// The keyboard shortcuts: "g" then a letter goes to a page (like GitHub's), "/" jumps to the search box, "?" lists them all. // One list, so the handler, the help dialog and the command palette's hints can't drift apart. export interface GoShortcut { /** The letter after "g". */ key: string; to: string; label: string; } export const GO_SHORTCUTS: GoShortcut[] = [ { key: "d", to: "/", label: "Dashboard" }, { key: "a", to: "/alerts", label: "Alerts" }, { key: "s", to: "/servers", label: "Servers" }, { key: "m", to: "/maintenance", label: "Maintenance" }, { key: "u", to: "/updates", label: "Updates" }, { key: "i", to: "/integrations", label: "Integrations" }, { key: "k", to: "/secrets", label: "Secrets" }, { key: "p", to: "/map", label: "Map" }, { key: "w", to: "/wall", label: "Wall display" }, ]; export const OTHER_SHORTCUTS: { keys: string; label: string }[] = [ { keys: "Ctrl K", label: "Search, and run actions (silence a server, switch theme…)" }, { keys: "/", label: "Jump to the search box of the table on this page" }, { keys: "j / k", label: "Move down or up the rows of the table on this page (Enter opens the row)" }, { keys: "[", label: "Narrow the sidebar to icons, or widen it again" }, { keys: "?", label: "Show this list" }, { keys: "Esc", label: "Close a dialog, the search or this list" }, ]; /** The "g x" hint for a page, if it has one — shown beside it in the command palette. */ export function shortcutHintFor(to: string): string | null { const found = GO_SHORTCUTS.find((s) => s.to === to); return found ? `g ${found.key}` : null; } export const SHOW_SHORTCUTS_EVENT = "show-shortcuts";