-
Notifications
You must be signed in to change notification settings - Fork 0
feat(settings): add secondary sidebar and standalone sections #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { notFound } from "next/navigation"; | ||
| import { getScopeContext } from "@/lib/scope-context"; | ||
| import { PERSONAL_SETTINGS, TEAM_SETTINGS } from "@/lib/settings-navigation"; | ||
| import { TeamSettingsClient } from "@/components/settings/team-settings-client"; | ||
| import { TeamsListSection } from "@/components/settings/teams-list-section"; | ||
| import { CliApiKeysSection } from "@/components/settings/cli-api-keys-section"; | ||
| import { PersonalAccountPage } from "../_components/personal-account-page"; | ||
| import { ProviderKeysPage } from "../_components/provider-keys-page"; | ||
|
|
||
| export default async function SettingsSectionPage({ params }: { | ||
| params: Promise<{ section: string }>; | ||
| }) { | ||
| const [{ section }, scope] = await Promise.all([params, getScopeContext()]); | ||
| const items = scope.kind === "team" ? TEAM_SETTINGS : PERSONAL_SETTINGS; | ||
| const item = items.find((entry) => entry.id === section); | ||
| if (!item) notFound(); | ||
|
|
||
| if (scope.kind === "team") { | ||
| // Billing and MCP have static route segments; this page owns the other sections. | ||
| if (section !== "members" && section !== "keys" && section !== "models" && section !== "audit") notFound(); | ||
| return <TeamSettingsClient teamId={scope.teamId} teamSlug={scope.slug} section={section} />; | ||
| } | ||
|
|
||
| return ( | ||
| <div className="min-h-full w-full max-w-[1488px] space-y-4 p-3 md:space-y-6 md:p-6"> | ||
| <h1 className="ui-page-title">{item.label}</h1> | ||
| {section === "account" && <PersonalAccountPage />} | ||
| {section === "teams" && <TeamsListSection />} | ||
| {section === "keys" && <ProviderKeysPage />} | ||
| {section === "mogplex-keys" && <CliApiKeysSection />} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
app/(dashboard)/[scope]/settings/_components/personal-account-page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| "use client" | ||
|
|
||
| import { useCallback, useMemo } from "react" | ||
| import useSWR from "swr" | ||
| import { useUser } from "@/hooks/use-user" | ||
| import { fetchJsonArray, fetchJsonObject } from "@/lib/client-fetch" | ||
| import { DecisionChecksSection } from "@/components/settings/decision-checks-section" | ||
| import { trackActivation } from "@/lib/activation-tracking" | ||
| import { AccountSection } from "./account-section" | ||
| import type { GithubInstallationView, GithubOwnerTarget, SettingsView } from "./settings-types" | ||
|
|
||
| export function PersonalAccountPage() { | ||
| const { user, isLoading } = useUser() | ||
| const { error: settingsError } = useSWR<SettingsView>( | ||
| "/api/settings", | ||
| (url: string) => fetchJsonObject<SettingsView>(url, "Failed to load settings"), | ||
| ) | ||
| const settingsLoadError = settingsError ? "Unable to load settings preferences" : null | ||
| const { | ||
| data: githubInstallations, | ||
| error: githubInstallationsError, | ||
| } = useSWR<GithubInstallationView[]>( | ||
| "/api/github/installations", | ||
| (url: string) => fetchJsonArray<GithubInstallationView>(url, "Failed to load GitHub installations"), | ||
| ) | ||
| const { data: githubOwnerTargets } = useSWR<GithubOwnerTarget[]>( | ||
| user?.github_connected ? "/api/github/owners" : null, | ||
| (url: string) => fetchJsonArray<GithubOwnerTarget>(url, "Failed to load GitHub accounts"), | ||
| ) | ||
| const ownerTargets = githubOwnerTargets ?? [] | ||
| const ownerTargetsNeedingInstall = ownerTargets.filter((target) => target.github_installation_id == null) | ||
| const githubInstallationsLoadError = githubInstallationsError ? "Unable to load GitHub App installations" : null | ||
|
|
||
| const githubPrimaryAction = useMemo(() => { | ||
| if (user?.github_primary_action) return user.github_primary_action | ||
| if (!user?.github_connected) { | ||
| return { | ||
| label: user?.github_app_available ? "Install GitHub App" : "Connect GitHub", | ||
| href: "/api/auth/github", | ||
| } | ||
| } | ||
| return null | ||
| }, [user]) | ||
|
|
||
| const showGithubAddInstallAction = Boolean( | ||
| user?.github_app_available && | ||
| user?.github_connected && | ||
| githubPrimaryAction?.href !== "/api/auth/github", | ||
| ) | ||
|
|
||
| const nextStep = useMemo(() => { | ||
| if (githubPrimaryAction) { | ||
| const githubState = user?.github_state | ||
| const title = githubState === "app_installed" | ||
| ? "Sync repositories next" | ||
| : githubState === "app_install_pending" | ||
| ? "Complete the GitHub App install" | ||
| : githubState === "oauth_connected" | ||
| ? "Upgrade GitHub from OAuth to the App" | ||
| : "Install GitHub App next" | ||
| const description = githubState === "app_installed" | ||
| ? "Open Projects and sync the repositories covered by your GitHub App installation into Mogplex." | ||
| : user?.github_status_detail || "GitHub powers repo sync, trigger coverage, and automation." | ||
| return { | ||
| title, | ||
| description, | ||
| href: githubPrimaryAction.href, | ||
| label: githubPrimaryAction.label, | ||
| } | ||
| } | ||
|
|
||
| if (!user?.github_connected) { | ||
| return { | ||
| title: user?.github_app_available ? "Install GitHub App next" : "Connect GitHub next", | ||
| description: "GitHub is required to import repositories and make Open Workspace useful.", | ||
| href: "/api/auth/github", | ||
| label: user?.github_app_available ? "Install GitHub App" : "Connect GitHub", | ||
| } | ||
| } | ||
|
|
||
| return null | ||
| }, [githubPrimaryAction, user]) | ||
|
|
||
| const trackConnectionStart = useCallback((provider: "github", source: string) => { | ||
| if (provider === "github") { | ||
| trackActivation("github_connect_started", { | ||
| source, | ||
| connection_mode: user?.github_app_available ? "app" : "oauth", | ||
| }) | ||
| } | ||
| }, [user?.github_app_available]) | ||
|
|
||
| return ( | ||
| <div className="space-y-4 md:space-y-6"> | ||
| {settingsLoadError && <div className="text-sm text-destructive">{settingsLoadError}</div>} | ||
| <AccountSection | ||
| isLoading={isLoading} | ||
| user={user} | ||
| githubPrimaryAction={githubPrimaryAction} | ||
| showGithubAddInstallAction={showGithubAddInstallAction} | ||
| nextStep={nextStep} | ||
| trackConnectionStart={trackConnectionStart} | ||
| githubInstallationsLoadError={githubInstallationsLoadError} | ||
| githubInstallations={githubInstallations} | ||
| ownerTargets={ownerTargets} | ||
| ownerTargetsNeedingInstall={ownerTargetsNeedingInstall} | ||
| /> | ||
| <DecisionChecksSection endpoint="/api/settings/decision-checks" audience="personal" /> | ||
| </div> | ||
| ) | ||
| } |
9 changes: 9 additions & 0 deletions
9
app/(dashboard)/[scope]/settings/_components/provider-keys-page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| "use client"; | ||
|
|
||
| import { useUser } from "@/hooks/use-user"; | ||
| import { ApiKeysSection } from "./api-keys-section"; | ||
|
|
||
| export function ProviderKeysPage() { | ||
| const { user, isLoading } = useUser(); | ||
| return <ApiKeysSection platformAiEnabled={isLoading ? null : user?.platform_access?.allowPlatformAi ?? null} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning: Team scope can still reach the personal MCP page
TEAM_SETTINGShas nomcpentry and this guard notFounds anything outside members/keys/models/audit, but the staticsettings/mcp/page.tsxsegment wins over[section]and performs no scope-kind check —/{team}/settings/mcprenders the personal MCP servers page with no nav entry pointing at it. The route predates this PR, but the PR is what establishes the personal-only section list, so the inconsistency is now part of this contract.Suggestion: in
settings/mcp/page.tsx,const scope = await getScopeContext(); if (scope.kind === "team") notFound();(mirroring the guard here), or addmcptoTEAM_SETTINGSif team-scoped MCP is intended.Related nit on the same page: the personal branch renders a title-only page for any
PERSONAL_SETTINGSid without a matching component. It is unreachable today (mcp/billing have static routes), but a future section added to the list would silently render an empty page — consider anotFound()in the else branch.