mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
Stacked PR 4/5 for page title improvements. Includes account and organization-level title updates plus organization list/selector page titles. _Base: [dnywh/feat/page-titles](https://github.com/supabase/supabase/pull/43538)_ --- ## What kind of change does this PR introduce? - Resolves FE-1960 - Resolves FE-1983 - Resolves DEPR-207 ## What is the current behavior? Page titles between surfaces are inconsistent and vague. Sometimes they say the product name: ``` My Project | My Org | Supabase ``` ...even when on a specific surface like Database > Tables. Other times they show the entity name but skip over the project or org name : ``` Edge Functions | Supabase ``` ## What is the new behavior? Account and organization-level title updates plus organization list/selector page titles, adopting the layout title format introduced in https://github.com/supabase/supabase/pull/43538: ``` users | Table Editor | My Project | My Org | Supabase hello-world | Logs | Edge Functions | My Project | My Org | Supabase Backups | Database | My Project | My Org | Supabase Authentication | My Project | My Org | Supabase ``` That format is: entity, section, surface, project, org, brand ## Additional context Related stacked PRs also based on the the original [dnywh/feat/page-titles](https://github.com/supabase/supabase/pull/43538) branch: - https://github.com/supabase/supabase/pull/43534 - https://github.com/supabase/supabase/pull/43535 - https://github.com/supabase/supabase/pull/43537 --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
227 lines
5.3 KiB
TypeScript
227 lines
5.3 KiB
TypeScript
import { useParams } from 'common'
|
|
import { useIsPlatformWebhooksEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
|
|
import type { SidebarSection } from 'components/layouts/AccountLayout/AccountLayout.types'
|
|
import { WithSidebar } from 'components/layouts/AccountLayout/WithSidebar'
|
|
import { useCurrentPath } from 'hooks/misc/useCurrentPath'
|
|
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
|
|
import { PropsWithChildren } from 'react'
|
|
|
|
interface OrganizationSettingsMenuItemsProps {
|
|
slug?: string
|
|
showSecuritySettings?: boolean
|
|
showSsoSettings?: boolean
|
|
showLegalDocuments?: boolean
|
|
showPlatformWebhooks?: boolean
|
|
}
|
|
|
|
interface OrganizationSettingsSectionsProps extends OrganizationSettingsMenuItemsProps {
|
|
currentPath: string
|
|
}
|
|
|
|
export const normalizeOrganizationSettingsPath = (path: string) => path.split('#')[0]
|
|
|
|
export const generateOrganizationSettingsMenuItems = ({
|
|
slug,
|
|
showSecuritySettings = true,
|
|
showSsoSettings = true,
|
|
showLegalDocuments = true,
|
|
showPlatformWebhooks = true,
|
|
}: OrganizationSettingsMenuItemsProps) => [
|
|
{
|
|
key: 'general',
|
|
label: 'General',
|
|
href: `/org/${slug}/general`,
|
|
},
|
|
...(showSecuritySettings
|
|
? [
|
|
{
|
|
key: 'security',
|
|
label: 'Security',
|
|
href: `/org/${slug}/security`,
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
key: 'apps',
|
|
label: 'OAuth Apps',
|
|
href: `/org/${slug}/apps`,
|
|
},
|
|
...(showSsoSettings
|
|
? [
|
|
{
|
|
key: 'sso',
|
|
label: 'SSO',
|
|
href: `/org/${slug}/sso`,
|
|
},
|
|
]
|
|
: []),
|
|
...(showPlatformWebhooks
|
|
? [
|
|
{
|
|
key: 'webhooks',
|
|
label: 'Webhooks',
|
|
href: `/org/${slug}/webhooks`,
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
key: 'audit',
|
|
label: 'Audit Logs',
|
|
href: `/org/${slug}/audit`,
|
|
},
|
|
...(showLegalDocuments
|
|
? [
|
|
{
|
|
key: 'documents',
|
|
label: 'Legal Documents',
|
|
href: `/org/${slug}/documents`,
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
|
|
export const generateOrganizationSettingsSections = ({
|
|
currentPath,
|
|
slug,
|
|
showSecuritySettings = true,
|
|
showSsoSettings = true,
|
|
showLegalDocuments = true,
|
|
showPlatformWebhooks = true,
|
|
}: OrganizationSettingsSectionsProps): SidebarSection[] => {
|
|
const isLinkActive = (key: string, href: string) =>
|
|
key === 'webhooks'
|
|
? currentPath === href || currentPath.startsWith(`${href}/`)
|
|
: currentPath === href
|
|
|
|
const configurationLinks = [
|
|
{
|
|
key: 'general',
|
|
label: 'General',
|
|
href: `/org/${slug}/general`,
|
|
},
|
|
...(showSecuritySettings
|
|
? [
|
|
{
|
|
key: 'security',
|
|
label: 'Security',
|
|
href: `/org/${slug}/security`,
|
|
},
|
|
]
|
|
: []),
|
|
...(showSsoSettings
|
|
? [
|
|
{
|
|
key: 'sso',
|
|
label: 'SSO',
|
|
href: `/org/${slug}/sso`,
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
|
|
const connectionsLinks = [
|
|
{
|
|
key: 'apps',
|
|
label: 'OAuth Apps',
|
|
href: `/org/${slug}/apps`,
|
|
},
|
|
...(showPlatformWebhooks
|
|
? [
|
|
{
|
|
key: 'webhooks',
|
|
label: 'Webhooks',
|
|
href: `/org/${slug}/webhooks`,
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
|
|
const complianceLinks = [
|
|
{
|
|
key: 'audit',
|
|
label: 'Audit Logs',
|
|
href: `/org/${slug}/audit`,
|
|
},
|
|
...(showLegalDocuments
|
|
? [
|
|
{
|
|
key: 'documents',
|
|
label: 'Legal Documents',
|
|
href: `/org/${slug}/documents`,
|
|
},
|
|
]
|
|
: []),
|
|
]
|
|
|
|
return [
|
|
{
|
|
key: 'configuration',
|
|
heading: 'Configuration',
|
|
links: configurationLinks.map((item) => ({
|
|
...item,
|
|
isActive: isLinkActive(item.key, item.href),
|
|
})),
|
|
},
|
|
{
|
|
key: 'connections',
|
|
heading: 'Connections',
|
|
links: connectionsLinks.map((item) => ({
|
|
...item,
|
|
isActive: isLinkActive(item.key, item.href),
|
|
})),
|
|
},
|
|
{
|
|
key: 'compliance',
|
|
heading: 'Compliance',
|
|
links: complianceLinks.map((item) => ({
|
|
...item,
|
|
isActive: isLinkActive(item.key, item.href),
|
|
})),
|
|
},
|
|
]
|
|
}
|
|
|
|
export function OrganizationSettingsLayout({ children }: PropsWithChildren) {
|
|
const { slug } = useParams()
|
|
const showPlatformWebhooks = useIsPlatformWebhooksEnabled()
|
|
const fullCurrentPath = useCurrentPath()
|
|
const currentPath = normalizeOrganizationSettingsPath(fullCurrentPath)
|
|
|
|
const {
|
|
organizationShowSsoSettings: showSsoSettings,
|
|
organizationShowSecuritySettings: showSecuritySettings,
|
|
organizationShowLegalDocuments: showLegalDocuments,
|
|
} = useIsFeatureEnabled([
|
|
'organization:show_sso_settings',
|
|
'organization:show_security_settings',
|
|
'organization:show_legal_documents',
|
|
])
|
|
|
|
const sections = generateOrganizationSettingsSections({
|
|
currentPath,
|
|
slug,
|
|
showSecuritySettings,
|
|
showSsoSettings,
|
|
showLegalDocuments,
|
|
showPlatformWebhooks,
|
|
})
|
|
|
|
// Browser titles for org settings routes are set by OrganizationLayout.
|
|
return (
|
|
<WithSidebar
|
|
title="Organization Settings"
|
|
breadcrumbs={[]}
|
|
sections={sections}
|
|
header={
|
|
<div className="border-default flex min-h-[var(--header-height)] items-center border-b px-6">
|
|
<h4 className="text-lg">Settings</h4>
|
|
</div>
|
|
}
|
|
>
|
|
{children}
|
|
</WithSidebar>
|
|
)
|
|
}
|
|
|
|
export default OrganizationSettingsLayout
|