diff --git a/apps/studio/components/interfaces/App/CommandMenu/CreateCommands.utils.tsx b/apps/studio/components/interfaces/App/CommandMenu/CreateCommands.utils.tsx index 58d54a6af07..4c7adb5bdea 100644 --- a/apps/studio/components/interfaces/App/CommandMenu/CreateCommands.utils.tsx +++ b/apps/studio/components/interfaces/App/CommandMenu/CreateCommands.utils.tsx @@ -1,4 +1,4 @@ -import { useFlag, useParams } from 'common' +import { useParams } from 'common' import type { Hook } from 'components/interfaces/Auth/Hooks/hooks.constants' import { HOOKS_DEFINITIONS } from 'components/interfaces/Auth/Hooks/hooks.constants' import { extractMethod, isValidHook } from 'components/interfaces/Auth/Hooks/hooks.utils' @@ -89,9 +89,6 @@ export function useCreateCommandsConfig() { const { openSidebar } = useSidebarManagerSnapshot() const snap = useAiAssistantStateSnapshot() - // Auth - const authenticationOauth21 = useFlag('EnableOAuth21') - const { projectAuthAll: authEnabled, projectEdgeFunctionAll: edgeFunctionsEnabled, @@ -182,7 +179,6 @@ export function useCreateCommandsConfig() { setPage, openSidebar, snap, - authenticationOauth21, authEnabled, edgeFunctionsEnabled, storageEnabled, diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx index 1c0d21ef48e..716618a7645 100644 --- a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx +++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx @@ -1,55 +1,23 @@ +import { useParams } from 'common' +import { ProductMenu } from 'components/ui/ProductMenu' +import { useAuthConfigPrefetch } from 'data/auth/auth-config-query' +import { withAuth } from 'hooks/misc/withAuth' import { useRouter } from 'next/router' import { PropsWithChildren } from 'react' -import { useFlag, useParams } from 'common' -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' -import { generateAuthMenu } from './AuthLayout.utils' +import { useGenerateAuthMenu } from './AuthLayout.utils' const AuthProductMenu = () => { const router = useRouter() const { ref: projectRef = 'default' } = useParams() - const authenticationShowOverview = useFlag('authOverviewPage') - const authenticationOauth21 = useFlag('EnableOAuth21') - - const { - authenticationSignInProviders, - authenticationRateLimits, - authenticationEmails, - authenticationMultiFactor, - authenticationAttackProtection, - authenticationPerformance, - } = useIsFeatureEnabled([ - 'authentication:sign_in_providers', - 'authentication:rate_limits', - 'authentication:emails', - 'authentication:multi_factor', - 'authentication:attack_protection', - 'authentication:performance', - ]) - useAuthConfigPrefetch({ projectRef }) const page = router.pathname.split('/')[4] - return ( - - ) + const menu = useGenerateAuthMenu() + + return } const AuthLayout = ({ children }: PropsWithChildren<{}>) => { diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts index 478aea25486..1fe0504cf67 100644 --- a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts +++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts @@ -1,48 +1,45 @@ +import { useFlag, useParams } from 'common' import type { ProductMenuGroup } from 'components/ui/ProductMenu/ProductMenu.types' import { IS_PLATFORM } from 'lib/constants' -export const generateAuthMenu = ( - ref: string, - flags?: { - authenticationSignInProviders: boolean - authenticationRateLimits: boolean - authenticationEmails: boolean - authenticationMultiFactor: boolean - authenticationAttackProtection: boolean - authenticationShowOverview: boolean - authenticationOauth21: boolean - authenticationPerformance: boolean - } -): ProductMenuGroup[] => { +import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' + +export const useGenerateAuthMenu = (): ProductMenuGroup[] => { + const { ref } = useParams() + const authenticationShowOverview = useFlag('authOverviewPage') + const { authenticationSignInProviders, authenticationRateLimits, authenticationEmails, authenticationMultiFactor, authenticationAttackProtection, - authenticationShowOverview, - authenticationOauth21, authenticationPerformance, - } = flags ?? {} + } = useIsFeatureEnabled([ + 'authentication:sign_in_providers', + 'authentication:rate_limits', + 'authentication:emails', + 'authentication:multi_factor', + 'authentication:attack_protection', + 'authentication:performance', + ]) + + const baseUrl = `/project/${ref}/auth` return [ { title: 'Manage', items: [ ...(authenticationShowOverview - ? [{ name: 'Overview', key: 'overview', url: `/project/${ref}/auth/overview`, items: [] }] - : []), - { name: 'Users', key: 'users', url: `/project/${ref}/auth/users`, items: [] }, - ...(authenticationOauth21 - ? [ - { - name: 'OAuth Apps', - key: 'oauth-apps', - url: `/project/${ref}/auth/oauth-apps`, - items: [], - }, - ] + ? [{ name: 'Overview', key: 'overview', url: `${baseUrl}/overview`, items: [] }] : []), + { name: 'Users', key: 'users', url: `${baseUrl}/users`, items: [] }, + { + name: 'OAuth Apps', + key: 'oauth-apps', + url: `${baseUrl}/oauth-apps`, + items: [], + }, ], }, ...(authenticationEmails && IS_PLATFORM @@ -56,7 +53,7 @@ export const generateAuthMenu = ( name: 'Email', key: 'email', pages: ['templates', 'smtp'], - url: `/project/${ref}/auth/templates`, + url: `${baseUrl}/templates`, items: [], }, ] @@ -71,7 +68,7 @@ export const generateAuthMenu = ( { name: 'Policies', key: 'policies', - url: `/project/${ref}/auth/policies`, + url: `${baseUrl}/policies`, items: [], }, ...(IS_PLATFORM @@ -82,25 +79,21 @@ export const generateAuthMenu = ( name: 'Sign In / Providers', key: 'sign-in-up', pages: ['providers', 'third-party'], - url: `/project/${ref}/auth/providers`, + url: `${baseUrl}/providers`, items: [], }, ] : []), - ...(authenticationOauth21 - ? [ - { - name: 'OAuth Server', - key: 'oauth-server', - url: `/project/${ref}/auth/oauth-server`, - label: 'Beta', - }, - ] - : []), + { + name: 'OAuth Server', + key: 'oauth-server', + url: `${baseUrl}/oauth-server`, + label: 'Beta', + }, { name: 'Sessions', key: 'sessions', - url: `/project/${ref}/auth/sessions`, + url: `${baseUrl}/sessions`, items: [], }, ...(authenticationRateLimits @@ -108,7 +101,7 @@ export const generateAuthMenu = ( { name: 'Rate Limits', key: 'rate-limits', - url: `/project/${ref}/auth/rate-limits`, + url: `${baseUrl}/rate-limits`, items: [], }, ] @@ -118,7 +111,7 @@ export const generateAuthMenu = ( { name: 'Multi-Factor', key: 'mfa', - url: `/project/${ref}/auth/mfa`, + url: `${baseUrl}/mfa`, items: [], }, ] @@ -126,7 +119,7 @@ export const generateAuthMenu = ( { name: 'URL Configuration', key: 'url-configuration', - url: `/project/${ref}/auth/url-configuration`, + url: `${baseUrl}/url-configuration`, items: [], }, ...(authenticationAttackProtection @@ -134,7 +127,7 @@ export const generateAuthMenu = ( { name: 'Attack Protection', key: 'protection', - url: `/project/${ref}/auth/protection`, + url: `${baseUrl}/protection`, items: [], }, ] @@ -142,14 +135,14 @@ export const generateAuthMenu = ( { name: 'Auth Hooks', key: 'hooks', - url: `/project/${ref}/auth/hooks`, + url: `${baseUrl}/hooks`, items: [], label: 'Beta', }, { name: 'Audit Logs', key: 'audit-logs', - url: `/project/${ref}/auth/audit-logs`, + url: `${baseUrl}/audit-logs`, items: [], }, ...(authenticationPerformance @@ -157,7 +150,7 @@ export const generateAuthMenu = ( { name: 'Performance', key: 'performance', - url: `/project/${ref}/auth/performance`, + url: `${baseUrl}/performance`, items: [], }, ] diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx index 995e6915d87..30bebf679ab 100644 --- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx +++ b/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx @@ -1,6 +1,4 @@ import { ICON_SIZE, ICON_STROKE_WIDTH } from 'components/interfaces/Sidebar' -import { generateAuthMenu } from 'components/layouts/AuthLayout/AuthLayout.utils' -import { generateDatabaseMenu } from 'components/layouts/DatabaseLayout/DatabaseMenu.utils' import { generateSettingsMenu } from 'components/layouts/ProjectSettingsLayout/SettingsMenu.utils' import type { Route } from 'components/ui/ui.types' import { EditorIndexPageLink } from 'data/prefetchers/project.$ref.editor' @@ -54,9 +52,6 @@ export const generateProductRoutes = ( const realtimeEnabled = features?.realtime ?? true const authOverviewPageEnabled = features?.authOverviewPage ?? false - const databaseMenu = generateDatabaseMenu(project) - const authMenu = generateAuthMenu(ref as string) - return [ { key: 'database', @@ -70,7 +65,6 @@ export const generateProductRoutes = ( : isProjectActive ? `/project/${ref}/database/schemas` : `/project/${ref}/database/backups/scheduled`), - items: databaseMenu, }, ...(authEnabled ? [ @@ -86,7 +80,6 @@ export const generateProductRoutes = ( : authOverviewPageEnabled ? `/project/${ref}/auth/overview` : `/project/${ref}/auth/users`), - items: authMenu, }, ] : []),