Files
supabase/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
T
Danny WhiteandJoshen Lim c1681cfcc2 chore(studio): add feature preview for auth security template UI (#39661)
* feature preview logic

* sidebar changes based on feature preview

* singular naming

* minor

* Flip isPlatformOnly for new preview

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-10-21 15:18:56 +11:00

75 lines
2.2 KiB
TypeScript

import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { useFlag, useParams } from 'common'
import { useIsSecurityNotificationsEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { ProductMenu } from 'components/ui/ProductMenu'
import { useAuthConfigPrefetch } from 'data/auth/auth-config-query'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { withAuth } from 'hooks/misc/withAuth'
import { ProjectLayout } from '../ProjectLayout/ProjectLayout'
import { generateAuthMenu } from './AuthLayout.utils'
const AuthProductMenu = () => {
const router = useRouter()
const { ref: projectRef = 'default' } = useParams()
const authenticationShowOverview = useFlag('authOverviewPage')
const authenticationShowSecurityNotifications = useIsSecurityNotificationsEnabled()
const {
authenticationSignInProviders,
authenticationRateLimits,
authenticationEmails,
authenticationMultiFactor,
authenticationAttackProtection,
authenticationAdvanced,
} = useIsFeatureEnabled([
'authentication:sign_in_providers',
'authentication:rate_limits',
'authentication:emails',
'authentication:multi_factor',
'authentication:attack_protection',
'authentication:advanced',
])
useAuthConfigPrefetch({ projectRef })
const page = router.pathname.split('/')[4]
return (
<ProductMenu
page={page}
menu={generateAuthMenu(projectRef, {
authenticationSignInProviders,
authenticationRateLimits,
authenticationEmails,
authenticationMultiFactor,
authenticationAttackProtection,
authenticationAdvanced,
authenticationShowOverview,
authenticationShowSecurityNotifications,
})}
/>
)
}
const AuthLayout = ({ children }: PropsWithChildren<{}>) => {
return (
<ProjectLayout
title="Authentication"
product="Authentication"
productMenu={<AuthProductMenu />}
isBlocking={false}
>
{children}
</ProjectLayout>
)
}
/**
* Layout for all auth pages on the dashboard, wrapped with withAuth to verify logged in state
*
* Handles rendering the navigation for each section under the auth pages.
*/
export default withAuth(AuthLayout)