mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 18:30:12 -04:00
f32977f04d
## What kind of change does this PR introduce? UI chore. ## What is the current behavior? The Keyboard shortcuts sheet renders shortcut definitions from the static registry, so contextual Database navigation shortcuts appear in the sheet even when `DatabaseLayout` is not active. This makes the Navigation section noisy as more product-specific navigation shortcuts are added. ## What is the new behavior? The shortcuts sheet now reads the mounted, enabled shortcut set at runtime. Global navigation remains under Navigation when it is the only navigation scope, and splits into _**Global** Navigation_ plus _**Database** Navigation_ when contextual database shortcuts are active. This also replaces the one-off `DatabaseNavShortcuts` component with a reusable `ProductMenuShortcuts` registrar so future product layouts can register scoped navigation shortcuts from their product menu model. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added keyboard shortcut support for product menu navigation items with router integration * **Improvements** * Keyboard shortcuts are now organized into logical groups (Global Navigation and Database Navigation) * Shortcut reference dynamically displays only active shortcuts instead of static definitions <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ali Waseem <waseema393@gmail.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { useRouter } from 'next/router'
|
|
import type { PropsWithChildren } from 'react'
|
|
|
|
import { ProjectLayout } from '../ProjectLayout'
|
|
import { useGenerateDatabaseMenu } from './DatabaseMenu.utils'
|
|
import { ProductMenu } from '@/components/ui/ProductMenu'
|
|
import { ProductMenuShortcuts } from '@/components/ui/ProductMenu/ProductMenuShortcuts'
|
|
import { withAuth } from '@/hooks/misc/withAuth'
|
|
|
|
export interface DatabaseLayoutProps {
|
|
title: string
|
|
}
|
|
|
|
export const DatabaseProductMenu = () => {
|
|
const router = useRouter()
|
|
const page = router.pathname.split('/')[4]
|
|
const menu = useGenerateDatabaseMenu()
|
|
|
|
return <ProductMenu page={page} menu={menu} />
|
|
}
|
|
|
|
const DatabaseLayout = ({ children, title }: PropsWithChildren<DatabaseLayoutProps>) => {
|
|
const router = useRouter()
|
|
const page = router.pathname.split('/')[4]
|
|
const menu = useGenerateDatabaseMenu()
|
|
|
|
return (
|
|
<ProjectLayout
|
|
product="Database"
|
|
browserTitle={{ section: title }}
|
|
productMenu={<ProductMenu page={page} menu={menu} />}
|
|
isBlocking={false}
|
|
>
|
|
<ProductMenuShortcuts menu={menu} />
|
|
{children}
|
|
</ProjectLayout>
|
|
)
|
|
}
|
|
|
|
export default withAuth(DatabaseLayout)
|