mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
Stacked on #54186, which should merge first. It adds the section anchors the new results link to. ## What's added Search results in the command menu (⌘K) for every add-on on the add-ons page that didn't have one: | Result | Goes to | | --- | --- | | Infrastructure | Settings → Infrastructure | | Compute size | Infrastructure, `#compute` | | Read replicas | Infrastructure, `#read-replicas` (read replicas feature only) | | Advanced disk | Infrastructure, `#advanced` (AWS projects only) | | Dedicated IPv4 address | Add-ons, IPv4 panel open (IPv4 feature only) | | Point in time recovery | Database → Backups → PITR | | SMS multi-factor authentication | Auth → MFA, `#sms-mfa` | Also adds search keywords to the existing Custom domains, Log drains, Pipelines and MFA results, and fixes a typo in the MFA result's search value. ## How to test 1. Open a project and press ⌘K. 2. Search for each result above and check it lands on the right page and section, for example `read replica`, `iops`, `static ip`, `pitr`, `sms mfa`, `cpu`. 3. Try a keyword for an existing result, for example `cname` finds Custom domains and `etl` finds Pipelines. 4. On a non-AWS project, `advanced disk` shouldn't appear.
213 lines
6.2 KiB
TypeScript
213 lines
6.2 KiB
TypeScript
import { useParams } from 'common'
|
|
import { BlocksIcon, CodeIcon, DatabaseIcon, HistoryIcon, SearchIcon } from 'lucide-react'
|
|
import type { CommandOptions } from 'ui-patterns/CommandMenu'
|
|
import { useRegisterCommands } from 'ui-patterns/CommandMenu'
|
|
import { IRouteCommand } from 'ui-patterns/CommandMenu/internal/types'
|
|
|
|
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'
|
|
|
|
export function useDatabaseGotoCommands(options?: CommandOptions) {
|
|
let { ref } = useParams()
|
|
ref ||= '_'
|
|
|
|
const { databaseReplication, databaseRoles, integrationsWrappers } = useIsFeatureEnabled([
|
|
'database:replication',
|
|
'database:roles',
|
|
'integrations:wrappers',
|
|
])
|
|
|
|
useRegisterCommands(
|
|
COMMAND_MENU_SECTIONS.QUERY,
|
|
[
|
|
{
|
|
id: 'run-sql',
|
|
name: 'Run SQL',
|
|
route: `/project/${ref}/sql/new`,
|
|
icon: () => <CodeIcon />,
|
|
},
|
|
],
|
|
{
|
|
...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-policies',
|
|
name: 'Policies',
|
|
value: 'Database: Policies (RLS)',
|
|
route: `/project/${ref}/database/policies`,
|
|
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: 'Pipelines',
|
|
value: 'Database: Pipelines',
|
|
keywords: ['replication', 'etl', 'cdc', 'destinations'],
|
|
route: `/project/${ref}/database/pipelines`,
|
|
defaultHidden: true,
|
|
} as IRouteCommand,
|
|
]
|
|
: []),
|
|
{
|
|
id: 'nav-database-backups',
|
|
name: 'Backups',
|
|
value: 'Database: Backups',
|
|
route: `/project/${ref}/database/backups/scheduled`,
|
|
defaultHidden: true,
|
|
},
|
|
{
|
|
id: 'nav-database-pitr',
|
|
name: 'Point in time recovery',
|
|
value: 'Database: Point in time recovery',
|
|
keywords: ['pitr', 'point in time', 'restore', 'backup'],
|
|
route: `/project/${ref}/database/backups/pitr`,
|
|
defaultHidden: true,
|
|
},
|
|
...(integrationsWrappers
|
|
? [
|
|
{
|
|
id: 'nav-database-wrappers',
|
|
name: 'Wrappers',
|
|
value: 'Database: Wrappers',
|
|
route: `/project/${ref}/integrations?category=wrappers`,
|
|
defaultHidden: true,
|
|
} as IRouteCommand,
|
|
]
|
|
: []),
|
|
{
|
|
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: () => <SearchIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-functions',
|
|
name: 'View and create functions',
|
|
route: `/project/${ref}/database/functions`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-triggers',
|
|
name: 'View and create triggers',
|
|
route: `/project/${ref}/database/triggers`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-enumerated-types',
|
|
name: 'View and create enumerated types',
|
|
route: `/project/${ref}/database/types`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-extensions',
|
|
name: 'View your extensions',
|
|
route: `/project/${ref}/database/extensions`,
|
|
icon: () => <BlocksIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-indexes',
|
|
name: 'View and create indexes',
|
|
route: `/project/${ref}/database/indexes`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-policies',
|
|
name: 'View and create RLS policies',
|
|
route: `/project/${ref}/database/policies`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
...(databaseRoles
|
|
? [
|
|
{
|
|
id: 'run-view-database-roles',
|
|
name: 'View your roles',
|
|
route: `/project/${ref}/database/roles`,
|
|
icon: () => <DatabaseIcon />,
|
|
} as IRouteCommand,
|
|
]
|
|
: []),
|
|
{
|
|
id: 'run-view-database-backups',
|
|
name: 'View your backups',
|
|
route: `/project/${ref}/database/backups/scheduled`,
|
|
icon: () => <DatabaseIcon />,
|
|
},
|
|
{
|
|
id: 'run-view-database-migrations',
|
|
name: 'View your migrations',
|
|
route: `/project/${ref}/database/migrations`,
|
|
icon: () => <HistoryIcon />,
|
|
},
|
|
],
|
|
{
|
|
...options,
|
|
deps: [ref],
|
|
orderSection: orderCommandSectionsByPriority,
|
|
sectionMeta: { priority: 3 },
|
|
}
|
|
)
|
|
}
|