Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/provider/src/components/create-capacity-dialog.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}` : ''}` };
})} /></Label>
{devices.isPending && <p>Loading Devices…</p>}
{devices.isPending && <p role="status" className="inventory-loading"><Spinner aria-hidden="true" />Loading Devices…</p>}
{devices.error && <p role="alert">Devices are unavailable or access is denied. Registration is blocked.</p>}
{devices.data?.length === 0 && <p>No Devices are available in default.</p>}
{selected && <p title={`Derived from the Device, so it can back only one capacity. The reference to ${selected.metadata.name} and its exact version are kept; the selection is never refreshed.`}>Capacity name: <code>{capacityNameFor(selected)}</code></p>}
Expand Down
3 changes: 2 additions & 1 deletion ui/provider/src/components/device-discovery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>('.inventory-fact-strip')!;

Expand Down
12 changes: 9 additions & 3 deletions ui/provider/src/components/device-discovery.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,22 +21,27 @@ function Marked({ tone, reason, children }: { tone: Tone; reason?: string; child
</span>;
}

/** 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 <div><dt className="inventory-visually-hidden">BMC</dt><dd>
<span className="inventory-discovery-chip" data-tone={chip.tone} title={chip.reason}>{chip.label}<span className="inventory-visually-hidden">. {chip.reason}</span></span>
<Badge {...chipBadge(chip.tone)} className="inventory-discovery-chip" data-tone={chip.tone} title={chip.reason}>{chip.label}<span className="inventory-visually-hidden">. {chip.reason}</span></Badge>
</dd></div>;
}

/** The five conditions as one line of chips; the reason and message are each chip's tooltip. */
export function ConditionChips({ device }: { device: Device }) {
return <ul className="inventory-discovery-chips" aria-label="Discovery conditions">
{conditionChips(device).map(chip => <li key={chip.type} className="inventory-discovery-chip" data-tone={chip.tone} data-status={chip.status} title={chip.reason}>
{conditionChips(device).map(chip => <li key={chip.type}><Badge {...chipBadge(chip.tone)} className="inventory-discovery-chip" data-tone={chip.tone} data-status={chip.status} title={chip.reason}>
<span aria-hidden="true">{chip.status === 'False' ? '✕ ' : chip.status === 'Unknown' ? '? ' : ''}</span>{chip.word}
<span className="inventory-visually-hidden">. {chip.reason}</span>
</li>)}
</Badge></li>)}
</ul>;
}

Expand Down
7 changes: 5 additions & 2 deletions ui/provider/src/components/device-power.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// operation in the header strip, the Power control in the header actions, and
// the Operations tab. See "Device page: power" in
// docs/development/staff-inventory-ui.md.
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';
Expand All @@ -26,10 +27,12 @@ const HOUR = 3_600_000;
/** A phase badge: the reason and any recovery hold are its tooltip and accessible text. */
export function PowerOutcomeBadge({ outcome, prefix }: { outcome: PowerOutcome; prefix?: string }) {
const note = [outcome.reason, outcome.hold].filter(Boolean).join('\n') || undefined;
return <span className="inventory-discovery-chip inventory-power-outcome" data-tone={outcome.tone} title={note}>
// Red failed or unknown, amber cancelled, blue dashed in progress, plain outline when it succeeded.
const tone = outcome.tone === 'progress' ? { type: 'info', theme: 'outline' } as const : outcome.tone ? { type: outcome.tone, theme: 'light' } as const : { type: 'secondary', theme: 'outline' } as const;
return <Badge {...tone} className="inventory-discovery-chip inventory-power-outcome" data-tone={outcome.tone} title={note}>
{prefix && <>{prefix} · </>}{outcome.label}{outcome.hold && <span aria-hidden="true"> · held</span>}
{note && <span className="inventory-visually-hidden">. {note}</span>}
</span>;
</Badge>;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -69,7 +70,7 @@ export function InventoryToolbar({ section, search = '', onSearch, location = ''
{(hasLocation || hasModel) && <Popover>
<PopoverTrigger asChild>
<Button type="secondary" theme="borderless" size="small" htmlType="button" disabled={!onLocation && !onModel} aria-label={active ? `Filter, ${active} active` : 'Filter'} icon={<SlidersHorizontal size={16} aria-hidden="true" />}>
<span className="inventory-filter-label">Filter</span>{active > 0 && <span className="inventory-filter-count" aria-hidden="true">{active}</span>}
<span className="inventory-filter-label">Filter</span>{active > 0 && <Badge type="primary" theme="solid" className="inventory-filter-count" aria-hidden="true">{active}</Badge>}
</Button>
</PopoverTrigger>
<PopoverContent align="end" className="inventory-filter-panel" aria-label={`Filter ${section.title.toLowerCase()}`}>
Expand Down
3 changes: 2 additions & 1 deletion ui/provider/src/components/inventory-location.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -96,7 +97,7 @@ export function RackOverview({ rack, inventory, selection, toolbar }: { rack: Ph
return <section className="inventory-rack-layout" aria-label="Rack layout">
<aside className="inventory-elevation">
<div className="inventory-list-heading"><Title as="h3" level={5}>Rack elevation</Title><span>{height ? `${height}U` : 'Height unknown'}</span></div>
<div className="inventory-elevation-toolbar"><div className="inventory-face-switch" role="group" aria-label="Rack faces">{(['both', 'front', 'rear'] as const).map(value => <Button type="secondary" theme="borderless" size="small" key={value} htmlType="button" aria-pressed={face === value} onClick={() => setFace(value)}>{value === 'both' ? 'Front + rear' : value === 'front' ? 'Front' : 'Rear'}</Button>)}</div>{toolbar}</div>
<div className="inventory-elevation-toolbar"><ButtonGroup className="inventory-face-switch" aria-label="Rack faces">{(['both', 'front', 'rear'] as const).map(value => <Button type={face === value ? 'primary' : 'secondary'} theme={face === value ? 'light' : 'outline'} size="small" key={value} htmlType="button" aria-pressed={face === value} onClick={() => setFace(value)}>{value === 'both' ? 'Front + rear' : value === 'front' ? 'Front' : 'Rear'}</Button>)}</ButtonGroup>{toolbar}</div>
{denied ? <p>Installation details unavailable. Rack positions cannot be shown.</p> : !height ? <p>Rack height is not recorded. Equipment remains listed without invented slots.</p> : <div className="inventory-rack-faces">{(['front', 'rear'] as const).filter(value => face === 'both' || face === value).map(side => <RackFace key={side} occupants={occupants} height={height} side={side} selection={selection} inventory={inventory} unit={UNIT_PX} />)}</div>}
</aside>
</section>;
Expand Down
15 changes: 9 additions & 6 deletions ui/provider/src/components/inventory-navigation.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -114,15 +115,17 @@ function CatalogNavigation({ counts }: { counts?: InventoryCounts }) {
const { href, current } = useCategoryHref(active);
return <nav ref={nav} className="inventory-sections inventory-catalog-toggle" aria-label="Catalog categories">
{CATALOG_KINDS.map(kind => <CountWords key={`words-${kind}`} id={`${countID}-${kind}`} count={counts?.[kind]} />)}
{CATALOG_KINDS.map(kind => {
<ButtonGroup>{CATALOG_KINDS.map(kind => {
const section = sections.find(item => item.kind === kind)!;
const Icon = section.icon;
const target = href(kind);
return <Link key={kind} to={target} aria-current={kind === active ? 'page' : undefined} aria-describedby={counts?.[kind] ? `${countID}-${kind}` : undefined}
onClick={event => { if (target === current) event.preventDefault(); }}>
<Icon size={16} aria-hidden="true" />{section.title}<CountMark count={counts?.[kind]} />
</Link>;
})}
return <Button key={kind} asChild type={kind === active ? 'primary' : 'secondary'} theme={kind === active ? 'light' : 'outline'} size="small">
<Link to={target} aria-current={kind === active ? 'page' : undefined} aria-describedby={counts?.[kind] ? `${countID}-${kind}` : undefined}
onClick={event => { if (target === current) event.preventDefault(); }}>
<Icon size={16} aria-hidden="true" />{section.title}<CountMark count={counts?.[kind]} />
</Link>
</Button>;
})}</ButtonGroup>
</nav>;
}

Expand Down
27 changes: 6 additions & 21 deletions ui/provider/src/components/physical-inventory.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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); }
Expand All @@ -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%; }
Expand Down Expand Up @@ -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; }
}
Expand Down Expand Up @@ -717,12 +708,6 @@
.fleet-inventory .inventory-tab-row a[role="tab"] { color:var(--foreground); text-decoration:none; }
.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; }

/* Device power: the header control, its outcome badge and the Operations tab. */
.inventory-title-actions .inventory-power-control { display:contents; }
.inventory-title-actions .inventory-power-control .inventory-management-controls { flex-shrink:0; }
Expand Down
5 changes: 3 additions & 2 deletions ui/provider/src/components/rack-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -281,8 +282,8 @@ export function RackSummary({ rack, inventory }: { rack: PhysicalRecord; invento
return <span className="inventory-rack-summary">
<span>{!facility ? 'Facility not recorded' : inventory.issues?.Facility ? 'Facility unavailable' : facilityRecord ? <Link to={inventoryHref('Facility', rack.metadata.namespace, facility)}>{displayLabel(facilityRecord)}</Link> : 'Facility record not found'}</span>
<span>{rack.spec.heightUnits === undefined ? 'Height not recorded' : `${rack.spec.heightUnits}U`}</span>
{overlaps > 0 && <Link className="inventory-issue-badge" data-kind="overlap" to={elevationHref}><span aria-hidden="true">! </span>{overlaps} placements disagree</Link>}
{unpositioned > 0 && <Link className="inventory-issue-badge" data-kind="unpositioned" to={elevationHref}><span aria-hidden="true">? </span>{unpositioned} without a position</Link>}
{overlaps > 0 && <Link className="inventory-issue-badge" data-kind="overlap" to={elevationHref}><Badge type="danger" theme="light"><span aria-hidden="true">! </span>{overlaps} placements disagree</Badge></Link>}
{unpositioned > 0 && <Link className="inventory-issue-badge" data-kind="unpositioned" to={elevationHref}><Badge type="warning" theme="light"><span aria-hidden="true">? </span>{unpositioned} without a position</Badge></Link>}
</span>;
}

Expand Down
Loading
Loading