Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
feat(settings): self-host settings plane, Sim wordmark in sidebar#5990
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6e21cc12fa102e8cc1ceb09a13b9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Suspense } from 'react' | ||
| import type { Metadata } from 'next' | ||
| import { notFound, redirect } from 'next/navigation' | ||
| import { | ||
| getSelfHostSettingsHref, | ||
| getSettingsSectionMeta, | ||
| parseSettingsPathSection, | ||
| SELFHOST_SETTINGS_ITEMS, | ||
| } from '@/components/settings/navigation' | ||
| import { SelfHostSettingsRenderer } from '@/components/settings/selfhost-settings-renderer' | ||
| import { getSession } from '@/lib/auth' | ||
| import { isBillingEnabled, isHosted } from '@/lib/core/config/env-flags' | ||
| interface SelfHostSettingsSectionPageProps { | ||
| params: Promise<{ section: string }> | ||
| } | ||
| export async function generateMetadata({ | ||
| params, | ||
| }: SelfHostSettingsSectionPageProps): Promise<Metadata> { | ||
| const { section } = await params | ||
| const parsed = parseSettingsPathSection({ | ||
| path: section, | ||
| items: SELFHOST_SETTINGS_ITEMS, | ||
| defaultSection: null, | ||
| }) | ||
| const meta = parsed ? getSettingsSectionMeta('selfhost', parsed) : null | ||
| return { title: meta ? `${meta.label} - Self-host settings` : 'Self-host settings' } | ||
| } | ||
| export default async function SelfHostSettingsSectionPage({ | ||
| params, | ||
| }: SelfHostSettingsSectionPageProps) { | ||
| const session = await getSession() | ||
| if (!session?.user) redirect('/login') | ||
| const { section } = await params | ||
| const parsed = parseSettingsPathSection({ | ||
| path: section, | ||
| items: SELFHOST_SETTINGS_ITEMS, | ||
| defaultSection: null, | ||
| }) | ||
| if (!parsed) notFound() | ||
| if (parsed === 'billing' && !isBillingEnabled) redirect(getSelfHostSettingsHref('general')) | ||
| if (parsed === 'chat-keys' && !isHosted) redirect(getSelfHostSettingsHref('general')) | ||
| /** | ||
| * Sections read URL query params via nuqs (which uses `useSearchParams` | ||
| * internally), so the renderer must sit under a Suspense boundary. | ||
| */ | ||
| return ( | ||
| <Suspense fallback={null}> | ||
| <SelfHostSettingsRenderer section={parsed} /> | ||
| </Suspense> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { redirect } from 'next/navigation' | ||
| import { StandaloneSettingsShell } from '@/components/settings/standalone-settings-shell' | ||
| import { getSession } from '@/lib/auth' | ||
| export default async function SelfHostSettingsLayout({ children }: { children: React.ReactNode }) { | ||
| const session = await getSession() | ||
| if (!session?.user) redirect('/login') | ||
| return <StandaloneSettingsShell plane='selfhost'>{children}</StandaloneSettingsShell> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { redirect } from 'next/navigation' | ||
| import { getSelfHostSettingsHref } from '@/components/settings/navigation' | ||
| export default function SelfHostSettingsPage() { | ||
| redirect(getSelfHostSettingsHref('general')) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.