wulf-pulse/app/admin/itglue-writes/page.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

177 lines
6.1 KiB
TypeScript

'use client';
import { useEffect, useState } from 'react';
import Link from 'next/link';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { PageHeader } from '@/components/navigation/page-header';
interface WriteRow {
id: string;
audit_id: string | null;
asset_type: 'flexible_asset';
asset_id: string;
field_name: string;
before_value: unknown;
after_value: unknown;
performed_by_user_id: string | null;
performed_at: string;
status: 'pending' | 'committed' | 'failed' | 'reverted';
error_message: string | null;
}
const STATUSES: Array<WriteRow['status'] | 'all'> = [
'all',
'committed',
'reverted',
'failed',
'pending',
];
function statusVariant(
s: WriteRow['status']
): 'default' | 'secondary' | 'destructive' | 'outline' {
switch (s) {
case 'committed':
return 'default';
case 'reverted':
return 'secondary';
case 'failed':
return 'destructive';
default:
return 'outline';
}
}
export default function ItglueWritesPage() {
const [rows, setRows] = useState<WriteRow[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [statusFilter, setStatusFilter] =
useState<WriteRow['status'] | 'all'>('all');
async function load(): Promise<void> {
try {
const url =
statusFilter === 'all'
? '/api/analyzer/itglue/writes'
: `/api/analyzer/itglue/writes?status=${statusFilter}`;
const res = await fetch(url);
if (!res.ok) {
const data = (await res.json().catch(() => ({}))) as { error?: string };
throw new Error(data.error ?? `Request failed: ${res.status}`);
}
const data = (await res.json()) as { writes: WriteRow[] };
setRows(data.writes);
setError(null);
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
}
}
useEffect(() => {
void load();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [statusFilter]);
return (
<>
<PageHeader
title="IT Glue Writes"
description="Every PATCH to IT Glue from Pulse, with before/after diffs and revert history."
breadcrumbs={[{ label: 'Admin', href: '/admin' }, { label: 'IT Glue Writes' }]}
accent
/>
<div className="container mx-auto px-6 py-6 max-w-5xl space-y-6">
<Card>
<CardHeader>
<div className="flex items-center justify-between gap-4 flex-wrap">
<div>
<CardTitle>IT Glue write log</CardTitle>
<p className="text-sm text-muted-foreground mt-1">
Every PATCH to IT Glue from Pulse, with before/after diffs and
revert history.
</p>
</div>
<div className="flex items-center gap-1">
{STATUSES.map((s) => (
<Button
key={s}
variant={statusFilter === s ? 'secondary' : 'ghost'}
size="sm"
onClick={() => setStatusFilter(s)}
>
{s}
</Button>
))}
</div>
</div>
</CardHeader>
<CardContent>
{error && (
<Alert variant="destructive" className="mb-4">
<AlertTitle>Couldn&rsquo;t load writes</AlertTitle>
<AlertDescription>{error}</AlertDescription>
</Alert>
)}
{rows === null && !error ? (
<div className="space-y-2">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-12 w-full" />
<Skeleton className="h-12 w-full" />
</div>
) : rows && rows.length === 0 ? (
<p className="text-sm text-muted-foreground">No writes recorded yet.</p>
) : (
<ul className="divide-y">
{(rows ?? []).map((w) => (
<li key={w.id} className="py-3">
<div className="flex items-start justify-between gap-3 flex-wrap">
<div className="min-w-0 flex-1">
<p className="text-sm">
<Link
href={`/analyzer/itglue/applications/${w.asset_id}`}
className="font-mono hover:underline"
>
{w.asset_id}
</Link>
{' · '}
<span className="font-medium">{w.field_name}</span>
</p>
<p className="text-xs text-muted-foreground mt-1">
{new Date(w.performed_at).toLocaleString()}
</p>
<p className="text-xs mt-1 break-words">
<span className="text-muted-foreground">Before: </span>
<span className="font-mono">
{w.before_value === null || w.before_value === undefined
? '(empty)'
: JSON.stringify(w.before_value).slice(0, 200)}
</span>
</p>
<p className="text-xs mt-0.5 break-words">
<span className="text-muted-foreground">After: </span>
<span className="font-mono">
{JSON.stringify(w.after_value).slice(0, 200)}
</span>
</p>
{w.error_message && (
<p className="text-xs mt-1 text-destructive">
Error: {w.error_message}
</p>
)}
</div>
<Badge variant={statusVariant(w.status)}>{w.status}</Badge>
</div>
</li>
))}
</ul>
)}
</CardContent>
</Card>
</div>
</>
);
}