diff --git a/apps/studio/components/interfaces/Account/Preferences/ShortcutSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/ShortcutSettings.tsx index 1d42c93612f..b24c127e754 100644 --- a/apps/studio/components/interfaces/Account/Preferences/ShortcutSettings.tsx +++ b/apps/studio/components/interfaces/Account/Preferences/ShortcutSettings.tsx @@ -1,4 +1,13 @@ import { RotateCcw } from 'lucide-react' +import { hotkeyToDisplayKeys } from 'state/shortcuts/hotkey-utils' +import { SHORTCUT_DEFINITIONS } from 'state/shortcuts/registry' +import { + resetAllShortcuts, + resetShortcut, + setShortcutEnabled, + useShortcutStateSnapshot, +} from 'state/shortcuts/shortcut-state' +import { SHORTCUT_CATEGORIES, ShortcutDefinition, ShortcutId } from 'state/shortcuts/types' import { Button, Card, CardContent, KeyboardShortcut, Switch } from 'ui' import { PageSection, @@ -9,28 +18,9 @@ import { PageSectionTitle, } from 'ui-patterns/PageSection' -import { - SHORTCUT_CATEGORIES, - SHORTCUT_DEFINITIONS, - type ShortcutDefinition, - type ShortcutId, -} from 'state/shortcuts/registry' -import { - resetAllShortcuts, - resetShortcut, - setShortcutEnabled, - useShortcutStateSnapshot, -} from 'state/shortcuts/shortcut-state' -import { hotkeyToDisplayKeys } from 'state/shortcuts/hotkey-utils' import { ShortcutRecorder } from './ShortcutRecorder' -function ShortcutRow({ - definition, - isLast, -}: { - definition: ShortcutDefinition - isLast: boolean -}) { +function ShortcutRow({ definition, isLast }: { definition: ShortcutDefinition; isLast: boolean }) { const snap = useShortcutStateSnapshot() const override = snap.overrides[definition.id] const effectiveHotkey = (override?.hotkey as string) ?? definition.defaultHotkey @@ -90,7 +80,12 @@ export function ShortcutSettings() {
{hasOverrides && (
-
diff --git a/apps/studio/components/ui/DownloadResultsButton.tsx b/apps/studio/components/ui/DownloadResultsButton.tsx index 02672e527cd..c7555bb7554 100644 --- a/apps/studio/components/ui/DownloadResultsButton.tsx +++ b/apps/studio/components/ui/DownloadResultsButton.tsx @@ -8,12 +8,12 @@ import saveAs from 'file-saver' import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage' import { useHotKey } from 'hooks/ui/useHotKey' import { useShortcut } from 'hooks/ui/useShortcut' -import { SHORTCUT_IDS } from 'state/shortcuts/registry' import { ChevronDown, Copy, Download, Settings } from 'lucide-react' import Link from 'next/link' import { usePathname } from 'next/navigation' import { useMemo } from 'react' import { toast } from 'sonner' +import { SHORTCUT_IDS } from 'state/shortcuts/registry' import { Button, copyToClipboard, @@ -93,14 +93,10 @@ export const DownloadResultsButton = ({ }) } - useShortcut( - SHORTCUT_IDS.RESULTS_COPY_MARKDOWN, - (e) => { - e.preventDefault() - copyAsMarkdown() - }, - { enabled: copyMarkdownEnabled ?? isEmpty } - ) + useShortcut(SHORTCUT_IDS.RESULTS_COPY_MARKDOWN, (e) => { + e.preventDefault() + copyAsMarkdown() + }) useHotKey( (e) => { diff --git a/apps/studio/hooks/ui/useShortcut.ts b/apps/studio/hooks/ui/useShortcut.ts index 3902ff29912..463214e4422 100644 --- a/apps/studio/hooks/ui/useShortcut.ts +++ b/apps/studio/hooks/ui/useShortcut.ts @@ -1,8 +1,9 @@ import useLatest from 'hooks/misc/useLatest' import { useEffect } from 'react' import { eventMatchesHotkey, parseHotkey } from 'state/shortcuts/hotkey-utils' -import { SHORTCUT_DEFINITIONS, type ShortcutId } from 'state/shortcuts/registry' +import { SHORTCUT_DEFINITIONS } from 'state/shortcuts/registry' import { useShortcutStateSnapshot } from 'state/shortcuts/shortcut-state' +import { ShortcutId } from 'state/shortcuts/types' /** * Subscribe to a registered shortcut by ID.