import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { formatKeyBinding, SHORTCUT_DEFINITIONS } from '@/lib/keyboardShortcuts' import { useUITranslation } from '@/lib/useUITranslation' import type { FC } from 'react' import type { KeyBinding, ShortcutActionId, ShortcutScope } from '@/lib/keyboardShortcuts' type Props = { open: boolean onOpenChange: (open: boolean) => void activeScope: ShortcutScope effectiveBindings: Record conflictActionIds: Set availableActionIds: Set } const ShortcutHelpDialog: FC = props => { const { open, onOpenChange, activeScope, effectiveBindings, conflictActionIds, availableActionIds } = props const { label } = useUITranslation ('settings') const rows = SHORTCUT_DEFINITIONS .filter (definition => definition.scope === 'global' || definition.scope === activeScope) .filter (definition => availableActionIds.has (definition.id)) return ( {label ('shortcuts.title')} {label ('shortcuts.description')}
{rows.map (row => ( ))}
{label ('shortcuts.operation')} {label ('shortcuts.scope')} {label ('shortcuts.key')} {label ('shortcuts.conflict')}
{label (`shortcuts.actions.${row.id}`)} {label (`shortcuts.scopes.${row.scope}`)} {effectiveBindings[row.id] == null ? label ('shortcuts.unassigned') : {formatKeyBinding (effectiveBindings[row.id])}} {conflictActionIds.has (row.id) ? {label ('shortcuts.conflicting')} : label ('shortcuts.none')}
) } export default ShortcutHelpDialog