import { Group, Kbd, ScrollArea, Text, UnstyledButton } from "@mantine/core"; import { IconApps, IconCommand, IconMovie, IconRobot, IconSearch, IconSettings, IconUsers, IconWorldSearch, } from "@tabler/icons-react"; import { useSession } from "@homarr/auth/client"; import type { SpotlightMode } from "../open"; import classes from "./spotlight.module.css"; interface ModeRailEntry { ariaLabel: string; character?: string; label: string; mode: SpotlightMode; } interface SpotlightModeRailProps { activeMode: SpotlightMode; entries: ModeRailEntry[]; navigationLabel: string; onModeChange: (mode: SpotlightMode) => void; } const modeIcons: Record = { search: IconSearch, apps: IconApps, command: IconCommand, preferences: IconSettings, assistant: IconRobot, external: IconWorldSearch, media: IconMovie, userGroup: IconUsers, }; export const SpotlightModeRail = ({ activeMode, entries, navigationLabel, onModeChange }: SpotlightModeRailProps) => { const { data: session } = useSession(); const canManageUsers = session?.user.permissions.includes("admin") ?? false; return ( {entries.map((entry) => { if (entry.mode === "userGroup" && !canManageUsers) return null; const Icon = modeIcons[entry.mode]; const active = entry.mode === activeMode; return ( onModeChange(entry.mode)} > {entry.label} {entry.character ? ( {entry.character} ) : null} ); })} ); };