Files
supabase/apps/studio/state/shortcuts/registry/database-nav.ts
Joshen Lim 1de298ff31 Reinstate https://github.com/supabase/supabase/pull/45143 into latest master (#47433)
## 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 -->
2026-06-30 18:49:33 +08:00

141 lines
5.5 KiB
TypeScript

import { SHORTCUT_REFERENCE_GROUPS } from '../referenceGroups'
import { RegistryDefinations } from '../types'
/**
* Contextual chords for jumping between Database sub-pages — `D + <letter>`.
*
* Active only while DatabaseLayout is mounted (i.e. the user is somewhere
* under `/project/<ref>/database/*`). The chord intentionally lives on the
* page rather than globally so the leading `D` doesn't burn a global key for
* a destination most users only care about while already in the section.
*
*/
export const DATABASE_NAV_SHORTCUT_IDS = {
NAV_DATABASE_TABLES: 'nav.database-tables',
NAV_DATABASE_FUNCTIONS: 'nav.database-functions',
NAV_DATABASE_TRIGGERS: 'nav.database-triggers',
NAV_DATABASE_INDEXES: 'nav.database-indexes',
NAV_DATABASE_EXTENSIONS: 'nav.database-extensions',
NAV_DATABASE_SCHEMA_VISUALIZER: 'nav.database-schema-visualizer',
NAV_DATABASE_ROLES: 'nav.database-roles',
NAV_DATABASE_BACKUPS: 'nav.database-backups',
NAV_DATABASE_MIGRATIONS: 'nav.database-migrations',
NAV_DATABASE_TYPES: 'nav.database-types',
NAV_DATABASE_PUBLICATIONS: 'nav.database-publications',
NAV_DATABASE_COLUMN_PRIVILEGES: 'nav.database-column-privileges',
NAV_DATABASE_SETTINGS: 'nav.database-settings',
NAV_DATABASE_REPLICATION: 'nav.database-replication',
NAV_DATABASE_POLICIES: 'nav.database-policies',
}
export type DatabaseNavShortcutId =
(typeof DATABASE_NAV_SHORTCUT_IDS)[keyof typeof DATABASE_NAV_SHORTCUT_IDS]
export const databaseNavRegistry: RegistryDefinations<DatabaseNavShortcutId> = {
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TABLES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TABLES,
label: 'Go to Tables',
sequence: ['D', 'T'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_FUNCTIONS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_FUNCTIONS,
label: 'Go to Functions',
sequence: ['D', 'F'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TRIGGERS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TRIGGERS,
label: 'Go to Triggers',
sequence: ['D', 'R'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_INDEXES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_INDEXES,
label: 'Go to Indexes',
sequence: ['D', 'I'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_EXTENSIONS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_EXTENSIONS,
label: 'Go to Extensions',
sequence: ['D', 'X'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_SCHEMA_VISUALIZER]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_SCHEMA_VISUALIZER,
label: 'Go to Schema Visualizer',
sequence: ['D', 'V'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_ROLES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_ROLES,
label: 'Go to Roles',
sequence: ['D', 'O'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_BACKUPS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_BACKUPS,
label: 'Go to Backups',
sequence: ['D', 'B'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_MIGRATIONS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_MIGRATIONS,
label: 'Go to Migrations',
sequence: ['D', 'M'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TYPES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_TYPES,
label: 'Go to Enumerated Types',
sequence: ['D', 'E'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_PUBLICATIONS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_PUBLICATIONS,
label: 'Go to Publications',
sequence: ['D', 'U'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_COLUMN_PRIVILEGES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_COLUMN_PRIVILEGES,
label: 'Go to Column Privileges',
sequence: ['D', 'C'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_SETTINGS]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_SETTINGS,
label: 'Go to Database Settings',
sequence: ['D', ','],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_REPLICATION]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_REPLICATION,
label: 'Go to Replication',
sequence: ['D', 'L'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
[DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_POLICIES]: {
id: DATABASE_NAV_SHORTCUT_IDS.NAV_DATABASE_POLICIES,
label: 'Go to Policies',
sequence: ['D', 'A'],
showInSettings: false,
referenceGroup: SHORTCUT_REFERENCE_GROUPS.NAVIGATION_DATABASE,
},
}