wulf-pulse/components/navigation/app-navigation.tsx
lorentz 9bfb57553d feat(design): nav/visual overhaul — brand layer, /status route, KPI dashboard, TanStack DataTable
Major UI refresh on the nav-design-improvements branch.  Drops 2013-era
inline styles and consolidates patterns behind shared primitives.

Foundation
- New Wulf brand layer in app/styles/brand.css repointing --primary to
  the standards-guide blue (#0075AD) with utility classes for numerics
  (.num / .num-lg / .num-xl), metric labels, surface tints, and the
  wolf-mark watermark
- Switch primary face to IBM Plex Sans + IBM Plex Mono via next/font;
  Helvetica/Arial stays in the fallback chain for brand fidelity
- Wordmark subtitle changed from "PSA Management System" to
  "Operations console" everywhere it appeared
- Tagline footer ("Don't be afraid to cry") on every non-mobile page

Status moved out of /dashboard
- New /status route with integration tiles grouped by category, sync
  health table, worker pulse cards (analyzer / RMM / sync scheduler),
  token-expiry section, conditional alert banner
- Top-bar StatusIndicator polls integration health every 60s and links
  to /status
- INTEGRATIONS_DISABLED env var suppresses operator-disabled
  integrations (e.g. SentinelOne) — no failure noise from broken-on-
  purpose entries.  Aliases supported (sentinelone → s1, etc.)

Dashboard rebuilt around KPIs
- /api/dashboard/overview adds today snapshot (opened, resolved, open
  total, SLA breaches) with delta math
- /api/dashboard/trends backs queue × priority heatmap, 30-day volume
  area chart, 30-day mean resolution time line chart, today's active
  engineers leaderboard

Components
- StatusBadge driven by lib/status-registry.ts (priority, ticket
  status, classification, source, company type, publish, active /
  yes-no / billable / approved registries)
- StatusLight (8px geometric square, five states, three sizes)
- EmptyState (shared dashed panel with icon + headline + optional CTA)
- KpiCard with delta indicator and tonal left border
- WulfMark (mark / wordmark variants from /public/branding)
- Skeleton helpers (SkeletonRow / Rows / Card / Chart / Header / Table)

Navigation
- Admin flat link → dropdown with seven shortcuts
- New UserMenu (initials avatar, role badge, settings + sign-out)
- Active-route highlight is now a 2px Wulf-blue underline echoing the
  PageHeader rule (consistent across flat links and submenu triggers);
  active children inside dropdowns use bg-primary/10
- Submenu width is content-driven (min-w 320 / max-w 440, single col)
- Mobile hamburger via Sheet, reuses the same nav config

Pages migrated
- 16 admin sub-pages adopt PageHeader (with accent prop)
- /addigy-devices: shadcn Table + Checkbox; PageHeader; status badges
- 10 raw <table> blocks across admin/sync/* migrated to shadcn Table
- /veeam-analysis migrated to shadcn Table (kept its expansion logic)
- Detail routes (analyzer ticket, analyzer analysis) get breadcrumbs

DataTable
- Rewritten on @tanstack/react-table v8 in manual mode; external API
  unchanged so all 10+ data-browser pages keep working
- New optional props for drill-down rows: getRowCanExpand + renderSubRow

Mobile
- Multi-select Popover gets max-w-[calc(100vw-1rem)] and
  collisionPadding so dropdowns can't overflow narrow viewports
- CI filter bar wraps and shrinks; stat pill flows below

Docs
- New ARCHITECTURE.md (load-bearing reference for runtime, data flow,
  workers, analyzer pipeline, auth, deployment, gotchas)
- New DESIGN.md (tokens, layout, navigation IA, component vocabulary,
  rolling backlog of remaining cleanup)
- CLAUDE.md refreshed with pointers to the two new docs and the
  INTEGRATIONS_DISABLED operator config note
- shadcn registry registered as project-level MCP server (.mcp.json)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 09:33:13 -04:00

323 lines
11 KiB
TypeScript

'use client';
import { usePathname } from 'next/navigation';
import Link from 'next/link';
import { cn } from '@/lib/utils';
import {
LayoutDashboard,
Server,
Database,
Activity,
HardDrive,
Sparkles,
Users,
TrendingUp,
BarChart3,
GitCompare,
Brain,
Search,
AlertTriangle,
} from 'lucide-react';
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
navigationMenuTriggerStyle,
} from '@/components/ui/navigation-menu';
import { Button } from '@/components/ui/button';
import { ThemeToggle } from '@/components/theme-toggle';
import { StatusIndicator } from '@/components/navigation/status-indicator';
import { UserMenu } from '@/components/navigation/user-menu';
import { MobileNav } from '@/components/navigation/mobile-nav';
import { useSession } from '@/lib/auth-client';
interface NavItem {
title: string;
href?: string;
icon?: React.ElementType;
description?: string;
children?: NavItem[];
}
const navigationItems: NavItem[] = [
{
title: 'Dashboard',
href: '/',
icon: LayoutDashboard,
description: 'Overview and quick access'
},
{
title: 'Configuration Items',
href: '/configuration-items',
icon: Server,
description: 'Manage IT assets and devices'
},
{
title: 'Backup Status',
icon: HardDrive,
children: [
{
title: 'Backup Status',
href: '/backup-status',
icon: HardDrive,
description: 'Veeam backup health and compliance'
},
{
title: 'RPO Comparison',
href: '/veeam-comparison',
icon: GitCompare,
description: 'Pulse RPO shadow vs Datto RMM ticket comparison'
},
{
title: 'Ticket Analysis',
href: '/veeam-analysis',
icon: Brain,
description: 'AI classification of backup tickets — patterns, skills, SOP gaps'
},
]
},
{
title: 'Engagement',
icon: Users,
children: [
{
title: 'Overview',
href: '/engagement',
icon: Users,
description: 'Staff activity and engagement metrics',
},
{
title: 'Employee Profile',
href: '/engagement/profile',
icon: TrendingUp,
description: '12-month activity calendar and performance profile',
},
],
},
{
title: 'Analyzer',
icon: Sparkles,
children: [
{
title: 'Browse Tickets',
href: '/analyzer/tickets',
icon: Search,
description: 'Filter tickets by period, client, or issue type — pick one to analyze',
},
{
title: 'Aggregate Reports',
href: '/analyzer/reports',
icon: BarChart3,
description: 'Cross-ticket pattern analysis: documentation gaps, process gaps, recurrence clusters',
},
{
title: 'Needs Review',
href: '/analyzer/queue',
icon: AlertTriangle,
description: 'Analyses flagged for human review (low confidence or cost-ceiling skipped Opus)',
},
{
title: 'IT Glue — Applications',
href: '/analyzer/itglue/applications',
icon: Database,
description: 'Audit IT Glue Application records against ticket history; admins can apply or revert documentation changes',
},
{
title: 'IT Glue — Configurations',
href: '/analyzer/itglue/configurations',
icon: Database,
description: 'Audit IT Glue Configuration records (servers, workstations, devices) against ticket history; admins can apply or revert',
},
],
},
{
title: 'Admin',
icon: Activity,
children: [
{
title: 'Admin home',
href: '/admin',
icon: Activity,
description: 'Tile index of every admin tool',
},
{
title: 'Sync schedules',
href: '/admin/sync',
icon: GitCompare,
description: 'Cron-driven syncs for Autotask, IT Glue, Veeam, Engagement, etc.',
},
{
title: 'Workflow rules',
href: '/admin/workflow',
icon: Brain,
description: 'Classification, AI prompts, ticket digest, and execution history',
},
{
title: 'RMM Overshell',
href: '/admin/rmm-overshell',
icon: Activity,
description: 'Curated Datto RMM scripts; recent executions and rate limits',
},
{
title: 'IT Glue write log',
href: '/admin/itglue-writes',
icon: Database,
description: 'Audit-driven changes pushed back to IT Glue; revert from here',
},
{
title: 'Device-link conflicts',
href: '/admin/device-link-conflicts',
icon: AlertTriangle,
description: 'Cross-system mappings needing a human decision',
},
{
title: 'Users & roles',
href: '/admin/users',
icon: Users,
description: 'Invite users, manage roles and permissions',
},
],
},
];
export function AppNavigation() {
const pathname = usePathname();
const { data: session } = useSession();
const userRole = (session?.user as any)?.role || 'user';
const isSuperAdmin = userRole === 'super-admin';
// Mobile routes have their own nav — suppress desktop header
if (pathname.startsWith('/mobile')) return null;
const isActive = (href?: string) => {
if (!href) return false;
return pathname === href || pathname.startsWith(href + '/');
};
// Hide Engagement and Admin from non-super-admins
const visibleItems = navigationItems.filter((item) => {
if (item.title === 'Engagement' || item.title === 'Admin') {
return isSuperAdmin;
}
return true;
});
return (
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
<div className="container mx-auto px-6 flex h-16 items-center justify-between">
{/* Mobile hamburger + brand */}
<div className="flex items-center gap-2 shrink-0">
<MobileNav items={visibleItems} pathname={pathname} isActive={isActive} />
<Link href="/" className="flex items-center space-x-3">
<img
src="/wulff-logo.png"
alt="Wulf Consulting"
className="h-10 w-auto"
/>
<div className="hidden sm:block">
<h1 className="text-xl font-semibold tracking-tight">Pulse</h1>
<p className="text-xs text-muted-foreground">Operations console</p>
</div>
</Link>
</div>
{/* Main Navigation — centered, desktop only */}
<NavigationMenu className="hidden md:flex">
<NavigationMenuList>
{visibleItems.map((item) => {
const childActive = item.children?.some((c) => isActive(c.href)) ?? false;
const flatActive = isActive(item.href);
// Brand-blue 2px underline marks active state — echoes the
// PageHeader rule rather than filling the button with primary.
const activeRule = 'relative after:absolute after:inset-x-2 after:bottom-0 after:h-[2px] after:bg-primary after:rounded-full';
return (
<NavigationMenuItem key={item.title}>
{item.children ? (
<>
<NavigationMenuTrigger
className={cn(
'h-9 px-4 py-2',
childActive && cn(activeRule, 'text-foreground'),
)}
>
{item.icon && <item.icon className="w-4 h-4 mr-2" />}
{item.title}
</NavigationMenuTrigger>
<NavigationMenuContent>
<ul className="grid gap-1 p-2 min-w-[320px] max-w-[440px]">
{item.children.map((child) => {
const active = isActive(child.href);
return (
<li key={child.title}>
<NavigationMenuLink asChild>
<Link
href={child.href || '#'}
className={cn(
'flex items-start gap-3 rounded-sm px-3 py-2 leading-none no-underline outline-none transition-colors',
'hover:bg-accent/40 focus:bg-accent/40',
active && 'bg-primary/10 text-primary',
)}
>
{child.icon && (
<child.icon
className={cn(
'w-4 h-4 mt-0.5 shrink-0',
active ? 'text-primary' : 'text-muted-foreground',
)}
/>
)}
<div className="min-w-0 flex-1">
<div className={cn('text-sm font-medium leading-none', active && 'text-primary')}>
{child.title}
</div>
{child.description && (
<p className="mt-1 line-clamp-2 text-xs leading-snug text-muted-foreground">
{child.description}
</p>
)}
</div>
</Link>
</NavigationMenuLink>
</li>
);
})}
</ul>
</NavigationMenuContent>
</>
) : (
<Link href={item.href || '#'} legacyBehavior passHref>
<NavigationMenuLink
className={cn(
navigationMenuTriggerStyle(),
'h-9',
flatActive && cn(activeRule, 'text-foreground'),
)}
>
{item.icon && <item.icon className="w-4 h-4 mr-2" />}
{item.title}
</NavigationMenuLink>
</Link>
)}
</NavigationMenuItem>
);
})}
</NavigationMenuList>
</NavigationMenu>
{/* Right Side Actions */}
<div className="flex items-center gap-1 shrink-0">
<StatusIndicator />
<ThemeToggle />
<UserMenu />
</div>
</div>
</header>
);
}
// PageHeader moved to ./page-header.tsx; re-exported for backwards compatibility.
export { PageHeader } from '@/components/navigation/page-header';
export type { BreadcrumbItem, PageHeaderProps } from '@/components/navigation/page-header';