Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): add Auth sub-page navigation chords (#45696)

Ali Waseem0278672102b0
diff --git a/apps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsx b/apps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsx
index 39f86f5b35c..e1b28051a8f 100644
--- a/apps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsx
+++ b/apps/studio/components/interfaces/Auth/CustomAuthProviders/CustomAuthProvidersList.tsx
@@ -2,7 +2,7 @@ import { useQueryClient } from '@tanstack/react-query'
import { useParams } from 'common'
import { Edit, MoreVertical, Plus, Power, PowerOff, Search, Trash, X } from 'lucide-react'
import { parseAsBoolean, parseAsStringLiteral, useQueryState } from 'nuqs'
-import { useEffect, useMemo, useState } from 'react'
+import { useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import {
Badge,
@@ -40,6 +40,7 @@ import { DeleteCustomProviderModal } from './DeleteCustomProviderModal'
import { DisableCustomProviderModal } from './DisableCustomProviderModal'
import AlertError from '@/components/ui/AlertError'
import { FilterPopover } from '@/components/ui/FilterPopover'
+import { Shortcut } from '@/components/ui/Shortcut'
import { UpgradePlanButton } from '@/components/ui/UpgradePlanButton'
import { useAuthConfigQuery } from '@/data/auth/auth-config-query'
import { useAuthConfigUpdateMutation } from '@/data/auth/auth-config-update-mutation'
@@ -47,6 +48,9 @@ import { useProjectApiUrl } from '@/data/config/project-endpoint-query'
import { useOAuthCustomProviderUpdateMutation } from '@/data/oauth-custom-providers/oauth-custom-provider-update-mutation'
import { useOAuthCustomProvidersQuery } from '@/data/oauth-custom-providers/oauth-custom-providers-query'
import { useSelectedOrganizationQuery } from '@/hooks/misc/useSelectedOrganization'
+import { onSearchInputEscape } from '@/lib/keyboard'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
const CUSTOM_PROVIDERS_SORT_VALUES = [
'name:asc',
@@ -125,6 +129,7 @@ export const CustomAuthProvidersList = () => {
const [selectedProviderToDisable, setSelectedProviderToDisable] = useState<string | null>(null)
const [filteredProviderTypes, setFilteredProviderTypes] = useState<string[]>([])
const [filteredEnabledStatuses, setFilteredEnabledStatuses] = useState<string[]>([])
+ const searchInputRef = useRef<HTMLInputElement>(null)
const {
data: customProviders,
@@ -213,6 +218,17 @@ export const CustomAuthProvidersList = () => {
setFilteredEnabledStatuses([])
}
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ searchInputRef.current?.focus()
+ searchInputRef.current?.select()
+ },
+ { label: 'Search custom providers' }
+ )
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, handleResetFilters)
+
const handleSortChange = (column: CustomProvidersSortColumn) => {
const [currentCol, currentOrder] = sort.split(':') as [
CustomProvidersSortColumn,
@@ -288,10 +304,12 @@ export const CustomAuthProvidersList = () => {
<div className="flex flex-col lg:flex-row lg:items-center gap-2">
<InputGroup className="w-full lg:w-52">
<InputGroupInput
+ ref={searchInputRef}
size="tiny"
placeholder="Search custom providers"
value={filterString}
onChange={(e) => setFilterString(e.target.value)}
+ onKeyDown={onSearchInputEscape(filterString, setFilterString)}
/>
<InputGroupAddon>
<Search />
@@ -370,10 +388,22 @@ export const CustomAuthProvidersList = () => {
</HoverCardContent>
</HoverCard>
) : (
- <NewProviderButton
- canCreateProvider={canCreateProvider}
- setShowCreateSheet={setShowCreateSheet}
- />
+ <Shortcut
+ id={SHORTCUT_IDS.LIST_PAGE_NEW_ITEM}
+ label="Create new provider"
+ onTrigger={() => setShowCreateSheet(true)}
+ side="bottom"
+ >
+ <Button
+ type="primary"
+ disabled={!canCreateProvider}
+ icon={<Plus />}
+ onClick={() => setShowCreateSheet(true)}
+ className="grow"
+ >
+ New Provider
+ </Button>
+ </Shortcut>
)}
</div>
</div>
diff --git a/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx b/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx
index 38e1337b0e7..d002751b0fe 100644
--- a/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx
+++ b/apps/studio/components/interfaces/Auth/Hooks/AddHookDropdown.tsx
@@ -25,6 +25,8 @@ interface AddHookDropdownProps {
buttonText?: string
align?: 'end' | 'center'
type?: 'primary' | 'default'
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
onSelectHook: (hook: HOOK_DEFINITION_TITLE) => void
}
@@ -32,6 +34,8 @@ export const AddHookDropdown = ({
buttonText = 'Add hook',
align = 'end',
type = 'primary',
+ open,
+ onOpenChange,
onSelectHook,
}: AddHookDropdownProps) => {
const { ref: projectRef } = useParams()
@@ -78,7 +82,7 @@ export const AddHookDropdown = ({
}
return (
- <DropdownMenu>
+ <DropdownMenu open={open} onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild>
<Button type={type} iconRight={<ChevronDown />}>
{buttonText}
diff --git a/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx b/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx
index 5240577c525..dde463edb53 100644
--- a/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx
+++ b/apps/studio/components/interfaces/Auth/Hooks/HooksListing.tsx
@@ -26,6 +26,8 @@ import { useAuthConfigQuery } from '@/data/auth/auth-config-query'
import { useAuthHooksUpdateMutation } from '@/data/auth/auth-hooks-update-mutation'
import { executeSql } from '@/data/sql/execute-sql-query'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
export const HooksListing = () => {
const { ref: projectRef } = useParams()
@@ -40,6 +42,8 @@ export const HooksListing = () => {
const [hook, setHook] = useQueryState('hook', parseAsString)
const [selectedHookForDeletion, setSelectedHookForDeletion] = useState<Hook | null>(null)
+ const [addHookAsideOpen, setAddHookAsideOpen] = useState(false)
+ const [addHookEmptyOpen, setAddHookEmptyOpen] = useState(false)
const { mutate: updateAuthHooks, isPending: isDeletingAuthHook } = useAuthHooksUpdateMutation({
onSuccess: async () => {
@@ -74,6 +78,15 @@ export const HooksListing = () => {
}
})
+ const validHooks = hooks.filter((h) => isValidHook(h))
+ const hasValidHooks = validHooks.length > 0
+
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_NEW_ITEM,
+ () => (hasValidHooks ? setAddHookAsideOpen(true) : setAddHookEmptyOpen(true)),
+ { label: 'Add hook' }
+ )
+
const selectedHook = hooks.find((h) => h.id === hook)
useEffect(() => {
@@ -114,6 +127,8 @@ export const HooksListing = () => {
</PageSectionSummary>
<PageSectionAside>
<AddHookDropdown
+ open={addHookAsideOpen}
+ onOpenChange={setAddHookAsideOpen}
onSelectHook={(title) => {
const hook = hooks.find((h) => h.title === title)
if (hook) setHook(hook.id)
@@ -122,7 +137,7 @@ export const HooksListing = () => {
</PageSectionAside>
</PageSectionMeta>
<PageSectionContent>
- {hooks.filter((h) => isValidHook(h)).length === 0 && (
+ {!hasValidHooks && (
<EmptyStatePresentational
title="Create an auth hook"
description="Use Postgres functions or HTTP endpoints to customize your authentication flow."
@@ -131,6 +146,8 @@ export const HooksListing = () => {
type="default"
align="center"
buttonText="Add a new hook"
+ open={addHookEmptyOpen}
+ onOpenChange={setAddHookEmptyOpen}
onSelectHook={(title) => {
const hook = hooks.find((h) => h.title === title)
if (hook) setHook(hook.id)
@@ -140,13 +157,9 @@ export const HooksListing = () => {
)}
<div className="-space-y-px">
- {hooks
- .filter((h) => isValidHook(h))
- .map((hook) => {
- return (
- <HookCard key={hook.enabledKey} hook={hook} onSelect={() => setHook(hook.id)} />
- )
- })}
+ {validHooks.map((hook) => {
+ return <HookCard key={hook.enabledKey} hook={hook} onSelect={() => setHook(hook.id)} />
+ })}
</div>
<CreateHookSheet
diff --git a/apps/studio/components/interfaces/Auth/OAuthApps/OAuthAppsList.tsx b/apps/studio/components/interfaces/Auth/OAuthApps/OAuthAppsList.tsx
index 149271a6f54..1b04a3d7739 100644
--- a/apps/studio/components/interfaces/Auth/OAuthApps/OAuthAppsList.tsx
+++ b/apps/studio/components/interfaces/Auth/OAuthApps/OAuthAppsList.tsx
@@ -3,7 +3,7 @@ import { useParams } from 'common'
import { Edit, MoreVertical, Plus, RotateCw, Search, Trash, X } from 'lucide-react'
import Link from 'next/link'
import { parseAsBoolean, parseAsString, parseAsStringLiteral, useQueryState } from 'nuqs'
-import { useEffect, useMemo, useState } from 'react'
+import { useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import {
Button,
@@ -40,11 +40,15 @@ import {
import AlertError from '@/components/ui/AlertError'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { FilterPopover } from '@/components/ui/FilterPopover'
+import { Shortcut } from '@/components/ui/Shortcut'
import { useAuthConfigQuery } from '@/data/auth/auth-config-query'
import { useProjectApiUrl } from '@/data/config/project-endpoint-query'
import { useOAuthServerAppDeleteMutation } from '@/data/oauth-server-apps/oauth-server-app-delete-mutation'
import { useOAuthServerAppRegenerateSecretMutation } from '@/data/oauth-server-apps/oauth-server-app-regenerate-secret-mutation'
import { useOAuthServerAppsQuery } from '@/data/oauth-server-apps/oauth-server-apps-query'
+import { onSearchInputEscape } from '@/lib/keyboard'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
const OAUTH_APPS_SORT_VALUES = [
'name:asc',
@@ -76,6 +80,7 @@ export const OAuthAppsList = () => {
const [filteredRegistrationTypes, setFilteredRegistrationTypes] = useState<string[]>([])
const [filteredClientTypes, setFilteredClientTypes] = useState<string[]>([])
const [filterString, setFilterString] = useState<string>('')
+ const searchInputRef = useRef<HTMLInputElement>(null)
const { hostEndpoint: clientEndpoint } = useProjectApiUrl({ projectRef })
const {
@@ -162,6 +167,17 @@ export const OAuthAppsList = () => {
setFilteredClientTypes([])
}
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ searchInputRef.current?.focus()
+ searchInputRef.current?.select()
+ },
+ { label: 'Search OAuth apps' }
+ )
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, handleResetFilters)
+
const handleSortChange = (column: OAuthAppsSortColumn) => {
const [currentCol, currentOrder] = sort.split(':') as [OAuthAppsSortColumn, OAuthAppsSortOrder]
if (currentCol === column) {
@@ -235,10 +251,12 @@ export const OAuthAppsList = () => {
<div className="flex flex-col lg:flex-row lg:items-center gap-2">
<InputGroup className="w-full lg:w-52">
<InputGroupInput
+ ref={searchInputRef}
size="tiny"
placeholder="Search OAuth apps"
value={filterString}
onChange={(e) => setFilterString(e.target.value)}
+ onKeyDown={onSearchInputEscape(filterString, setFilterString)}
/>
<InputGroupAddon>
<Search />
@@ -279,22 +297,38 @@ export const OAuthAppsList = () => {
)}
</div>
<div className="flex items-center gap-x-2">
- <ButtonTooltip
- disabled={!isOAuthServerEnabled}
- icon={<Plus />}
- onClick={() => setShowCreateSheet(true)}
- className="grow"
- tooltip={{
- content: {
- side: 'bottom',
- text: !isOAuthServerEnabled
- ? 'OAuth server must be enabled in settings'
- : undefined,
- },
- }}
- >
- New OAuth App
- </ButtonTooltip>
+ {isOAuthServerEnabled ? (
+ <Shortcut
+ id={SHORTCUT_IDS.LIST_PAGE_NEW_ITEM}
+ label="Create new OAuth app"
+ onTrigger={() => setShowCreateSheet(true)}
+ side="bottom"
+ >
+ <Button
+ type="primary"
+ icon={<Plus />}
+ onClick={() => setShowCreateSheet(true)}
+ className="grow"
+ >
+ New OAuth App
+ </Button>
+ </Shortcut>
+ ) : (
+ <ButtonTooltip
+ disabled
+ icon={<Plus />}
+ onClick={() => setShowCreateSheet(true)}
+ className="grow"
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: 'OAuth server must be enabled in settings',
+ },
+ }}
+ >
+ New OAuth App
+ </ButtonTooltip>
+ )}
</div>
</div>
diff --git a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
index 9e452ff5300..c698c5db9bd 100644
--- a/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
+++ b/apps/studio/components/interfaces/Auth/RedirectUrls/RedirectUrlList.tsx
@@ -5,7 +5,9 @@ import { Button, Checkbox } from 'ui'
import { ValueContainer } from './ValueContainer'
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
import { EmptyListState } from '@/components/ui/EmptyListState'
+import { Shortcut } from '@/components/ui/Shortcut'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
interface RedirectUrlListProps {
allowList: string[]
@@ -87,20 +89,28 @@ export const RedirectUrlList = ({
</ButtonTooltip>
</div>
) : (
- <ButtonTooltip
- disabled={!canUpdateConfig}
- onClick={() => onSelectAddURL()}
- tooltip={{
- content: {
- side: 'bottom',
- text: !canUpdateConfig
- ? 'You need additional permissions to update redirect URLs'
- : undefined,
- },
- }}
+ <Shortcut
+ id={SHORTCUT_IDS.LIST_PAGE_NEW_ITEM}
+ label="Add redirect URL"
+ onTrigger={() => onSelectAddURL()}
+ options={{ enabled: canUpdateConfig }}
+ side="bottom"
>
- Add URL
- </ButtonTooltip>
+ <ButtonTooltip
+ disabled={!canUpdateConfig}
+ onClick={() => onSelectAddURL()}
+ tooltip={{
+ content: {
+ side: 'bottom',
+ text: !canUpdateConfig
+ ? 'You need additional permissions to update redirect URLs'
+ : undefined,
+ },
+ }}
+ >
+ Add URL
+ </ButtonTooltip>
+ </Shortcut>
)}
</ValueContainer>
{allowList.length > 0 ? (
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
index d5ab1fa1936..d2ebc0202b7 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AddIntegrationDropdown.tsx
@@ -21,6 +21,8 @@ interface AddIntegrationDropdownProps {
buttonText?: string
align?: 'end' | 'center'
type?: 'primary' | 'default'
+ open?: boolean
+ onOpenChange?: (open: boolean) => void
onSelectIntegrationType: (type: INTEGRATION_TYPES) => void
}
@@ -49,10 +51,12 @@ const ProviderDropdownItem = ({
export const AddIntegrationDropdown = ({
type = 'primary',
align = 'end',
+ open,
+ onOpenChange,
onSelectIntegrationType,
}: AddIntegrationDropdownProps) => {
return (
- <DropdownMenu>
+ <DropdownMenu open={open} onOpenChange={onOpenChange}>
<DropdownMenuTrigger asChild>
<Button type={type} iconRight={<ChevronDown />}>
Add provider
diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
index 53b9c5c3ee5..78fed9f5b71 100644
--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/index.tsx
@@ -39,6 +39,8 @@ import {
} from '@/data/third-party-auth/integrations-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { DOCS_URL } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
export const ThirdPartyAuthForm = () => {
const { ref: projectRef } = useParams()
@@ -54,6 +56,11 @@ export const ThirdPartyAuthForm = () => {
const [selectedIntegration, setSelectedIntegration] = useState<INTEGRATION_TYPES>()
const [selectedIntegrationForDeletion, setSelectedIntegrationForDeletion] =
useState<ThirdPartyAuthIntegration>()
+ const [addIntegrationOpen, setAddIntegrationOpen] = useState(false)
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_NEW_ITEM, () => setAddIntegrationOpen(true), {
+ label: 'Add provider',
+ })
const { mutateAsync: deleteIntegration } = useDeleteThirdPartyAuthIntegrationMutation()
const { can: canUpdateConfig } = useAsyncCheckPermissions(
@@ -87,7 +94,11 @@ export const ThirdPartyAuthForm = () => {
</PageSectionSummary>
<PageSectionAside>
<DocsButton href={`${DOCS_URL}/guides/auth/third-party/overview`} />
- <AddIntegrationDropdown onSelectIntegrationType={setSelectedIntegration} />
+ <AddIntegrationDropdown
+ open={addIntegrationOpen}
+ onOpenChange={setAddIntegrationOpen}
+ onSelectIntegrationType={setSelectedIntegration}
+ />
</PageSectionAside>
</PageSectionMeta>
<PageSectionContent>
@@ -110,6 +121,8 @@ export const ThirdPartyAuthForm = () => {
<AddIntegrationDropdown
align="center"
type="default"
+ open={addIntegrationOpen}
+ onOpenChange={setAddIntegrationOpen}
onSelectIntegrationType={setSelectedIntegration}
/>
</EmptyStatePresentational>
diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
index 73c6e69de50..72e21215c2c 100644
--- a/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
+++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.tsx
@@ -5,6 +5,7 @@ import type { PropsWithChildren } from 'react'
import { ProjectLayout } from '../ProjectLayout'
import { useGenerateAuthMenu } from './AuthLayout.utils'
import { ProductMenu } from '@/components/ui/ProductMenu'
+import { ProductMenuShortcuts } from '@/components/ui/ProductMenu/ProductMenuShortcuts'
import { useAuthConfigPrefetch } from '@/data/auth/auth-config-query'
import { withAuth } from '@/hooks/misc/withAuth'
@@ -20,13 +21,21 @@ export const AuthProductMenu = () => {
}
const AuthLayout = ({ title, children }: PropsWithChildren<{ title: string }>) => {
+ const router = useRouter()
+ const { ref: projectRef = 'default' } = useParams()
+
+ useAuthConfigPrefetch({ projectRef })
+ const page = router.pathname.split('/')[4]
+ const menu = useGenerateAuthMenu()
+
return (
<ProjectLayout
product="Authentication"
browserTitle={{ section: title }}
- productMenu={<AuthProductMenu />}
+ productMenu={<ProductMenu page={page} menu={menu} />}
isBlocking={false}
>
+ <ProductMenuShortcuts menu={menu} />
{children}
</ProjectLayout>
)
diff --git a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
index ae9ffff3d6b..b593ae60108 100644
--- a/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
+++ b/apps/studio/components/layouts/AuthLayout/AuthLayout.utils.ts
@@ -3,6 +3,7 @@ import { useFlag, useParams } from 'common'
import type { ProductMenuGroup } from '@/components/ui/ProductMenu/ProductMenu.types'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { IS_PLATFORM } from '@/lib/constants'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
export interface GenerateAuthMenuOptions {
ref?: string
@@ -29,9 +30,23 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
title: 'Manage',
items: [
...(showOverview
- ? [{ name: 'Overview', key: 'overview', url: `${baseUrl}/overview`, items: [] }]
+ ? [
+ {
+ name: 'Overview',
+ key: 'overview',
+ url: `${baseUrl}/overview`,
+ items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_OVERVIEW,
+ },
+ ]
: []),
- { name: 'Users', key: 'users', url: `${baseUrl}/users`, items: [] },
+ {
+ name: 'Users',
+ key: 'users',
+ url: `${baseUrl}/users`,
+ items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_USERS,
+ },
...(isPlatform
? [
{
@@ -39,6 +54,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'oauth-apps',
url: `${baseUrl}/oauth-apps`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_OAUTH_APPS,
},
]
: []),
@@ -57,6 +73,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
pages: ['templates', 'smtp'],
url: `${baseUrl}/templates`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_EMAIL,
},
]
: []),
@@ -72,6 +89,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'policies',
url: `${baseUrl}/policies`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_POLICIES,
},
...(isPlatform
? [
@@ -83,6 +101,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
pages: ['providers', 'third-party'],
url: `${baseUrl}/providers`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_SIGN_IN,
},
]
: []),
@@ -93,6 +112,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'passkeys',
url: `${baseUrl}/passkeys`,
label: 'Beta',
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_PASSKEYS,
},
]
: []),
@@ -101,12 +121,14 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'oauth-server',
url: `${baseUrl}/oauth-server`,
label: 'Beta',
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_OAUTH_SERVER,
},
{
name: 'Sessions',
key: 'sessions',
url: `${baseUrl}/sessions`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_SESSIONS,
},
...(features.rateLimits
? [
@@ -115,6 +137,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'rate-limits',
url: `${baseUrl}/rate-limits`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_RATE_LIMITS,
},
]
: []),
@@ -125,6 +148,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'mfa',
url: `${baseUrl}/mfa`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_MFA,
},
]
: []),
@@ -133,6 +157,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'url-configuration',
url: `${baseUrl}/url-configuration`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_URL_CONFIGURATION,
},
...(features.attackProtection
? [
@@ -141,6 +166,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'protection',
url: `${baseUrl}/protection`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_PROTECTION,
},
]
: []),
@@ -150,12 +176,14 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
url: `${baseUrl}/hooks`,
items: [],
label: 'Beta',
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_HOOKS,
},
{
name: 'Audit Logs',
key: 'audit-logs',
url: `${baseUrl}/audit-logs`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_AUDIT_LOGS,
},
...(features.performance
? [
@@ -164,6 +192,7 @@ export function generateAuthMenu(options: GenerateAuthMenuOptions): ProductMenuG
key: 'performance',
url: `${baseUrl}/performance`,
items: [],
+ shortcutId: SHORTCUT_IDS.NAV_AUTH_PERFORMANCE,
},
]
: []),
diff --git a/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.test.tsx b/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.test.tsx
index 433a5a3cd4d..3668f8727ca 100644
--- a/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.test.tsx
+++ b/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.test.tsx
@@ -32,6 +32,11 @@ const ACTIVE_DATABASE_SHORTCUT_IDS = [
SHORTCUT_IDS.NAV_DATABASE_TABLES,
] satisfies ShortcutId[]
+const ACTIVE_AUTH_SHORTCUT_IDS = [
+ ...ACTIVE_SHORTCUT_IDS,
+ SHORTCUT_IDS.NAV_AUTH_USERS,
+] satisfies ShortcutId[]
+
let sequenceIdCounter = 0
const buildSequenceRegistration = (id: ShortcutId): SequenceRegistrationView => {
@@ -128,6 +133,15 @@ describe('ShortcutsReferenceSheet', () => {
expect(screen.getByText('Go to Tables')).toBeInTheDocument()
})
+ it('shows the auth navigation section when auth shortcuts are active', async () => {
+ renderShortcutsReferenceSheet(ACTIVE_AUTH_SHORTCUT_IDS)
+
+ expect(await screen.findByText('Global Navigation')).toBeInTheDocument()
+ expect(screen.getByText('Auth Navigation')).toBeInTheDocument()
+ expect(screen.queryByText(/^Navigation$/)).not.toBeInTheDocument()
+ expect(screen.getByText('Go to Users')).toBeInTheDocument()
+ })
+
it('does not show inactive database shortcuts in search results', async () => {
const user = userEvent.setup()
diff --git a/apps/studio/pages/project/[ref]/auth/policies.tsx b/apps/studio/pages/project/[ref]/auth/policies.tsx
index 79f83ea52aa..0dfeb58ef68 100644
--- a/apps/studio/pages/project/[ref]/auth/policies.tsx
+++ b/apps/studio/pages/project/[ref]/auth/policies.tsx
@@ -4,7 +4,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
import { Search, X } from 'lucide-react'
import { parseAsBoolean, parseAsString, useQueryState } from 'nuqs'
-import { useCallback, useDeferredValue, useEffect, useMemo, useState } from 'react'
+import { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
import { toast } from 'sonner'
import { Button } from 'ui'
import { Input } from 'ui-patterns/DataInputs/Input'
@@ -41,6 +41,7 @@ import { useBannerStack } from '@/components/ui/BannerStack/BannerStackProvider'
import { DocsButton } from '@/components/ui/DocsButton'
import { NoPermission } from '@/components/ui/NoPermission'
import { SchemaSelector } from '@/components/ui/SchemaSelector'
+import { Shortcut } from '@/components/ui/Shortcut'
import { useProjectPostgrestConfigQuery } from '@/data/config/project-postgrest-config-query'
import { useDatabasePoliciesQuery } from '@/data/database-policies/database-policies-query'
import { useTablesQuery } from '@/data/tables/tables-query'
@@ -49,7 +50,10 @@ import { useLocalStorageQuery } from '@/hooks/misc/useLocalStorage'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { useIsProtectedSchema } from '@/hooks/useProtectedSchemas'
import { DOCS_URL } from '@/lib/constants'
+import { onSearchInputEscape } from '@/lib/keyboard'
import { useEditorPanelStateSnapshot } from '@/state/editor-panel-state'
+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
+import { useShortcut } from '@/state/shortcuts/useShortcut'
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
import type { NextPageWithLayout } from '@/types'
@@ -131,6 +135,19 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
'new',
parseAsBoolean.withDefault(false).withOptions({ history: 'push', clearOnDefault: true })
)
+ const [schemaSelectorOpen, setSchemaSelectorOpen] = useState(false)
+ const searchInputRef = useRef<HTMLInputElement>(null)
+
+ useShortcut(
+ SHORTCUT_IDS.LIST_PAGE_FOCUS_SEARCH,
+ () => {
+ searchInputRef.current?.focus()
+ searchInputRef.current?.select()
+ },
+ { label: 'Search policies' }
+ )
+
+ useShortcut(SHORTCUT_IDS.LIST_PAGE_RESET_FILTERS, () => setSearchString(''))
const { isSchemaLocked } = useIsProtectedSchema({ schema: schema, excludedSchemas: ['realtime'] })
const { addBanner, dismissBanner } = useBannerStack()
@@ -293,18 +310,28 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
<PageSectionContent>
<div className="mb-4 flex flex-row gap-x-2">
- <SchemaSelector
- className="w-full lg:w-[180px]"
- size="tiny"
- align="end"
- showError={false}
- selectedSchemaName={schema}
- onSelectSchema={(schemaName) => {
- setSchema(schemaName)
- setSearchString('')
- }}
- />
+ <Shortcut
+ id={SHORTCUT_IDS.LIST_PAGE_FOCUS_SCHEMA}
+ onTrigger={() => setSchemaSelectorOpen(true)}
+ side="bottom"
+ tooltipOpen={schemaSelectorOpen ? false : undefined}
+ >
+ <SchemaSelector
+ className="w-full lg:w-[180px]"
+ size="tiny"
+ align="end"
+ showError={false}
+ selectedSchemaName={schema}
+ open={schemaSelectorOpen}
+ onOpenChange={setSchemaSelectorOpen}
+ onSelectSchema={(schemaName) => {
+ setSchema(schemaName)
+ setSearchString('')
+ }}
+ />
+ </Shortcut>
<Input
+ ref={searchInputRef}
size="tiny"
placeholder="Filter tables and policies"
className="block w-full lg:w-52"
@@ -314,6 +341,7 @@ const AuthPoliciesPage: NextPageWithLayout = () => {
const str = e.target.value
setSearchString(str)
}}
+ onKeyDown={onSearchInputEscape(searchString || '', setSearchString)}
icon={<Search size={14} />}
actions={
searchString ? (
diff --git a/apps/studio/state/shortcuts/referenceGroups.ts b/apps/studio/state/shortcuts/referenceGroups.ts
index 224fe209e15..82a6670c17e 100644
--- a/apps/studio/state/shortcuts/referenceGroups.ts
+++ b/apps/studio/state/shortcuts/referenceGroups.ts
@@ -1,11 +1,13 @@
export const SHORTCUT_REFERENCE_GROUPS = {
NAVIGATION_GLOBAL: 'navigation.global',
NAVIGATION_DATABASE: 'navigation.database',
+ NAVIGATION_AUTH: 'navigation.auth',
} as const
export const SHORTCUT_REFERENCE_GROUP_LABELS: Record<string, string> = {
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_GLOBAL]: 'Global Navigation',
[SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE]: 'Database Navigation',
+ [SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH]: 'Auth Navigation',
}
export const SHORTCUT_REFERENCE_GROUP_ORDER = [
@@ -13,6 +15,7 @@ export const SHORTCUT_REFERENCE_GROUP_ORDER = [
'shortcuts',
SHORTCUT_REFERENCE_GROUPS.NAVIGATION_GLOBAL,
SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
+ SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
'nav',
'ai-assistant',
'inline-editor',
diff --git a/apps/studio/state/shortcuts/registry.ts b/apps/studio/state/shortcuts/registry.ts
index 120eaf267c5..8fffb317ebc 100644
--- a/apps/studio/state/shortcuts/registry.ts
+++ b/apps/studio/state/shortcuts/registry.ts
@@ -1,4 +1,5 @@
import { SHORTCUT_REFERENCE_GROUPS } from './referenceGroups'
+import { AUTH_NAV_SHORTCUT_IDS, authNavRegistry } from './registry/auth-nav'
import { DATABASE_NAV_SHORTCUT_IDS, databaseNavRegistry } from './registry/database-nav'
import { LIST_PAGE_SHORTCUT_IDS, listPageRegistry } from './registry/list-page'
import {
@@ -69,6 +70,9 @@ export const SHORTCUT_IDS = {
// Database sub-page navigation chords
...DATABASE_NAV_SHORTCUT_IDS,
+
+ // Auth sub-page navigation chords
+ ...AUTH_NAV_SHORTCUT_IDS,
} as const
/**
@@ -348,4 +352,7 @@ export const SHORTCUT_DEFINITIONS: Record<ShortcutId, ShortcutDefinition> = {
// Database sub-page navigation chord registration
...databaseNavRegistry,
+
+ // Auth sub-page navigation chord registration
+ ...authNavRegistry,
}
diff --git a/apps/studio/state/shortcuts/registry/auth-nav.ts b/apps/studio/state/shortcuts/registry/auth-nav.ts
new file mode 100644
index 00000000000..4aae5898777
--- /dev/null
+++ b/apps/studio/state/shortcuts/registry/auth-nav.ts
@@ -0,0 +1,145 @@
+import { SHORTCUT_REFERENCE_GROUPS } from '../referenceGroups'
+import { RegistryDefinations } from '../types'
+
+/**
+ * Contextual chords for jumping between Authentication sub-pages — `A + <letter>`.
+ *
+ * Active only while AuthLayout is mounted (i.e. the user is somewhere under
+ * `/project/<ref>/auth/*`). Mirrors the database-nav pattern: the leading `A`
+ * is layout-scoped so it doesn't burn a global key.
+ */
+export const AUTH_NAV_SHORTCUT_IDS = {
+ NAV_AUTH_OVERVIEW: 'nav.auth-overview',
+ NAV_AUTH_USERS: 'nav.auth-users',
+ NAV_AUTH_OAUTH_APPS: 'nav.auth-oauth-apps',
+ NAV_AUTH_EMAIL: 'nav.auth-email',
+ NAV_AUTH_POLICIES: 'nav.auth-policies',
+ NAV_AUTH_SIGN_IN: 'nav.auth-sign-in',
+ NAV_AUTH_PASSKEYS: 'nav.auth-passkeys',
+ NAV_AUTH_OAUTH_SERVER: 'nav.auth-oauth-server',
+ NAV_AUTH_SESSIONS: 'nav.auth-sessions',
+ NAV_AUTH_RATE_LIMITS: 'nav.auth-rate-limits',
+ NAV_AUTH_MFA: 'nav.auth-mfa',
+ NAV_AUTH_URL_CONFIGURATION: 'nav.auth-url-configuration',
+ NAV_AUTH_PROTECTION: 'nav.auth-protection',
+ NAV_AUTH_HOOKS: 'nav.auth-hooks',
+ NAV_AUTH_AUDIT_LOGS: 'nav.auth-audit-logs',
+ NAV_AUTH_PERFORMANCE: 'nav.auth-performance',
+}
+
+export type AuthNavShortcutId = (typeof AUTH_NAV_SHORTCUT_IDS)[keyof typeof AUTH_NAV_SHORTCUT_IDS]
+
+export const authNavRegistry: RegistryDefinations<AuthNavShortcutId> = {
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OVERVIEW]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OVERVIEW,
+ label: 'Go to Overview',
+ sequence: ['A', 'O'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_USERS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_USERS,
+ label: 'Go to Users',
+ sequence: ['A', 'U'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OAUTH_APPS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OAUTH_APPS,
+ label: 'Go to OAuth Apps',
+ sequence: ['A', 'A'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_EMAIL]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_EMAIL,
+ label: 'Go to Email',
+ sequence: ['A', 'E'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_POLICIES]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_POLICIES,
+ label: 'Go to Policies',
+ sequence: ['A', 'P'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_SIGN_IN]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_SIGN_IN,
+ label: 'Go to Sign In / Providers',
+ sequence: ['A', 'I'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PASSKEYS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PASSKEYS,
+ label: 'Go to Passkeys',
+ sequence: ['A', 'K'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OAUTH_SERVER]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_OAUTH_SERVER,
+ label: 'Go to OAuth Server',
+ sequence: ['A', 'V'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_SESSIONS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_SESSIONS,
+ label: 'Go to Sessions',
+ sequence: ['A', 'S'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_RATE_LIMITS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_RATE_LIMITS,
+ label: 'Go to Rate Limits',
+ sequence: ['A', 'R'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_MFA]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_MFA,
+ label: 'Go to Multi-Factor',
+ sequence: ['A', 'M'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_URL_CONFIGURATION]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_URL_CONFIGURATION,
+ label: 'Go to URL Configuration',
+ sequence: ['A', 'L'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PROTECTION]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PROTECTION,
+ label: 'Go to Attack Protection',
+ sequence: ['A', 'T'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_HOOKS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_HOOKS,
+ label: 'Go to Auth Hooks',
+ sequence: ['A', 'H'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_AUDIT_LOGS]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_AUDIT_LOGS,
+ label: 'Go to Audit Logs',
+ sequence: ['A', 'G'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+ [AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PERFORMANCE]: {
+ id: AUTH_NAV_SHORTCUT_IDS.NAV_AUTH_PERFORMANCE,
+ label: 'Go to Performance',
+ sequence: ['A', 'F'],
+ showInSettings: false,
+ referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_AUTH,
+ },
+}