mirror of
https://github.com/supabase/supabase.git
synced 2026-05-07 06:27:16 +08:00
## What kind of change does this PR introduce? UI polish. Updates sidebar and submenu navigation hover and active styling. ## What is the current behavior? Product submenu navigation items either lack a hover fill or use a hover fill that visually matches the active state. Adjacent hovered and selected rows can appear to touch. ## What is the new behavior? Primary sidebar buttons, sidebar sub-buttons, and product submenu pills now share a muted hover fill while preserving the full accent fill for active/selected states. Product submenu rows also get a small visual gap with slightly reduced vertical padding to keep the overall spacing compact. | After | | --- | | <img width="988" height="408" alt="CleanShot 2026-05-05 at 11 53 05@2x" src="https://github.com/user-attachments/assets/560ac8a5-1262-41af-a196-618c86580150" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Refined sidebar hover/active states with subtle accent alpha colors for a more polished visual experience. * Updated sidebar menu spacing and rounded corners for improved touch and visual clarity. * **UI Improvements** * Sidebar now only displays when sections exist and uses a streamlined submenu flow for more consistent, predictable navigation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
239 lines
5.7 KiB
TypeScript
239 lines
5.7 KiB
TypeScript
import { useFlag, useParams } from 'common'
|
|
import { PropsWithChildren } from 'react'
|
|
|
|
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'
|
|
|
|
interface OrganizationSettingsMenuItemsProps {
|
|
slug?: string
|
|
showSecuritySettings?: boolean
|
|
showSsoSettings?: boolean
|
|
showLegalDocuments?: boolean
|
|
showPlatformWebhooks?: boolean
|
|
showPrivateApps?: 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,
|
|
showPrivateApps: _showPrivateApps = false,
|
|
}: 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,
|
|
showPrivateApps = false,
|
|
}: 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`,
|
|
},
|
|
...(showPrivateApps
|
|
? [
|
|
{
|
|
key: 'private-apps',
|
|
label: 'Private Apps',
|
|
href: `/org/${slug}/private-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 showPrivateApps = useFlag('privateApps')
|
|
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,
|
|
showPrivateApps,
|
|
})
|
|
|
|
// Browser titles for org settings routes are set by OrganizationLayout.
|
|
return (
|
|
<WithSidebar
|
|
title="Organization Settings"
|
|
sections={sections}
|
|
header={
|
|
<div className="border-default flex min-h-(--header-height) items-center border-b px-6">
|
|
<h4 className="text-lg">Settings</h4>
|
|
</div>
|
|
}
|
|
>
|
|
{children}
|
|
</WithSidebar>
|
|
)
|
|
}
|