import { useState, type ReactNode } from "react"; import { NavLink } from "react-router-dom"; import { IconLayoutDashboard, IconServer2, IconWorld, IconNetwork, IconKey, IconPlugConnected, IconBrandDocker, IconAffiliate, IconPlayerPlay, IconBrandGit, IconServerCog, IconDatabase, IconUsers, IconHistory, IconStethoscope, IconSettings, IconMenu2, } from "@tabler/icons-react"; import type { CurrentUser } from "../api/client"; interface NavItem { to: string; label: string; icon: ReactNode; minRole?: "operator" | "admin"; } const NAV_ITEMS: NavItem[] = [ { to: "/", label: "Dashboard", icon: }, { to: "/servers", label: "Servers", icon: }, { to: "/proxmox", label: "Proxmox", icon: }, { to: "/docker", label: "Docker", icon: }, { to: "/synology", label: "Synology", icon: }, { to: "/secrets", label: "Secrets", icon: }, { to: "/dns", label: "DNS", icon: }, { to: "/ipam", label: "IP Addresses", icon: }, { to: "/tailscale", label: "Tailscale", icon: }, { to: "/semaphore", label: "Semaphore", icon: }, { to: "/gitea", label: "Gitea", icon: }, { to: "/integrations", label: "Integrations", icon: }, { to: "/users", label: "Users", icon: , minRole: "admin" }, { to: "/audit-log", label: "Audit Log", icon: , minRole: "operator" }, { to: "/diag-log", label: "Diagnostic Log", icon: , minRole: "admin" }, { to: "/settings", label: "Settings", icon: , minRole: "admin" }, ]; const roleRank: Record = { viewer: 0, operator: 1, admin: 2 }; export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) { const [sidebarOpen, setSidebarOpen] = useState(false); const visibleItems = NAV_ITEMS.filter( (item) => !item.minRole || roleRank[user.role] >= roleRank[item.minRole], ); return (
{children}
); }