OrganizationSettingsMenu.tsx50 lines · main
| 1 | import { useFlag, useParams } from 'common' |
| 2 | import { useRouter } from 'next/router' |
| 3 | |
| 4 | import { |
| 5 | generateOrganizationSettingsSections, |
| 6 | normalizeOrganizationSettingsPath, |
| 7 | } from './OrganizationSettingsLayout' |
| 8 | import { useIsPlatformWebhooksEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext' |
| 9 | import { SubMenu } from '@/components/ui/ProductMenu/SubMenu' |
| 10 | import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' |
| 11 | import { getPathnameWithoutQuery } from '@/lib/pathname.utils' |
| 12 | |
| 13 | export interface OrganizationSettingsMenuProps { |
| 14 | onCloseSheet?: () => void |
| 15 | } |
| 16 | |
| 17 | export function OrganizationSettingsMenu({ onCloseSheet }: OrganizationSettingsMenuProps) { |
| 18 | const router = useRouter() |
| 19 | const { slug } = useParams() |
| 20 | const organizationSlug = slug ?? (router.query.orgSlug as string) ?? '' |
| 21 | |
| 22 | const pathname = getPathnameWithoutQuery(router.asPath, router.pathname) |
| 23 | const currentPath = normalizeOrganizationSettingsPath(pathname) |
| 24 | const showPlatformWebhooks = useIsPlatformWebhooksEnabled() |
| 25 | const showPrivateApps = useFlag('privateApps') |
| 26 | |
| 27 | const { |
| 28 | organizationShowSsoSettings: showSsoSettings, |
| 29 | organizationShowSecuritySettings: showSecuritySettings, |
| 30 | organizationShowLegalDocuments: showLegalDocuments, |
| 31 | } = useIsFeatureEnabled([ |
| 32 | 'organization:show_sso_settings', |
| 33 | 'organization:show_security_settings', |
| 34 | 'organization:show_legal_documents', |
| 35 | ]) |
| 36 | |
| 37 | const sections = generateOrganizationSettingsSections({ |
| 38 | slug: organizationSlug, |
| 39 | currentPath, |
| 40 | showSecuritySettings: showSecuritySettings, |
| 41 | showSsoSettings, |
| 42 | showLegalDocuments, |
| 43 | showPlatformWebhooks, |
| 44 | showPrivateApps, |
| 45 | }) |
| 46 | |
| 47 | const page = currentPath.split('/').filter(Boolean).pop() |
| 48 | |
| 49 | return <SubMenu sections={sections} page={page} onItemClick={onCloseSheet} /> |
| 50 | } |