Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
import { For, Show } from 'solid-js';
import { Dialog } from '@/components/shared/Dialog';
import { SearchField } from '@/components/shared/SearchField';
import {
type CommandPaletteModalCommand,
type CommandPaletteModalProps,
useCommandPaletteState,
} from './useCommandPaletteState';
export type { CommandPaletteModalProps } from './useCommandPaletteState';
const COMMAND_PALETTE_RESULTS_ID = 'command-palette-results';
const getCommandPaletteOptionId = (commandId: string) => `command-palette-option-${commandId}`;
export function CommandPaletteModal(props: CommandPaletteModalProps) {
const commandPalette = useCommandPaletteState(props);
const activeOptionId = () => {
const command = commandPalette.filteredCommands()[commandPalette.selectedIndex()];
return command ? getCommandPaletteOptionId(command.id) : undefined;
};
const handleSelect = (command: CommandPaletteModalCommand) => {
commandPalette.handleSelect(command);
};
return (
<Dialog
isOpen={props.isOpen}
onClose={props.onClose}
panelClass="max-w-xl"
ariaLabel="Command palette"
>
<div class="border-b border-border px-5 py-4">
<SearchField
value={commandPalette.query()}
onChange={commandPalette.setQuery}
inputRef={commandPalette.setInputRef}
onKeyDown={commandPalette.handleInputKeyDown}
placeholder="Type a command or search..."
class="w-full"
clearOnFocusedEscape={false}
shortcutHint="Cmd+K"
role="combobox"
ariaAutocomplete="list"
ariaControls={COMMAND_PALETTE_RESULTS_ID}
ariaExpanded={commandPalette.filteredCommands().length > 0}
ariaActiveDescendant={activeOptionId()}
/>
</div>
<div class="max-h-[320px] overflow-y-auto px-3 py-3">
<Show
when={commandPalette.filteredCommands().length > 0}
fallback={<div class="px-3 py-8 text-center text-sm text-muted">No matches found.</div>}
>
<div
ref={commandPalette.setListboxRef}
id={COMMAND_PALETTE_RESULTS_ID}
role="listbox"
aria-label="Command palette results"
>
<For each={commandPalette.filteredCommands()}>
{(command, index) => {
const selected = () => commandPalette.selectedIndex() === index();
return (
<button
type="button"
id={getCommandPaletteOptionId(command.id)}
role="option"
aria-selected={selected()}
tabIndex={-1}
class={`flex w-full items-center justify-between rounded-md px-3 py-2 text-left text-sm text-base-content outline-hidden transition-colors hover:bg-surface-hover focus:bg-surface-hover ${
selected() ? 'bg-surface-hover' : ''
}`}
onClick={() => handleSelect(command)}
onMouseEnter={() => commandPalette.setSelectedIndex(index())}
>
<div>
<div class="font-medium">{command.label}</div>
<Show when={command.description}>
<div class="text-xs text-muted">{command.description}</div>
</Show>
</div>
<Show when={command.shortcut}>
<span class="rounded-sm border border-border-subtle bg-page px-2 py-1 text-[10px] font-medium text-base-content">
{command.shortcut}
</span>
</Show>
</button>
);
}}
</For>
</div>
</Show>
</div>
</Dialog>
);
}
export default CommandPaletteModal;