The page also gives quarterly and annual reports. The route is unchanged; the scheduled monthly message in Notifications keeps its name. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
247 lines
8.8 KiB
TypeScript
247 lines
8.8 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import {
|
|
IconLayoutDashboard,
|
|
IconServer2,
|
|
IconWorld,
|
|
IconNetwork,
|
|
IconRouter,
|
|
IconArrowsSplit2,
|
|
IconHome2,
|
|
IconBatteryCharging,
|
|
IconDatabaseExport,
|
|
IconAdjustmentsAlt,
|
|
IconChecklist,
|
|
IconListDetails,
|
|
IconKey,
|
|
IconPlugConnected,
|
|
IconBrandDocker,
|
|
IconAffiliate,
|
|
IconCloud,
|
|
IconBinaryTree,
|
|
IconDeviceGamepad2,
|
|
IconDeviceTv,
|
|
IconServerBolt,
|
|
IconBolt,
|
|
IconFileText,
|
|
IconFlame,
|
|
IconLock,
|
|
IconMovie,
|
|
IconPhoto,
|
|
IconPlayerPlay,
|
|
IconBrandGit,
|
|
IconServerCog,
|
|
IconDatabase,
|
|
IconUsers,
|
|
IconSettings,
|
|
IconWand,
|
|
IconTool,
|
|
IconListCheck,
|
|
IconRefresh,
|
|
IconApps,
|
|
IconHistory,
|
|
IconGauge,
|
|
IconCoin,
|
|
IconBooks,
|
|
IconDownload,
|
|
IconCloudDownload,
|
|
IconCpu,
|
|
IconBox,
|
|
IconHeartbeat,
|
|
IconGitCommit,
|
|
IconShieldLock,
|
|
IconWorldWww,
|
|
IconVersions,
|
|
IconChartAreaLine,
|
|
IconActivityHeartbeat,
|
|
IconCopyCheck,
|
|
IconTicket,
|
|
IconPlug,
|
|
IconExternalLink,
|
|
IconAlertTriangle,
|
|
IconSitemap,
|
|
IconCalendarEvent,
|
|
IconHeartRateMonitor,
|
|
IconReportAnalytics,
|
|
} from "@tabler/icons-react";
|
|
import type { CurrentUser } from "../api/client";
|
|
import { isPageHidden } from "../utils/navVisibility";
|
|
|
|
// The menu: what pages there are, how they are grouped, and which role is needed to see each. Used by the sidebar, the command
|
|
// palette, the keyboard shortcuts and the breadcrumbs, so they always agree.
|
|
|
|
type Role = "operator" | "admin";
|
|
|
|
export interface NavLeaf {
|
|
to: string;
|
|
label: string;
|
|
/** Shown for top-level links, and when a group is left with a single visible page and so is drawn as that page's own link. */
|
|
icon: ReactNode;
|
|
minRole?: Role;
|
|
}
|
|
|
|
export interface NavGroup {
|
|
id: string;
|
|
label: string;
|
|
icon: ReactNode;
|
|
items: NavLeaf[];
|
|
}
|
|
|
|
export type NavEntry = NavLeaf | NavGroup;
|
|
|
|
export const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry;
|
|
|
|
export const NAV: NavEntry[] = [
|
|
{ to: "/", label: "Dashboard", icon: <IconLayoutDashboard size={20} /> },
|
|
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
|
|
{ to: "/my-work", label: "My work", icon: <IconChecklist size={20} />, minRole: "operator" },
|
|
{
|
|
id: "infrastructure",
|
|
label: "Infrastructure",
|
|
icon: <IconServer2 size={20} />,
|
|
items: [
|
|
{ to: "/servers", label: "Servers", icon: <IconServer2 size={20} /> },
|
|
{ to: "/proxmox", label: "Proxmox", icon: <IconServerCog size={20} /> },
|
|
{ to: "/synology", label: "Synology", icon: <IconDatabase size={20} /> },
|
|
{ to: "/docker", label: "Docker", icon: <IconBrandDocker size={20} /> },
|
|
{ to: "/hetzner", label: "Hetzner Cloud", icon: <IconServerBolt size={20} /> },
|
|
{ to: "/hetzner-robot", label: "Hetzner Robot", icon: <IconCpu size={20} /> },
|
|
{ to: "/game-servers", label: "Game servers", icon: <IconDeviceGamepad2 size={20} /> },
|
|
{ to: "/tailscale", label: "Tailscale", icon: <IconAffiliate size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "apps",
|
|
label: "Apps",
|
|
icon: <IconApps size={20} />,
|
|
items: [
|
|
{ to: "/home-assistant", label: "Home Assistant", icon: <IconHome2 size={20} /> },
|
|
{ to: "/jellyfin", label: "Jellyfin", icon: <IconMovie size={20} /> },
|
|
{ to: "/media", label: "Media managers", icon: <IconDeviceTv size={20} /> },
|
|
{ to: "/downloads", label: "Download clients", icon: <IconCloudDownload size={20} /> },
|
|
{ to: "/immich", label: "Immich", icon: <IconPhoto size={20} /> },
|
|
{ to: "/paperless", label: "Paperless", icon: <IconFileText size={20} /> },
|
|
{ to: "/nextcloud", label: "Nextcloud", icon: <IconCloud size={20} /> },
|
|
{ to: "/authentik", label: "Authentik", icon: <IconLock size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "backups",
|
|
label: "Backups",
|
|
icon: <IconCopyCheck size={20} />,
|
|
items: [
|
|
{ to: "/backups", label: "Proxmox backups", icon: <IconCopyCheck size={20} /> },
|
|
{ to: "/duplicati", label: "Duplicati", icon: <IconDatabaseExport size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "network",
|
|
label: "Network",
|
|
icon: <IconWorld size={20} />,
|
|
items: [
|
|
{ to: "/dns", label: "DNS", icon: <IconWorld size={20} /> },
|
|
{ to: "/adguard", label: "AdGuard Home", icon: <IconShieldLock size={20} /> },
|
|
{ to: "/technitium", label: "Technitium DNS", icon: <IconWorldWww size={20} /> },
|
|
{ to: "/network/devices", label: "Network devices", icon: <IconRouter size={20} /> },
|
|
{ to: "/proxy-hosts", label: "Proxy hosts", icon: <IconArrowsSplit2 size={20} /> },
|
|
{ to: "/ipam", label: "IP Addresses", icon: <IconNetwork size={20} /> },
|
|
{ to: "/netbox", label: "NetBox", icon: <IconBinaryTree size={20} /> },
|
|
{ to: "/ports", label: "Ports", icon: <IconPlug size={20} /> },
|
|
{ to: "/consistency", label: "Consistency", icon: <IconListCheck size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "monitoring",
|
|
label: "Monitoring",
|
|
icon: <IconHeartbeat size={20} />,
|
|
items: [
|
|
{ to: "/endpoints", label: "Endpoints", icon: <IconHeartbeat size={20} /> },
|
|
{ to: "/alert-settings", label: "Alert settings", icon: <IconAdjustmentsAlt size={20} /> },
|
|
{ to: "/heartbeats", label: "Heartbeats", icon: <IconHeartRateMonitor size={20} /> },
|
|
{ to: "/uptime-kuma", label: "Uptime Kuma", icon: <IconActivityHeartbeat size={20} /> },
|
|
{ to: "/ups", label: "UPS", icon: <IconBatteryCharging size={20} /> },
|
|
{ to: "/prometheus", label: "Prometheus", icon: <IconFlame size={20} /> },
|
|
{ to: "/grafana", label: "Grafana", icon: <IconChartAreaLine size={20} /> },
|
|
{ to: "/speedtest", label: "Speedtest", icon: <IconGauge size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "automation",
|
|
label: "Automation",
|
|
icon: <IconRefresh size={20} />,
|
|
items: [
|
|
{ to: "/semaphore", label: "Semaphore", icon: <IconPlayerPlay size={20} /> },
|
|
{ to: "/gitea", label: "Gitea", icon: <IconBrandGit size={20} /> },
|
|
{ to: "/n8n", label: "n8n", icon: <IconBolt size={20} /> },
|
|
],
|
|
},
|
|
{ to: "/secrets", label: "Secrets", icon: <IconKey size={20} /> },
|
|
{
|
|
id: "operations",
|
|
label: "Operations",
|
|
icon: <IconTool size={20} />,
|
|
items: [
|
|
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
|
|
{ to: "/updates", label: "Updates", icon: <IconDownload size={20} /> },
|
|
{ to: "/versions", label: "App versions", icon: <IconVersions size={20} /> },
|
|
{ to: "/coming-up", label: "Coming up", icon: <IconCalendarEvent size={20} /> },
|
|
{ to: "/todo", label: "To do", icon: <IconListDetails size={20} /> },
|
|
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "records",
|
|
label: "Records",
|
|
icon: <IconHistory size={20} />,
|
|
items: [
|
|
{ to: "/reports", label: "Reports", icon: <IconReportAnalytics size={20} /> },
|
|
{ to: "/costs", label: "Costs", icon: <IconCoin size={20} /> },
|
|
{ to: "/changes", label: "Change log", icon: <IconGitCommit size={20} />, minRole: "operator" },
|
|
],
|
|
},
|
|
{
|
|
id: "reference",
|
|
label: "Reference",
|
|
icon: <IconBooks size={20} />,
|
|
items: [
|
|
{ to: "/map", label: "Map", icon: <IconSitemap size={20} /> },
|
|
{ to: "/inventory", label: "Inventory", icon: <IconBox size={20} /> },
|
|
{ to: "/admin-links", label: "Admin Links", icon: <IconExternalLink size={20} /> },
|
|
{ to: "/generator", label: "Generator", icon: <IconWand size={20} /> },
|
|
],
|
|
},
|
|
{
|
|
id: "administration",
|
|
label: "Administration",
|
|
icon: <IconSettings size={20} />,
|
|
items: [
|
|
{ to: "/integrations", label: "Integrations", icon: <IconPlugConnected size={20} /> },
|
|
{ to: "/users", label: "Users", icon: <IconUsers size={20} />, minRole: "admin" },
|
|
{ to: "/settings", label: "Settings", icon: <IconSettings size={20} />, minRole: "admin" },
|
|
],
|
|
},
|
|
];
|
|
|
|
const roleRank: Record<CurrentUser["role"], number> = { viewer: 0, operator: 1, admin: 2 };
|
|
|
|
/** What this role can see: pages it isn't allowed are dropped, so are pages of integrations nobody has added when the Display setting says to leave those out, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
|
export function visibleNav(role: CurrentUser["role"]): NavEntry[] {
|
|
const allowed = (leaf: NavLeaf) => (!leaf.minRole || roleRank[role] >= roleRank[leaf.minRole]) && !isPageHidden(leaf.to);
|
|
const out: NavEntry[] = [];
|
|
for (const entry of NAV) {
|
|
if (!isGroup(entry)) {
|
|
if (allowed(entry)) out.push(entry);
|
|
continue;
|
|
}
|
|
const items = entry.items.filter(allowed);
|
|
if (items.length === 1) out.push(items[0]);
|
|
else if (items.length > 1) out.push({ ...entry, items });
|
|
}
|
|
return out;
|
|
}
|
|
|
|
/** Is this the current page (or a page beneath it, like /servers/3 under /servers)? */
|
|
export function isCurrent(pathname: string, to: string): boolean {
|
|
return to === "/" ? pathname === "/" : pathname === to || pathname.startsWith(`${to}/`);
|
|
}
|
|
|