{{-- Command palette + keyboard shortcuts. Mounted ONCE in the persistent layout so it survives wire:navigate and its global keydown listener is registered only once. Strg/⌘-K opens it; "g" + a key navigates; "/" focuses the page search; "?" shows help. --}} @php // Every navigable page (mirrors the 3-group sidebar), each ROLE-GATED so the palette + its // "g " shortcut only ever offer pages the user can actually open — go() resolves a chord // via this list, so a gated-out page has neither an entry nor a live shortcut (no 403 dead-end). // [ lang key, href, chord letter (null = search-only), required ability (null = always) ] $u = auth()->user(); $navDefs = [ // Fleet ['shell.nav_dashboard', '/', 'd', null], ['shell.nav_servers', '/servers', 's', null], ['shell.nav_services', '/services', 'i', null], ['shell.nav_commands', '/commands', 'c', 'operate'], ['shell.nav_files', '/files', 'f', null], ['shell.nav_audit', '/audit', 'l', null], // Host ['shell.nav_docker', '/docker', 'k', 'manage-fleet'], ['shell.nav_terminal', '/terminal', 't', 'manage-fleet'], ['shell.nav_wireguard', '/wireguard', 'w', 'manage-network'], ['shell.nav_system', '/system', 'y', null], ['shell.nav_posture', '/posture', 'p', 'operate'], ['shell.nav_patch', '/patch', 'u', 'operate'], ['shell.nav_certs', '/certs', 'r', 'operate'], ['shell.nav_health', '/health', null, 'operate'], // Account ['shell.nav_settings', '/settings', 'e', null], ['shell.nav_alerts', '/alerts', 'a', 'manage-panel'], ['shell.nav_threats', '/threats', null, 'manage-panel'], ['shell.nav_versions', '/versions', 'v', null], ['shell.nav_help', config('clusev.docs_url'), 'h', null], ]; $nav = []; foreach ($navDefs as [$key, $href, $chord, $gate]) { if ($gate !== null && ! ($u?->can($gate) ?? false)) { continue; } $nav[] = ['label' => __($key), 'href' => $href, 'hint' => $chord ? 'g '.$chord : '']; } // Help panel: the fixed utility keys + one "g " row per shortcut the user actually has. $chords = [ ['Strg / ⌘ K', __('shell.cmdk_open')], ['/', __('shell.cmdk_focus_search')], ['?', __('shell.cmdk_show_help')], ]; foreach ($nav as $n) { if ($n['hint'] !== '') { $chords[] = [str_replace('g ', 'g ', $n['hint']), $n['label']]; } } $actions = [ ['label' => __('servers.add_server'), 'action' => 'create-server', 'hint' => ''], ]; // Fleet servers become palette entries so "Strg/⌘ K → name/IP" jumps straight to a // server's details. `search` carries name + IP so either matches; the hint shows the IP. $servers = \App\Models\Server::orderBy('name')->get(['uuid', 'name', 'ip']) ->map(fn ($s) => [ 'label' => $s->name, 'href' => '/servers/'.$s->uuid, 'hint' => $s->ip, 'search' => $s->name.' '.$s->ip, ])->all(); $kbd = 'rounded border border-line bg-inset px-1.5 py-0.5 font-mono text-[10px] text-ink-2'; @endphp
{{-- Command palette --}} {{-- Shortcut help --}}