From f66a74fbf7e39352e9616496af91437b32d24eef Mon Sep 17 00:00:00 2001 From: Kevin Williams Date: Fri, 27 Nov 2026 21:22:17 +0000 Subject: [PATCH] feat(ui): use datum-ui Badge, ButtonGroup and Spinner in inventory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace hand-built pieces with the datum-ui components staff-portal already ships (its Tailwind scans all of datum-ui, so every variant's classes are present in the host): - Discovery chips, the rack's issue badges and the Filter count are Badges: red light for a disagreement, amber light to check, outline when OK. - The rack face switch and the Catalog toggle are ButtonGroups; the chosen option is a light primary button. - The two plain "Loading…" lines show a Spinner. Their custom CSS goes. PageTitle stays out: it renders the title as a plain span and takes only a string, so the record header would lose its focusable h1 and icon. Co-Authored-By: Claude Opus 5.5 --- .../src/components/create-capacity-dialog.tsx | 3 ++- .../src/components/device-discovery.test.tsx | 3 ++- .../src/components/device-discovery.tsx | 12 ++++++--- .../inventory-directory-heading.tsx | 3 ++- .../src/components/inventory-location.tsx | 3 ++- .../src/components/inventory-navigation.tsx | 15 ++++++----- .../src/components/physical-inventory.css | 25 +++++-------------- ui/provider/src/components/rack-detail.tsx | 5 ++-- ui/provider/src/pages/inventory-create.tsx | 3 ++- 9 files changed, 37 insertions(+), 35 deletions(-) diff --git a/ui/provider/src/components/create-capacity-dialog.tsx b/ui/provider/src/components/create-capacity-dialog.tsx index 267b152b..2df862a7 100644 --- a/ui/provider/src/components/create-capacity-dialog.tsx +++ b/ui/provider/src/components/create-capacity-dialog.tsx @@ -1,3 +1,4 @@ +import { Spinner } from '@datum-cloud/datum-ui/spinner'; import { Button } from '@datum-cloud/datum-ui/button'; import { Label } from '@datum-cloud/datum-ui/label'; import { useQuery } from '@tanstack/react-query'; @@ -73,7 +74,7 @@ export function CapacityRegistrationForm({ onRegistered }: { onRegistered?: () = // A Device without a uid is listed as ineligible; its placeholder value never matches a selection. return { value: device.metadata.uid ?? `unidentified/${device.metadata.name}`, disabled: !!reason, label: `${device.metadata.name}${reason ? ` — ${reason}` : ''}` }; })} /> - {devices.isPending &&

Loading Devices…

} + {devices.isPending &&

} {devices.error &&

Devices are unavailable or access is denied. Registration is blocked.

} {devices.data?.length === 0 &&

No Devices are available in default.

} {selected &&

Capacity name: {capacityNameFor(selected)}

} diff --git a/ui/provider/src/components/device-discovery.test.tsx b/ui/provider/src/components/device-discovery.test.tsx index 41ab82ad..881ea027 100644 --- a/ui/provider/src/components/device-discovery.test.tsx +++ b/ui/provider/src/components/device-discovery.test.tsx @@ -19,7 +19,8 @@ const hardware = () => screen.getByRole('region', { name: 'Hardware & management const table = (label: string) => within(hardware()).getByRole('table', { name: label }); const rowOf = (label: string, first: string) => within(table(label)).getAllByRole('row').find(row => within(row).queryAllByRole('cell')[0]?.textContent === first)!; const cells = (label: string, first: string) => within(rowOf(label, first)).getAllByRole('cell'); -const chips = () => within(within(hardware()).getByRole('list', { name: 'Discovery conditions' })).getAllByRole('listitem'); +// Each list item holds one datum-ui Badge, which carries the tone, status and tooltip. +const chips = () => within(within(hardware()).getByRole('list', { name: 'Discovery conditions' })).getAllByRole('listitem').map(item => item.firstElementChild as HTMLElement); const fact = (label: string) => within(hardware()).getByText(label, { selector: 'dt' }).nextElementSibling as HTMLElement; const header = (container: HTMLElement) => container.querySelector('.inventory-fact-strip')!; diff --git a/ui/provider/src/components/device-discovery.tsx b/ui/provider/src/components/device-discovery.tsx index d8553bbd..03ba36bd 100644 --- a/ui/provider/src/components/device-discovery.tsx +++ b/ui/provider/src/components/device-discovery.tsx @@ -1,6 +1,7 @@ // The Device page's view of BMC discovery: Device.status, next to the spec it // is compared with. See "Device page" in docs/development/staff-inventory-ui.md. // Red is a disagreement or failure, amber needs checking, and OK stays plain. +import { Badge } from '@datum-cloud/datum-ui/badge'; import { Button } from '@datum-cloud/datum-ui/button'; import { useState, type ReactNode } from 'react'; import type { Device } from '../../../shared/fleet-api'; @@ -20,22 +21,27 @@ function Marked({ tone, reason, children }: { tone: Tone; reason?: string; child ; } +/** Red for a disagreement or failure, amber to check, plain outline when OK. */ +function chipBadge(tone: Tone) { + return { type: tone ?? 'secondary', theme: tone ? 'light' : 'outline' } as const; +} + /** The header's one BMC chip; nothing before discovery has run. */ export function BmcChip({ device }: { device: Device }) { const chip = bmcChip(device); if (!chip) return null; return
BMC
- {chip.label}. {chip.reason} + {chip.label}. {chip.reason}
; } /** The five conditions as one line of chips; the reason and message are each chip's tooltip. */ export function ConditionChips({ device }: { device: Device }) { return
    - {conditionChips(device).map(chip =>
  • + {conditionChips(device).map(chip =>
  • {chip.word} . {chip.reason} -
  • )} + )}
; } diff --git a/ui/provider/src/components/inventory-directory-heading.tsx b/ui/provider/src/components/inventory-directory-heading.tsx index bb6bf0cb..52bbdb34 100644 --- a/ui/provider/src/components/inventory-directory-heading.tsx +++ b/ui/provider/src/components/inventory-directory-heading.tsx @@ -1,3 +1,4 @@ +import { Badge } from '@datum-cloud/datum-ui/badge'; import { Button } from '@datum-cloud/datum-ui/button'; import { Input } from '@datum-cloud/datum-ui/input'; import { Label } from '@datum-cloud/datum-ui/label'; @@ -69,7 +70,7 @@ export function InventoryToolbar({ section, search = '', onSearch, location = '' {(hasLocation || hasModel) && diff --git a/ui/provider/src/components/inventory-location.tsx b/ui/provider/src/components/inventory-location.tsx index 640aecc6..9e220a15 100644 --- a/ui/provider/src/components/inventory-location.tsx +++ b/ui/provider/src/components/inventory-location.tsx @@ -1,4 +1,5 @@ import { Button } from '@datum-cloud/datum-ui/button'; +import { ButtonGroup } from '@datum-cloud/datum-ui/button-group'; import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from '@datum-cloud/datum-ui/table'; import { Title } from '@datum-cloud/datum-ui/typography'; import { useState, type ReactNode } from 'react'; @@ -96,7 +97,7 @@ export function RackOverview({ rack, inventory, selection, toolbar }: { rack: Ph return
; diff --git a/ui/provider/src/components/inventory-navigation.tsx b/ui/provider/src/components/inventory-navigation.tsx index d9dfc3e2..14ebe578 100644 --- a/ui/provider/src/components/inventory-navigation.tsx +++ b/ui/provider/src/components/inventory-navigation.tsx @@ -1,5 +1,6 @@ import { Link, useLocation, useSearchParams } from 'react-router'; import { Button } from '@datum-cloud/datum-ui/button'; +import { ButtonGroup } from '@datum-cloud/datum-ui/button-group'; import { Popover, PopoverContent, PopoverTrigger } from '@datum-cloud/datum-ui/popover'; import { Box, Building2, Cable, Check, ChevronDown, ClipboardList, Factory, HardDrive, MapPin, Server, Zap } from 'lucide-react'; import { inventoryDirectoryPath, inventoryReturnSearch } from './inventory-page-title'; @@ -114,15 +115,17 @@ function CatalogNavigation({ counts }: { counts?: InventoryCounts }) { const { href, current } = useCategoryHref(active); return ; } diff --git a/ui/provider/src/components/physical-inventory.css b/ui/provider/src/components/physical-inventory.css index 9240cadb..273e6123 100644 --- a/ui/provider/src/components/physical-inventory.css +++ b/ui/provider/src/components/physical-inventory.css @@ -84,8 +84,6 @@ .inventory-rack-plan-far a { color:var(--muted-foreground); } .inventory-rack-plan-side { font-style:italic; } .inventory-rack-plan[data-depth="unknown"]:not(.inventory-rack-plan-far) { border-style:dotted; } -.inventory-face-switch { display:flex; gap:4px; } -.inventory-face-switch button { flex:none; } .inventory-equipment-sections { display:grid; gap:16px; min-width:0; } .inventory-equipment-sections section { display:grid; gap:10px; } .inventory-count { font-size:11px; color:var(--muted-foreground); font-weight:400; } @@ -123,8 +121,7 @@ .inventory-rack-header { display:grid; gap:6px; min-width:0; } .inventory-rack-summary { display:flex; flex-wrap:wrap; align-items:center; gap:4px 12px; } .inventory-rack-summary > span + span::before { content:"·"; margin-right:12px; color:var(--muted-foreground); } -.fleet-inventory a.inventory-issue-badge { display:inline-flex; align-items:center; min-height:24px; padding:0 8px; border:1px solid var(--destructive); border-radius:999px; font-size:12px; text-decoration:none; } -.fleet-inventory a.inventory-issue-badge[data-kind="unpositioned"] { border-style:dashed; border-color:var(--muted-foreground); } +.fleet-inventory a.inventory-issue-badge { display:inline-flex; text-decoration:none; } .inventory-rack-tabs [role="tablist"] { max-width:100%; overflow-x:auto; } .inventory-rack-tabs [role="tab"] { flex-shrink:0; } .fleet-inventory .inventory-rack-tabs a[role="tab"] { text-decoration:none; } @@ -599,10 +596,7 @@ /* BMC discovery on the Device page: red disagrees or failed, amber needs checking, OK is plain. */ .inventory-discovery-chips { display:flex; flex-wrap:wrap; gap:4px; margin:0; padding:0; list-style:none; } -.inventory-discovery-chip { display:inline-flex; align-items:center; gap:3px; padding:0 6px; border:1px solid var(--border); border-radius:4px; font-size:12px; line-height:20px; white-space:nowrap; } -.inventory-discovery-chip[data-tone="danger"] { border-color:var(--destructive); color:var(--destructive); font-weight:500; } -.inventory-discovery-chip[data-tone="warning"] { border-color:var(--warning,#d97706); } -.inventory-fact-strip .inventory-discovery-chip { line-height:18px; } +.inventory-discovery-chip { gap:3px; white-space:nowrap; } .inventory-discovery-mark[data-tone="danger"] { color:var(--destructive); font-weight:500; } .inventory-discovery-key { display:inline-flex; flex-wrap:wrap; align-items:baseline; gap:6px; min-width:0; } .inventory-copy { height:20px; padding:0 6px; font-size:11px; } @@ -638,11 +632,7 @@ .inventory-switcher-menu a[aria-current="page"] .inventory-tab-count { margin-left:auto; } .inventory-switcher-check { margin-left:6px; } -.inventory-catalog-toggle a { display:inline-flex; align-items:center; gap:6px; height:30px; padding:0 10px; border-radius:var(--radius); color:var(--foreground); font-size:14px; font-weight:400; text-decoration:none; white-space:nowrap; } -.inventory-catalog-toggle a:hover { background:var(--muted); color:var(--primary); } -.inventory-catalog-toggle a[aria-current="page"] { background:var(--muted); color:var(--primary); font-weight:500; } -.inventory-catalog-toggle a:focus-visible { outline:2px solid var(--ring); outline-offset:2px; } -.inventory-catalog-toggle svg { flex:none; } +.inventory-catalog-toggle a { gap:6px; text-decoration:none; white-space:nowrap; } /* The toolbar row: a card whose bottom edge joins the table. */ .inventory-list-frame .inventory-toolbar { flex-wrap:nowrap; gap:4px; min-height:44px; padding:0 8px 0 calc(var(--inventory-switcher-w, 0px) + 2px); border:1px solid var(--border); border-radius:var(--radius) var(--radius) 0 0; background:var(--card); } @@ -653,7 +643,8 @@ .inventory-list-frame .inventory-search input:focus-visible { outline:none; box-shadow:none; } .inventory-list-frame .inventory-search:focus-within { box-shadow:inset 0 -2px 0 var(--ring); } .inventory-list-frame .inventory-toolbar-actions { flex-wrap:nowrap; gap:4px; } -.inventory-filter-count { display:inline-block; min-width:18px; height:18px; margin-left:6px; padding:0 5px; border-radius:9px; background:var(--primary); color:var(--primary-foreground); font-size:11px; line-height:18px; text-align:center; } +.inventory-filter-count { margin-left:6px; padding:0 6px; font-variant-numeric:tabular-nums; } +.inventory-loading { display:flex; align-items:center; gap:8px; } .inventory-filter-panel { display:grid; gap:12px; width:min(280px,calc(100vw - 32px)); } .inventory-filter-panel .inventory-filter-field { display:grid; gap:6px; font-size:13px; } .inventory-filter-panel .field-select { width:100%; } @@ -683,7 +674,7 @@ @media(max-width:640px) { .inventory-list-frame > .inventory-sections { position:static; height:auto; margin-bottom:8px; padding:0; border:0; } .inventory-list-frame > .inventory-sections .inventory-switcher { border-color:var(--border); background:var(--card); } - .inventory-list-frame > .inventory-catalog-toggle { display:inline-flex; padding:4px; border:1px solid var(--border); border-radius:calc(var(--radius) + 2px); background:var(--card); } + .inventory-list-frame > .inventory-catalog-toggle { display:inline-flex; } .inventory-list-frame .inventory-toolbar { padding-left:0; } .inventory-list-frame .inventory-filter-label { display:none; } } @@ -718,7 +709,3 @@ .fleet-inventory .inventory-tab-row a[role="tab"]:hover,.fleet-inventory .inventory-tab-row a[role="tab"][data-state="active"] { color:var(--primary); } /* Rack face toggle: a segmented pill, like the host's ViewTabs. */ -.inventory-face-switch { display:inline-flex; flex-wrap:wrap; gap:2px; width:fit-content; max-width:100%; padding:3px; border-radius:calc(var(--radius) + 2px); background:color-mix(in oklab,var(--border) 50%,transparent); } -.inventory-face-switch button { flex:none; height:28px; padding:0 12px; border:0; border-radius:var(--radius); background:transparent; color:var(--foreground); font-weight:400; box-shadow:none; } -.inventory-face-switch button:hover { color:var(--primary); } -.inventory-face-switch button[aria-pressed="true"] { background:var(--card); color:var(--primary); font-weight:500; } diff --git a/ui/provider/src/components/rack-detail.tsx b/ui/provider/src/components/rack-detail.tsx index b65f25da..6cbb46c5 100644 --- a/ui/provider/src/components/rack-detail.tsx +++ b/ui/provider/src/components/rack-detail.tsx @@ -9,6 +9,7 @@ // fallback stays labelled; overlaps are flagged, never blocked; a denied // collection shows "unavailable" and names nothing from it. +import { Badge } from '@datum-cloud/datum-ui/badge'; import { Button } from '@datum-cloud/datum-ui/button'; import { X } from 'lucide-react'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@datum-cloud/datum-ui/table'; @@ -281,8 +282,8 @@ export function RackSummary({ rack, inventory }: { rack: PhysicalRecord; invento return {!facility ? 'Facility not recorded' : inventory.issues?.Facility ? 'Facility unavailable' : facilityRecord ? {displayLabel(facilityRecord)} : 'Facility record not found'} {rack.spec.heightUnits === undefined ? 'Height not recorded' : `${rack.spec.heightUnits}U`} - {overlaps > 0 && {overlaps} placements disagree} - {unpositioned > 0 && {unpositioned} without a position} + {overlaps > 0 && {overlaps} placements disagree} + {unpositioned > 0 && {unpositioned} without a position} ; } diff --git a/ui/provider/src/pages/inventory-create.tsx b/ui/provider/src/pages/inventory-create.tsx index f92ba23f..440c2dd1 100644 --- a/ui/provider/src/pages/inventory-create.tsx +++ b/ui/provider/src/pages/inventory-create.tsx @@ -1,3 +1,4 @@ +import { Spinner } from '@datum-cloud/datum-ui/spinner'; import { Link, useLocation, useNavigate, useParams } from 'react-router'; import { FleetPage } from '../components/fleet-page'; import { InventorySessionBoundary } from '../components/inventory-session-boundary'; @@ -30,7 +31,7 @@ export default function InventoryCreatePage() { function CreateContent({ kind, back }: { kind: ManagedKind; back: string }) { const { data, error, isLoading, refetch } = useInventory(); const navigate = useNavigate(); - if (isLoading) return

Loading inventory references…

; + if (isLoading) return

; if (error) return void refetch()} />; if (!data) return null; if (Object.values(data.issues ?? {}).some(issue => issue?.status === 401)) return ;