Files
supabase/apps/studio/components/layouts/DatabaseLayout/Database.Commands.tsx
T
Joshen Lim 7b1ac2a66e Chore/disable more sections 04 (#38064)
* Add flags for policies, third party auth, and manual linking + providers in sign in page

* Add flag for rate limitm page

* Add UnknownInterface components

* Update comment

* Flip flags to true

* Add flags for realtime policies and reports page

* Temp

* Add flag for sign in providers page

* Add flag for stripe wrapper

* Add flag for custom domains

* Add flag for dedicated ipv4 address addon

* Add empty state for realtime policies

* Add empty state for reports page

* Add flag for disable legacy JWT keys section

* Add flag for legacy jwt keys

* nit

* Remove ConnectionStringMoved call out

* Add flag for project settings log drains

* Add flag for subscription link in project settings

* Deprecate settings/auth page and redirect directly to auth page

* Flip back flags

* Add flags for account preferences analytics marketing and account deleetion

* Remove 'table_editor:enable_rls_toggle' flag and revert UI changes

* Remove 'authentication:policies' flag and revert UI changes

* Add flags for cmd K routes

* Add flags for instance size in infra settings

* Small refactor to DisplayApiSettings, decouple ToggleLegacyApiKeysPanel from it

* Have project_connection:javascript_example toggle code example title to TS

* add flag for templates dropdown in logs explorer

* UsesOverview only show link to providers page if providers is enabled

* API Docs UserManagement to only include docs on third party auth if providers is enabled

* Hide instance size on project card if flag is off

* Fix cmd k for roles, update redirect link from settings/auth to auth/providers
2025-08-22 16:17:43 +08:00

193 lines
5.4 KiB
TypeScript

import { Blocks, Code, Database, History, Search } from 'lucide-react'
import { useParams } from 'common'
import { COMMAND_MENU_SECTIONS } from 'components/interfaces/App/CommandMenu/CommandMenu.utils'
import { orderCommandSectionsByPriority } from 'components/interfaces/App/CommandMenu/ordering'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import type { CommandOptions } from 'ui-patterns/CommandMenu'
import { useRegisterCommands } from 'ui-patterns/CommandMenu'
import { IRouteCommand } from 'ui-patterns/CommandMenu/internal/types'
export function useDatabaseGotoCommands(options?: CommandOptions) {
let { ref } = useParams()
ref ||= '_'
const { databaseReplication, databaseRoles } = useIsFeatureEnabled([
'database:replication',
'database:roles',
])
useRegisterCommands(
COMMAND_MENU_SECTIONS.QUERY,
[
{
id: 'run-sql',
name: 'Run SQL',
route: `/project/${ref}/sql/new`,
icon: () => <Code />,
},
],
{
...options,
deps: [ref],
orderSection: orderCommandSectionsByPriority,
sectionMeta: { priority: 2 },
}
)
useRegisterCommands(
COMMAND_MENU_SECTIONS.NAVIGATE,
[
{
id: 'nav-database-tables',
name: 'Tables',
value: 'Database: Tables',
route: `/project/${ref}/database/tables`,
defaultHidden: true,
},
{
id: 'nav-database-triggers',
name: 'Triggers',
value: 'Database: Triggers',
route: `/project/${ref}/database/triggers`,
defaultHidden: true,
},
{
id: 'nav-database-functions',
name: 'Functions',
value: 'Database: Functions',
route: `/project/${ref}/database/functions`,
defaultHidden: true,
},
{
id: 'nav-database-extensions',
name: 'Extensions',
value: 'Database: Extensions',
route: `/project/${ref}/database/extensions`,
defaultHidden: true,
},
...(databaseRoles
? [
{
id: 'nav-database-roles',
name: 'Roles',
value: 'Database: Roles',
route: `/project/${ref}/database/roles`,
defaultHidden: true,
} as IRouteCommand,
]
: []),
...(databaseReplication
? [
{
id: 'nav-database-replication',
name: 'Replication',
value: 'Database: Replication',
route: `/project/${ref}/database/replication`,
defaultHidden: true,
} as IRouteCommand,
]
: []),
{
id: 'nav-database-hooks',
name: 'Webhooks',
value: 'Database: Webhooks',
route: `/project/${ref}/integrations/hooks`,
defaultHidden: true,
},
{
id: 'nav-database-backups',
name: 'Backups',
value: 'Database: Backups',
route: `/project/${ref}/database/backups/scheduled`,
defaultHidden: true,
},
{
id: 'nav-database-wrappers',
name: 'Wrappers',
value: 'Database: Wrappers',
route: `/project/${ref}/integrations/wrappers`,
defaultHidden: true,
},
{
id: 'nav-database-migrations',
name: 'Migrations',
value: 'Database: Migrations',
route: `/project/${ref}/database/migrations`,
defaultHidden: true,
},
],
{ ...options, deps: [ref] }
)
useRegisterCommands(
COMMAND_MENU_SECTIONS.DATABASE,
[
{
id: 'run-schema-visualizer',
name: 'View your schemas',
route: `/project/${ref}/database/schemas`,
icon: () => <Search />,
},
{
id: 'run-view-database-functions',
name: 'View and create functions',
route: `/project/${ref}/database/functions`,
icon: () => <Database />,
},
{
id: 'run-view-database-triggers',
name: 'View and create triggers',
route: `/project/${ref}/database/triggers`,
icon: () => <Database />,
},
{
id: 'run-view-database-enumerated-types',
name: 'View and create enumerated types',
route: `/project/${ref}/database/types`,
icon: () => <Database />,
},
{
id: 'run-view-database-extensions',
name: 'View your extensions',
route: `/project/${ref}/database/extensions`,
icon: () => <Blocks />,
},
{
id: 'run-view-database-indexes',
name: 'View and create indexes',
route: `/project/${ref}/database/indexes`,
icon: () => <Database />,
},
...(databaseRoles
? [
{
id: 'run-view-database-roles',
name: 'View your roles',
route: `/project/${ref}/database/roles`,
icon: () => <Database />,
} as IRouteCommand,
]
: []),
{
id: 'run-view-database-backups',
name: 'View your backups',
route: `/project/${ref}/database/backups/scheduled`,
icon: () => <Database />,
},
{
id: 'run-view-database-migrations',
name: 'View your migrations',
route: `/project/${ref}/database/migrations`,
icon: () => <History />,
},
],
{
...options,
deps: [ref],
orderSection: orderCommandSectionsByPriority,
sectionMeta: { priority: 3 },
}
)
}