The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(studio): add keyboard shortcuts to the schema visualizer (#45386)
Ali Waseeme6f779ea3014
diff --git a/apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx b/apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsxindex 5e1e0710da6..3ea45e0170b 100644--- a/apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx+++ b/apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx@@ -15,6 +15,7 @@ import { Check, ChevronDown, Copy, Download, Loader2, Plus } from 'lucide-react'import { useTheme } from 'next-themes'import Link from 'next/link'import { useEffect, useMemo, useRef, useState } from 'react'+import { toast } from 'sonner'import '@xyflow/react/dist/style.css'@@ -53,6 +54,7 @@ import { useExportSchemaToImage } from './useExportSchemaToImage'import AlertError from '@/components/ui/AlertError'import { ButtonTooltip } from '@/components/ui/ButtonTooltip'import SchemaSelector from '@/components/ui/SchemaSelector'+import { Shortcut } from '@/components/ui/Shortcut'import { useSchemasQuery } from '@/data/database/schemas-query'import { useTablesQuery } from '@/data/tables/tables-query'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'@@ -62,6 +64,8 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'import { useIsProtectedSchema } from '@/hooks/useProtectedSchemas'import { useStaticEffectEvent } from '@/hooks/useStaticEffectEvent'import { tablesToSQL } from '@/lib/helpers'+import { SHORTCUT_IDS } from '@/state/shortcuts/registry'+import { useShortcut } from '@/state/shortcuts/useShortcut'import { useTableEditorStateSnapshot } from '@/state/table-editor'// [Joshen] Persisting logic: Only save positions to local storage WHEN a node is moved OR when explicitly clicked to reset layout@@ -201,6 +205,39 @@ export const SchemaGraph = () => {exportSchemaToImage({ element: reactflowViewport, format, x, y, zoom, projectRef: ref })}+ const copyAsSQL = () => {+ if (!tables) return+ copyToClipboard(tablesToSQL(tables))+ setCopied(true)+ toast.success('Successfully copied as SQL')+ }++ const copyAsMarkdown = () => {+ const tableNodes = reactFlowInstance+ .getNodes()+ .filter((node) => node.type === 'table')+ .map((node) => node.data as TableNodeData)+ copyToClipboard(getSchemaAsMarkdown(selectedSchema, tableNodes))+ setCopied(true)+ toast.success('Successfully copied as Markdown')+ }++ const [schemaSelectorOpen, setSchemaSelectorOpen] = useState(false)+ const [autoLayoutDialogOpen, setAutoLayoutDialogOpen] = useState(false)++ const shortcutsEnabled = isSuccessSchemas && !hasNoTables++ useShortcut(SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_SQL, copyAsSQL, { enabled: shortcutsEnabled })+ useShortcut(SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_MARKDOWN, copyAsMarkdown, {+ enabled: shortcutsEnabled,+ })+ useShortcut(SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_PNG, () => downloadImage('png'), {+ enabled: shortcutsEnabled,+ })+ useShortcut(SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_SVG, () => downloadImage('svg'), {+ enabled: shortcutsEnabled,+ })+const isFirstLoad = useRef(true)useEffect(() => {if (isSuccessTables && isSuccessSchemas && tables.length > 0) {@@ -262,13 +299,23 @@ export const SchemaGraph = () => {{isSuccessSchemas && (<>- <SchemaSelector- className="w-[180px]"- size="tiny"- showError={false}- selectedSchemaName={selectedSchema}- onSelectSchema={setSelectedSchema}- />+ <Shortcut+ id={SHORTCUT_IDS.SCHEMA_VISUALIZER_FOCUS_SCHEMA}+ onTrigger={() => setSchemaSelectorOpen(true)}+ options={{ enabled: isSuccessSchemas }}+ side="bottom"+ tooltipOpen={schemaSelectorOpen ? false : undefined}+ >+ <SchemaSelector+ className="w-[180px]"+ size="tiny"+ showError={false}+ selectedSchemaName={selectedSchema}+ onSelectSchema={setSelectedSchema}+ open={schemaSelectorOpen}+ onOpenChange={setSchemaSelectorOpen}+ />+ </Shortcut>{!hasNoTables && (<div className="flex items-center gap-x-2"><div className="flex items-center gap-0">@@ -276,12 +323,7 @@ export const SchemaGraph = () => {type="default"className="rounded-r-none border-r-0"icon={copied ? <Check data-testid="copy-sql-ready" /> : <Copy />}- onClick={() => {- if (tables) {- copyToClipboard(tablesToSQL(tables))- setCopied(true)- }- }}+ onClick={copyAsSQL}tooltip={{content: {side: 'bottom',@@ -315,13 +357,7 @@ export const SchemaGraph = () => {className="flex items-center space-x-2 whitespace-nowrap"onClick={(e) => {e.stopPropagation()- const tables = reactFlowInstance- .getNodes()- .filter((node) => node.type === 'table')- .map((node) => node.data as TableNodeData)-- copyToClipboard(getSchemaAsMarkdown(selectedSchema, tables))- setCopied(true)+ copyAsMarkdown()}}><Copy size={12} />@@ -350,20 +386,18 @@ export const SchemaGraph = () => {</DropdownMenuContent></DropdownMenu></div>- <AlertDialog>- <AlertDialogTrigger asChild>- <ButtonTooltip- type="default"- tooltip={{- content: {- side: 'bottom',- text: 'Automatically arrange the layout of all nodes',- },- }}- >- Auto layout- </ButtonTooltip>- </AlertDialogTrigger>+ <AlertDialog open={autoLayoutDialogOpen} onOpenChange={setAutoLayoutDialogOpen}>+ <Shortcut+ id={SHORTCUT_IDS.SCHEMA_VISUALIZER_AUTO_LAYOUT}+ onTrigger={() => setAutoLayoutDialogOpen(true)}+ options={{ enabled: shortcutsEnabled }}+ side="bottom"+ tooltipOpen={autoLayoutDialogOpen ? false : undefined}+ >+ <AlertDialogTrigger asChild>+ <Button type="default">Auto layout</Button>+ </AlertDialogTrigger>+ </Shortcut><AlertDialogContent><AlertDialogHeader><AlertDialogTitle>Confirm to rearrange all nodes</AlertDialogTitle>diff --git a/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsx b/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsxindex 9eadf66acb2..17594eda447 100644--- a/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsx+++ b/apps/studio/components/ui/GlobalShortcuts/ShortcutsReferenceSheet.tsx@@ -36,6 +36,7 @@ const GROUP_LABELS: Record<string, string> = {nav: 'Navigation','operation-queue': 'Operation Queue',results: 'Results',+ 'schema-visualizer': 'Schema Visualizer',shortcuts: 'Shortcuts','table-editor': 'Table Editor','unified-logs': 'Logs',@@ -50,6 +51,7 @@ const GROUP_ORDER = ['results','data-table','table-editor',+ 'schema-visualizer','action-bar','operation-queue','unified-logs',diff --git a/apps/studio/components/ui/SchemaSelector.tsx b/apps/studio/components/ui/SchemaSelector.tsxindex 958810a2578..150603b400d 100644--- a/apps/studio/components/ui/SchemaSelector.tsx+++ b/apps/studio/components/ui/SchemaSelector.tsx@@ -1,6 +1,6 @@import { PermissionAction } from '@supabase/shared-types/out/constants'import { Check, ChevronsUpDown, Plus } from 'lucide-react'-import { useState } from 'react'+import { ComponentPropsWithoutRef, forwardRef, useState } from 'react'import {Alert_Shadcn_,AlertDescription_Shadcn_,@@ -24,8 +24,7 @@ import { useSchemasQuery } from '@/data/database/schemas-query'import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'-interface SchemaSelectorProps {- className?: string+type SchemaSelectorProps = Omit<ComponentPropsWithoutRef<'div'>, 'onSelect'> & {disabled?: booleansize?: 'tiny' | 'small'showError?: boolean@@ -37,182 +36,200 @@ interface SchemaSelectorProps {onSelectSchema: (name: string) => voidonSelectCreateSchema?: () => voidalign?: 'start' | 'end'+ open?: boolean+ onOpenChange?: (open: boolean) => void}-export const SchemaSelector = ({- className,- disabled = false,- size = 'tiny',- showError = true,- selectedSchemaName,- placeholderLabel = 'Choose a schema...',- supportSelectAll = false,- excludedSchemas = [],- stopScrollPropagation = false,- onSelectSchema,- onSelectCreateSchema,- align = 'start',-}: SchemaSelectorProps) => {- const [open, setOpen] = useState(false)- const { can: canCreateSchemas } = useAsyncCheckPermissions(- PermissionAction.TENANT_SQL_ADMIN_WRITE,- 'schemas'- )+export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(+ (+ {+ className,+ disabled = false,+ size = 'tiny',+ showError = true,+ selectedSchemaName,+ placeholderLabel = 'Choose a schema...',+ supportSelectAll = false,+ excludedSchemas = [],+ stopScrollPropagation = false,+ onSelectSchema,+ onSelectCreateSchema,+ align = 'start',+ open: openProp,+ onOpenChange,+ ...rest+ },+ ref+ ) => {+ const [internalOpen, setInternalOpen] = useState(false)+ const isControlled = openProp !== undefined+ const open = isControlled ? openProp : internalOpen+ const setOpen = (next: boolean) => {+ if (!isControlled) setInternalOpen(next)+ onOpenChange?.(next)+ }+ const { can: canCreateSchemas } = useAsyncCheckPermissions(+ PermissionAction.TENANT_SQL_ADMIN_WRITE,+ 'schemas'+ )- const { data: project } = useSelectedProjectQuery()- const {- data,- isPending: isSchemasLoading,- isSuccess: isSchemasSuccess,- isError: isSchemasError,- error: schemasError,- refetch: refetchSchemas,- } = useSchemasQuery({- projectRef: project?.ref,- connectionString: project?.connectionString,- })+ const { data: project } = useSelectedProjectQuery()+ const {+ data,+ isPending: isSchemasLoading,+ isSuccess: isSchemasSuccess,+ isError: isSchemasError,+ error: schemasError,+ refetch: refetchSchemas,+ } = useSchemasQuery({+ projectRef: project?.ref,+ connectionString: project?.connectionString,+ })- const schemas = (data || [])- .filter((schema) => !excludedSchemas.includes(schema.name))- .sort((a, b) => a.name.localeCompare(b.name))+ const schemas = (data || [])+ .filter((schema) => !excludedSchemas.includes(schema.name))+ .sort((a, b) => a.name.localeCompare(b.name))- return (- <div className={className}>- {isSchemasLoading && (- <Button- type="default"- key="schema-selector-skeleton"- className="w-full [&>span]:w-full"- size={size}- disabled- >- <Skeleton className="w-full h-3 bg-foreground-muted" />- </Button>- )}-- {showError && isSchemasError && (- <Alert_Shadcn_ variant="warning" className="px-3! py-3!">- <AlertTitle_Shadcn_ className="text-xs text-amber-900">- Failed to load schemas- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_ className="text-xs mb-2 wrap-break-word">- Error: {(schemasError as any)?.message}- </AlertDescription_Shadcn_>- <Button type="default" size="tiny" onClick={() => refetchSchemas()}>- Reload schemas+ return (+ <div ref={ref} className={className} {...rest}>+ {isSchemasLoading && (+ <Button+ type="default"+ key="schema-selector-skeleton"+ className="w-full [&>span]:w-full"+ size={size}+ disabled+ >+ <Skeleton className="w-full h-3 bg-foreground-muted" /></Button>- </Alert_Shadcn_>- )}+ )}- {isSchemasSuccess && (- <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>- <PopoverTrigger_Shadcn_ asChild>- <Button- size={size}- disabled={disabled}- type="default"- data-testid="schema-selector"- className={`w-full [&>span]:w-full pr-1! space-x-1`}- iconRight={- <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />- }- >- {selectedSchemaName ? (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">schema</p>- <p className="text-foreground">- {selectedSchemaName === '*' ? 'All schemas' : selectedSchemaName}- </p>- </div>- ) : (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">{placeholderLabel}</p>- </div>- )}+ {showError && isSchemasError && (+ <Alert_Shadcn_ variant="warning" className="px-3! py-3!">+ <AlertTitle_Shadcn_ className="text-xs text-amber-900">+ Failed to load schemas+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_ className="text-xs mb-2 wrap-break-word">+ Error: {(schemasError as any)?.message}+ </AlertDescription_Shadcn_>+ <Button type="default" size="tiny" onClick={() => refetchSchemas()}>+ Reload schemas</Button>- </PopoverTrigger_Shadcn_>- <PopoverContent_Shadcn_- className="p-0 min-w-[200px] pointer-events-auto"- side="bottom"- align={align}- sameWidthAsTrigger- >- <Command_Shadcn_>- <CommandInput_Shadcn_ className="text-xs" placeholder="Find schema..." />- <CommandList_Shadcn_- onWheel={stopScrollPropagation ? (event) => event.stopPropagation() : undefined}+ </Alert_Shadcn_>+ )}++ {isSchemasSuccess && (+ <Popover_Shadcn_ open={open} onOpenChange={setOpen} modal={false}>+ <PopoverTrigger_Shadcn_ asChild>+ <Button+ size={size}+ disabled={disabled}+ type="default"+ data-testid="schema-selector"+ className={`w-full [&>span]:w-full pr-1! space-x-1`}+ iconRight={+ <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />+ }>- <CommandEmpty_Shadcn_>No schemas found</CommandEmpty_Shadcn_>- <CommandGroup_Shadcn_>- <ScrollArea className={(schemas || []).length > 7 ? 'h-[210px]' : ''}>- {supportSelectAll && (- <CommandItem_Shadcn_- key="select-all"- className="cursor-pointer flex items-center justify-between space-x-2 w-full"- onSelect={() => {- onSelectSchema('*')- setOpen(false)- }}- onClick={() => {- onSelectSchema('*')- setOpen(false)- }}- >- <span>All schemas</span>- {selectedSchemaName === '*' && (- <Check className="text-brand" strokeWidth={2} size={16} />- )}- </CommandItem_Shadcn_>- )}- {schemas.map((schema) => (- <CommandItem_Shadcn_- key={schema.id}- className="cursor-pointer flex items-center justify-between space-x-2 w-full"- onSelect={() => {- onSelectSchema(schema.name)- setOpen(false)- }}- onClick={() => {- onSelectSchema(schema.name)- setOpen(false)- }}- >- <span>{schema.name}</span>- {selectedSchemaName === schema.name && (- <Check className="text-brand" strokeWidth={2} size={16} />- )}- </CommandItem_Shadcn_>- ))}- </ScrollArea>- </CommandGroup_Shadcn_>- {onSelectCreateSchema !== undefined && canCreateSchemas && (- <>- <CommandSeparator_Shadcn_ />- <CommandGroup_Shadcn_>- <CommandItem_Shadcn_- className="cursor-pointer flex items-center gap-x-2 w-full"- onSelect={() => {- onSelectCreateSchema()- setOpen(false)- }}- onClick={() => {- onSelectCreateSchema()- setOpen(false)- }}- >- <Plus size={12} />- Create a new schema- </CommandItem_Shadcn_>- </CommandGroup_Shadcn_>- </>+ {selectedSchemaName ? (+ <div className="w-full flex gap-1">+ <p className="text-foreground-lighter">schema</p>+ <p className="text-foreground">+ {selectedSchemaName === '*' ? 'All schemas' : selectedSchemaName}+ </p>+ </div>+ ) : (+ <div className="w-full flex gap-1">+ <p className="text-foreground-lighter">{placeholderLabel}</p>+ </div>)}- </CommandList_Shadcn_>- </Command_Shadcn_>- </PopoverContent_Shadcn_>- </Popover_Shadcn_>- )}- </div>- )-}+ </Button>+ </PopoverTrigger_Shadcn_>+ <PopoverContent_Shadcn_+ className="p-0 min-w-[200px] pointer-events-auto"+ side="bottom"+ align={align}+ sameWidthAsTrigger+ >+ <Command_Shadcn_>+ <CommandInput_Shadcn_ className="text-xs" placeholder="Find schema..." />+ <CommandList_Shadcn_+ onWheel={stopScrollPropagation ? (event) => event.stopPropagation() : undefined}+ >+ <CommandEmpty_Shadcn_>No schemas found</CommandEmpty_Shadcn_>+ <CommandGroup_Shadcn_>+ <ScrollArea className={(schemas || []).length > 7 ? 'h-[210px]' : ''}>+ {supportSelectAll && (+ <CommandItem_Shadcn_+ key="select-all"+ className="cursor-pointer flex items-center justify-between space-x-2 w-full"+ onSelect={() => {+ onSelectSchema('*')+ setOpen(false)+ }}+ onClick={() => {+ onSelectSchema('*')+ setOpen(false)+ }}+ >+ <span>All schemas</span>+ {selectedSchemaName === '*' && (+ <Check className="text-brand" strokeWidth={2} size={16} />+ )}+ </CommandItem_Shadcn_>+ )}+ {schemas.map((schema) => (+ <CommandItem_Shadcn_+ key={schema.id}+ className="cursor-pointer flex items-center justify-between space-x-2 w-full"+ onSelect={() => {+ onSelectSchema(schema.name)+ setOpen(false)+ }}+ onClick={() => {+ onSelectSchema(schema.name)+ setOpen(false)+ }}+ >+ <span>{schema.name}</span>+ {selectedSchemaName === schema.name && (+ <Check className="text-brand" strokeWidth={2} size={16} />+ )}+ </CommandItem_Shadcn_>+ ))}+ </ScrollArea>+ </CommandGroup_Shadcn_>+ {onSelectCreateSchema !== undefined && canCreateSchemas && (+ <>+ <CommandSeparator_Shadcn_ />+ <CommandGroup_Shadcn_>+ <CommandItem_Shadcn_+ className="cursor-pointer flex items-center gap-x-2 w-full"+ onSelect={() => {+ onSelectCreateSchema()+ setOpen(false)+ }}+ onClick={() => {+ onSelectCreateSchema()+ setOpen(false)+ }}+ >+ <Plus size={12} />+ Create a new schema+ </CommandItem_Shadcn_>+ </CommandGroup_Shadcn_>+ </>+ )}+ </CommandList_Shadcn_>+ </Command_Shadcn_>+ </PopoverContent_Shadcn_>+ </Popover_Shadcn_>+ )}+ </div>+ )+ }+)++SchemaSelector.displayName = 'SchemaSelector'export default SchemaSelectordiff --git a/apps/studio/components/ui/Shortcut.tsx b/apps/studio/components/ui/Shortcut.tsxindex 62d4ce2853e..d75439361d0 100644--- a/apps/studio/components/ui/Shortcut.tsx+++ b/apps/studio/components/ui/Shortcut.tsx@@ -24,6 +24,12 @@ interface ShortcutProps {* action is a narrower/contextual variant of the registered shortcut.*/label?: string+ /**+ * Controlled open state for the tooltip. Pass `false` to force the tooltip+ * closed (e.g. while a popover or dialog opened by the wrapped element is+ * visible). Leave `undefined` for default uncontrolled behavior.+ */+ tooltipOpen?: boolean}/**@@ -59,6 +65,7 @@ export const Shortcut = ({sideOffset,delayDuration,label,+ tooltipOpen,}: ShortcutProps) => {useShortcut(id, onTrigger, options)@@ -70,6 +77,7 @@ export const Shortcut = ({sideOffset={sideOffset}delayDuration={delayDuration}label={label}+ open={tooltipOpen}>{children}</ShortcutTooltip>diff --git a/apps/studio/components/ui/ShortcutTooltip.tsx b/apps/studio/components/ui/ShortcutTooltip.tsxindex 13bd66072d6..202c9dec5e9 100644--- a/apps/studio/components/ui/ShortcutTooltip.tsx+++ b/apps/studio/components/ui/ShortcutTooltip.tsx@@ -17,6 +17,12 @@ interface ShortcutTooltipProps {* action is a narrower/contextual variant of the registered shortcut.*/label?: string+ /**+ * Controlled open state for the tooltip. Pass `false` to force the tooltip+ * closed (e.g. while a popover or dialog opened by the wrapped element is+ * visible). Leave `undefined` for default uncontrolled behavior.+ */+ open?: boolean}/**@@ -39,12 +45,13 @@ export const ShortcutTooltip = ({sideOffset,delayDuration,label: labelOverride,+ open,}: ShortcutTooltipProps) => {const def = SHORTCUT_DEFINITIONS[shortcutId]const label = labelOverride ?? def.labelreturn (- <Tooltip delayDuration={delayDuration}>+ <Tooltip delayDuration={delayDuration} open={open}><TooltipTrigger asChild>{children}</TooltipTrigger><TooltipContentside={side}diff --git a/apps/studio/state/shortcuts/registry.ts b/apps/studio/state/shortcuts/registry.tsindex 8bd41f8f968..ca6a19266a5 100644--- a/apps/studio/state/shortcuts/registry.ts+++ b/apps/studio/state/shortcuts/registry.ts@@ -1,3 +1,7 @@+import {+ SCHEMA_VISUALIZER_SHORTCUT_IDS,+ schemaVisualizerRegistry,+} from './registry/schema-visualizer'import { SQL_EDITOR_SHORTCUT_IDS, sqlEditorRegistry } from './registry/sql-editor'import { TABLE_EDITOR_SHORTCUT_IDS, tableEditorRegistry } from './registry/table-editor'import { ShortcutDefinition } from './types'@@ -53,6 +57,9 @@ export const SHORTCUT_IDS = {// SQL editor shortcuts...SQL_EDITOR_SHORTCUT_IDS,++ // Schema visualizer shortcuts+ ...SCHEMA_VISUALIZER_SHORTCUT_IDS,} as const/**@@ -304,4 +311,7 @@ export const SHORTCUT_DEFINITIONS: Record<ShortcutId, ShortcutDefinition> = {// SQL editor shortcut registration...sqlEditorRegistry,++ // Schema visualizer shortcut registration+ ...schemaVisualizerRegistry,}diff --git a/apps/studio/state/shortcuts/registry/schema-visualizer.ts b/apps/studio/state/shortcuts/registry/schema-visualizer.tsnew file mode 100644index 00000000000..80b8e5d40a0--- /dev/null+++ b/apps/studio/state/shortcuts/registry/schema-visualizer.ts@@ -0,0 +1,58 @@+import { RegistryDefinations } from '../types'++export const SCHEMA_VISUALIZER_SHORTCUT_IDS = {+ SCHEMA_VISUALIZER_COPY_SQL: 'schema-visualizer.copy-sql',+ SCHEMA_VISUALIZER_COPY_MARKDOWN: 'schema-visualizer.copy-markdown',+ SCHEMA_VISUALIZER_DOWNLOAD_PNG: 'schema-visualizer.download-png',+ SCHEMA_VISUALIZER_DOWNLOAD_SVG: 'schema-visualizer.download-svg',+ SCHEMA_VISUALIZER_AUTO_LAYOUT: 'schema-visualizer.auto-layout',+ SCHEMA_VISUALIZER_FOCUS_SCHEMA: 'schema-visualizer.focus-schema',+}++export type SchemaVisualizerShortcutId =+ (typeof SCHEMA_VISUALIZER_SHORTCUT_IDS)[keyof typeof SCHEMA_VISUALIZER_SHORTCUT_IDS]++export const schemaVisualizerRegistry: RegistryDefinations<SchemaVisualizerShortcutId> = {+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_SQL]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_SQL,+ label: 'Copy schema as SQL',+ sequence: ['Mod+Shift+C'],+ showInSettings: false,+ options: { registerInCommandMenu: true },+ },+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_MARKDOWN]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_COPY_MARKDOWN,+ label: 'Copy schema as Markdown',+ sequence: ['Mod+Shift+M'],+ showInSettings: false,+ options: { registerInCommandMenu: true },+ },+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_PNG]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_PNG,+ label: 'Download schema as PNG',+ sequence: ['D', 'P'],+ showInSettings: false,+ options: { ignoreInputs: true, registerInCommandMenu: true },+ },+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_SVG]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_DOWNLOAD_SVG,+ label: 'Download schema as SVG',+ sequence: ['D', 'S'],+ showInSettings: false,+ options: { ignoreInputs: true, registerInCommandMenu: true },+ },+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_AUTO_LAYOUT]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_AUTO_LAYOUT,+ label: 'Open auto-layout dialog',+ sequence: ['O', 'A'],+ showInSettings: false,+ options: { ignoreInputs: true, registerInCommandMenu: true },+ },+ [SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_FOCUS_SCHEMA]: {+ id: SCHEMA_VISUALIZER_SHORTCUT_IDS.SCHEMA_VISUALIZER_FOCUS_SCHEMA,+ label: 'Open schema selector',+ sequence: ['O', 'S'],+ showInSettings: false,+ options: { ignoreInputs: true, registerInCommandMenu: true },+ },+}diff --git a/apps/studio/state/shortcuts/useShortcut.tsx b/apps/studio/state/shortcuts/useShortcut.tsxindex a7942d1186a..edb39809bf1 100644--- a/apps/studio/state/shortcuts/useShortcut.tsx+++ b/apps/studio/state/shortcuts/useShortcut.tsx@@ -70,6 +70,8 @@ export function useShortcut(id: ShortcutId, callback: () => void, options?: Shorconst enabled = globallyEnabled && callerEnabledconst timeout = options?.timeout ?? def.options?.timeout ?? undefinedconst ignoreInputs = options?.ignoreInputs ?? def.options?.ignoreInputs+ const registerInCommandMenu =+ options?.registerInCommandMenu ?? def.options?.registerInCommandMenu ?? false// Only include `ignoreInputs` when set. The library resolves it to a concrete// boolean at register time (false for Meta/Ctrl/Escape, true otherwise), but@@ -83,7 +85,7 @@ export function useShortcut(id: ShortcutId, callback: () => void, options?: Shor})// Handle overrides for command menu- const enabledInCommandMenu = enabled && (options?.registerInCommandMenu ?? false)+ const enabledInCommandMenu = enabled && registerInCommandMenuconst depsInCommandMenu = [enabled, def.label]const callbackRef = useLatest(callback)const setCommandMenuOpen = useSetCommandMenuOpen()diff --git a/e2e/studio/features/database.spec.ts b/e2e/studio/features/database.spec.tsindex 80cc3a6520e..c3dd933dc33 100644--- a/e2e/studio/features/database.spec.ts+++ b/e2e/studio/features/database.spec.ts@@ -3,6 +3,7 @@ import { expect } from '@playwright/test'import { env } from '../env.config.js'import { expectClipboardValue } from '../utils/clipboard.js'import { createTable, dropTable, query } from '../utils/db/index.js'+import { dismissToastsIfAny } from '../utils/dismiss-toast.js'import { test, withSetupCleanup } from '../utils/test.js'import { toUrl } from '../utils/to-url.js'import {@@ -50,6 +51,10 @@ test.describe('Database', () => {);`,})+ await expect(page.getByText('Successfully copied as SQL')).toBeVisible({ timeout: 15000 })+ await dismissToastsIfAny(page)+ await expect(page.locator('[data-sonner-toast]')).toHaveCount(0)+// downloads schema diagram when export is triggeredconst downloadPromise = page.waitForEvent('download')await page.getByRole('button', { name: 'Export options' }).click()@@ -57,6 +62,10 @@ test.describe('Database', () => {const download = await downloadPromiseexpect(download.suggestedFilename()).toContain('.png')+ await expect(page.getByText('Successfully downloaded as PNG')).toBeVisible({ timeout: 15000 })+ await dismissToastsIfAny(page)+ await expect(page.locator('[data-sonner-toast]')).toHaveCount(0)+// changing schema -> authawait page.getByTestId('schema-selector').click()await page.getByRole('option', { name: 'auth' }).click()