mirror of
https://github.com/supabase/supabase.git
synced 2026-09-09 11:30:17 +08:00
## Context Previous PR was [here](https://github.com/supabase/supabase/pull/45143) but it got stale with lots of conflicts so figured it'll be easier redo it off the latest master Moves policies page from Auth to Database under an Access Control section along with Roles. This moves all existing files, applies redirects, and updates urls to point to the new route <img width="274" height="412" alt="image" src="https://github.com/user-attachments/assets/7952c185-64ae-4355-ba36-45397efe1787" /> <img width="453" height="471" alt="image" src="https://github.com/user-attachments/assets/04b3dcb3-48a5-4049-9893-d01109fb46a9" /> ## To test - [ ] Verify that policies now live under Database correctly <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a quick navigation shortcut to open **Database > Policies (RLS)**. * **Bug Fixes** * Updated Policies and RLS-related links across the product to open the **Database policies** area (menus, command palette, context actions, alerts, and link-outs). * Added a permanent redirect from the old **auth policies** URL to the new **database policies** URL. * **Documentation** * Updated RLS Dashboard and security checklist instructions to reference **Database > Policies**. * **Tests** * Adjusted automated tests to validate the new Policies route. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
204 lines
5.8 KiB
TypeScript
204 lines
5.8 KiB
TypeScript
import { useParams } from 'common'
|
|
import { Blocks, Code, Database, History, Search } 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: () => <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-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: 'Replication',
|
|
value: 'Database: Replication',
|
|
route: `/project/${ref}/database/replication`,
|
|
defaultHidden: true,
|
|
} as IRouteCommand,
|
|
]
|
|
: []),
|
|
{
|
|
id: 'nav-database-backups',
|
|
name: 'Backups',
|
|
value: 'Database: Backups',
|
|
route: `/project/${ref}/database/backups/scheduled`,
|
|
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: () => <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 />,
|
|
},
|
|
{
|
|
id: 'run-view-database-policies',
|
|
name: 'View and create RLS policies',
|
|
route: `/project/${ref}/database/policies`,
|
|
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 },
|
|
}
|
|
)
|
|
}
|