import { Command } from "lucide-react"; // helpers import { substringMatch } from "@/helpers/string.helper"; // hooks import { usePlatformOS } from "@/hooks/use-platform-os"; type Props = { searchQuery: string; }; export const ShortcutCommandsList: React.FC = (props) => { const { searchQuery } = props; const { platform } = usePlatformOS(); const KEYBOARD_SHORTCUTS = [ { key: "navigation", title: "Navigation", shortcuts: [{ keys: "Ctrl,K", description: "Open command menu" }], }, { key: "common", title: "Common", shortcuts: [ { keys: "P", description: "Create project" }, { keys: "C", description: "Create issue" }, { keys: "Q", description: "Create cycle" }, { keys: "M", description: "Create module" }, { keys: "V", description: "Create view" }, { keys: "D", description: "Create page" }, { keys: "Delete", description: "Bulk delete issues" }, { keys: "H", description: "Open shortcuts guide" }, { keys: platform === "MacOS" ? "Ctrl,control,C" : "Ctrl,Alt,C", description: "Copy issue URL from the issue details page", }, ], }, ]; const filteredShortcuts = KEYBOARD_SHORTCUTS.map((category) => { const newCategory = { ...category }; newCategory.shortcuts = newCategory.shortcuts.filter((shortcut) => substringMatch(shortcut.description, searchQuery) ); return newCategory; }); const isShortcutsEmpty = filteredShortcuts.every((category) => category.shortcuts.length === 0); return (
{!isShortcutsEmpty ? ( filteredShortcuts.map((category) => { if (category.shortcuts.length === 0) return; return (
{category.title}
{category.shortcuts.map((shortcut) => (

{shortcut.description}

{shortcut.keys.split(",").map((key) => (
{key === "Ctrl" ? (
{ platform === "MacOS" ? : 'Ctrl'}
) : ( {key} )}
))}
))}
); }) ) : (

No shortcuts found for{" "} {`"`} {searchQuery} {`"`}

)}
); };