SPB Git

Repository Public

nav.ts 2.4 KB 47 lines typescript

1import type { TKey } from "@/i18n";2import type { IconName } from "@/ui";34export interface NavItem {5  href: string;6  key: TKey;7  icon: IconName;8  /** Permission from GET /me required to show the entry. Hidden entries stay protected by the server. */9  permission?: string;10  group: "observe" | "operate" | "govern";11}1213export const NAV: readonly NavItem[] = [14  { href: "/", key: "nav.overview", icon: "overview", permission: "cluster.read", group: "observe" },15  { href: "/nodes", key: "nav.nodes", icon: "nodes", permission: "nodes.read", group: "observe" },16  { href: "/services", key: "nav.services", icon: "services", permission: "services.read", group: "observe" },17  { href: "/models", key: "nav.models", icon: "models", permission: "models.read", group: "observe" },18  { href: "/jobs", key: "nav.jobs", icon: "jobs", permission: "jobs.read", group: "operate" },19  { href: "/network", key: "nav.network", icon: "network", permission: "cluster.read", group: "observe" },20  { href: "/storage", key: "nav.storage", icon: "storage", permission: "nodes.read", group: "observe" },21  { href: "/alerts", key: "nav.alerts", icon: "alerts", permission: "alerts.read", group: "operate" },22  { href: "/maintenance", key: "nav.maintenance", icon: "maintenance", permission: "maintenance.read", group: "operate" },23  { href: "/activity", key: "nav.activity", icon: "activity", permission: "cluster.read", group: "govern" },24  { href: "/audit", key: "nav.audit", icon: "audit", permission: "audit.read", group: "govern" },25  { href: "/settings", key: "nav.settings", icon: "settings", group: "govern" },26];2728export function isActive(pathname: string, href: string): boolean {29  return href === "/" ? pathname === "/" : pathname === href || pathname.startsWith(href + "/");30}3132/** Detail route for a search result / event target. */33export function hrefFor(kind: string, id: string, nodeId?: string): string {34  switch (kind) {35    case "node": return `/nodes/${id}`;36    case "service": return `/services/${id}`;37    case "alert": return `/alerts/${id}`;38    case "incident": return `/incidents/${id}`;39    case "action": return `/actions/${id}`;40    case "job": return `/jobs/${id}`;41    case "inference_server": return `/models?server=${id}`;42    case "maintenance_window": return `/maintenance/${id}`;43    case "maintenance_note": return nodeId ? `/nodes/${nodeId}?tab=maintenance` : `/maintenance?tab=notes`;44    default: return "/";45  }46}47
Files main
Menu

Theme