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
284 changes: 173 additions & 111 deletions docs/development/staff-inventory-ui.md

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions ui/provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,17 @@ to that array instead.

## Differences from the consumer plugin

Inventory uses four route-linked Datum underline groups: Equipment (Devices,
Cables, Power feeds), Locations (Operational sites, Facilities, Racks), Installation
plans, and Hardware catalog (Manufacturers, Device types). Only the selected
group's secondary navigation is shown. Installation plans opens the existing
Claims & registrations directory; plans do not allocate capacity. Site membership and
Facility premises remain distinct. The default is Equipment / Devices.
Search/filter/refresh/Create stay in the page toolbar. Existing query bookmarks,
detail and task routes work with group/category breadcrumbs; Back/Forward restores
filters. Static navigation survives access checks and denial without exposing
protected names or counts. Rows scroll horizontally on small screens, with
keyboard-focus navigation and Enter/Space link activation. See the
[implemented navigation and safety boundaries](../../docs/development/staff-inventory-ui.md#grouped-inventory-navigation-implemented).
Inventory and Catalog list pages follow staff-portal's list style: one toolbar
row (a category switcher grouped by Equipment, Locations and Installation plans,
or on Catalog a Manufacturers / Device types toggle; then search, Filter,
Refresh and Create) on top of a compact sortable datum-ui data table with a
rows-per-page footer. Each category shows its count once access resolves.
Installation plans do not allocate capacity, and Site membership and Facility
premises remain distinct. Devices is the Inventory default. Existing query
bookmarks and detail and task routes keep working, including old Manufacturer
and Device type links, which redirect to Catalog; Back and Forward restore
filters. See the
[implemented navigation](../../docs/development/staff-inventory-ui.md#inventory-and-catalog-navigation-implemented).

The Inventory tab loads all six physical inventory collections with API pagination.
Counts describe loaded records, not capacity or verified equipment. Unknown
Expand Down
10 changes: 9 additions & 1 deletion ui/provider/public/plugin-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"MachineProfileList": "./src/pages/machine-profile-list.tsx",
"MachineClassList": "./src/pages/machine-class-list.tsx",
"DeviceInventoryList": "./src/pages/device-inventory-list.tsx",
"InventoryCreatePage": "./src/pages/inventory-create.tsx"
"InventoryCreatePage": "./src/pages/inventory-create.tsx",
"HardwareCatalog": "./src/pages/hardware-catalog.tsx"
},
"extensions": [
{
Expand Down Expand Up @@ -54,6 +55,13 @@
"path": "inventory/create/:kind",
"component": { "$codeRef": "InventoryCreatePage" }
}
},
{
"type": "portal.page/platform",
"properties": {
"path": "catalog",
"component": { "$codeRef": "HardwareCatalog" }
}
}
]
}
17 changes: 9 additions & 8 deletions ui/provider/scripts/screenshot-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const record = (kind: string, name: string, extra = '') => `${INVENTORY}?kind=${

export const PAGES: CapturePage[] = [
{ name: 'inventory-list', path: INVENTORY, ready: '[data-testid="fleet-plugin-inventory-list"] table' },
{ name: 'catalog-list', path: '/plugins/metal-datumapis-com/catalog', ready: '[data-testid="fleet-plugin-catalog"] table' },
{ name: 'capacity-list', path: '/plugins/metal-datumapis-com', ready: '[data-testid="fleet-plugin-capacity-table"] table' },
{ name: 'capacity-pool', path: '/plugins/metal-datumapis-com?namespace=fleet-provider&pool=central-metal', ready: '[data-testid="fleet-plugin-capacity-filter"]', viewports: ['desktop-light'] },
{ name: 'profile-list', path: '/plugins/metal-datumapis-com/profiles', ready: '[data-testid="fleet-plugin-profile-table"] table' },
Expand Down Expand Up @@ -86,24 +87,24 @@ export const PAGES: CapturePage[] = [
// A Cable whose ends land on opposite rack faces carries a check note, shown in the port's card.
{ name: 'opposite-face-check', path: record('Device', 'example-app-a01'), ready: '.inventory-port-grid', click: tile('net0') },
// Detail and list pages for each kind, for page-design review.
{ name: 'cable-detail', path: record('Cable', 'example-brk-swp49'), ready: '.inventory-page-title' },
{ name: 'cable-detail', path: record('Cable', 'example-brk-swp49'), ready: '.inventory-entity-header' },
// A one-lane Cable is one line; a duplicate's shared end is red.
{ name: 'cable-detail-dac', path: record('Cable', 'example-dac-a01-01-eth0'), ready: '.inventory-cable-line' },
{ name: 'cable-detail-conflict', path: record('Cable', 'example-dac-a01-01-eth1-dup'), ready: '.inventory-cable-line' },
{ name: 'power-feed-detail', path: record('PowerFeed', 'example-feed-a'), ready: '.inventory-page-title' },
{ name: 'facility-detail', path: record('Facility', 'example-dc1'), ready: '.inventory-page-title' },
{ name: 'site-detail', path: record('Site', 'example-site-one'), ready: '.inventory-page-title' },
{ name: 'device-type-detail', path: record('DeviceType', 'example-server-1u'), ready: '.inventory-page-title' },
{ name: 'manufacturer-detail', path: record('Manufacturer', 'example-compute'), ready: '.inventory-page-title' },
{ name: 'power-feed-detail', path: record('PowerFeed', 'example-feed-a'), ready: '.inventory-entity-header' },
{ name: 'facility-detail', path: record('Facility', 'example-dc1'), ready: '.inventory-entity-header' },
{ name: 'site-detail', path: record('Site', 'example-site-one'), ready: '.inventory-entity-header' },
{ name: 'device-type-detail', path: record('DeviceType', 'example-server-1u'), ready: '.inventory-entity-header' },
{ name: 'manufacturer-detail', path: record('Manufacturer', 'example-compute'), ready: '.inventory-entity-header' },
{ name: 'site-devices', path: record('Site', 'example-site-one', '&tab=devices'), ready: '[data-tab="devices"] table' },
{ name: 'site-plans', path: record('Site', 'example-site-one', '&tab=plans'), ready: '[data-tab="plans"] table' },
{ name: 'facility-unracked', path: record('Facility', 'example-dc1', '&tab=unracked'), ready: '[data-tab="unracked"] table' },
{ name: 'facility-feeds', path: record('Facility', 'example-dc1', '&tab=feeds'), ready: '[data-tab="feeds"] table' },
{ name: 'facility-cables', path: record('Facility', 'example-dc1', '&tab=cables'), ready: '[data-tab="cables"] table' },
{ name: 'device-type-leaf', path: record('DeviceType', 'example-leaf-48x25-8x100'), ready: '.inventory-drawing' },
{ name: 'device-type-pdu', path: record('DeviceType', 'example-pdu-8'), ready: '.inventory-page-title' },
{ name: 'device-type-pdu', path: record('DeviceType', 'example-pdu-8'), ready: '.inventory-entity-header' },
{ name: 'manufacturer-devices', path: record('Manufacturer', 'example-compute', '&tab=devices'), ready: '[data-tab="devices"] table' },
{ name: 'claim-detail', path: record('DeviceClaim', 'example-srv-a01-01-install'), ready: '.inventory-page-title' },
{ name: 'claim-detail', path: record('DeviceClaim', 'example-srv-a01-01-install'), ready: '.inventory-entity-header' },
{ name: 'devices-list', path: `${INVENTORY}?kind=Device`, ready: '[data-testid="fleet-plugin-inventory-table"]' },
{ name: 'cables-list', path: `${INVENTORY}?kind=Cable`, ready: '[data-testid="fleet-plugin-inventory-table"]' },
{ name: 'racks-list', path: `${INVENTORY}?kind=Rack`, ready: '[data-testid="fleet-plugin-inventory-table"]' },
Expand Down
25 changes: 22 additions & 3 deletions ui/provider/src/components/adversarial-review.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { InventorySessionBoundary } from './inventory-session-boundary';
import DeviceInventoryList from '../pages/device-inventory-list';
import { inventoryPayload, INVENTORY_FIELD_MANAGER } from '../lib/inventory-management';
import { focusManager } from '@tanstack/react-query';
import { useContext } from 'react';
import { InventoryOperationContext, type InventoryOperationScope } from '../lib/inventory-operation';

const values = { name: 'review-facility', namespace: 'default', displayName: 'Original label', facility: '', height: '' };
const original = { ...inventoryPayload('Facility', values), metadata: { name: values.name, namespace: 'default', uid: 'synthetic-only', resourceVersion: '1', managedFields: [{ manager: INVENTORY_FIELD_MANAGER }] } };
Expand Down Expand Up @@ -138,16 +140,33 @@ it('must not silently advance an open edit form to a refreshed resourceVersion',
expect(patches).toEqual([]);
});

it('must keep inventory concealed if foreground verification finishes after another pagehide', async () => {
// Restored from "must keep inventory concealed if foreground verification
// finishes after another pagehide". The page is no longer concealed during a
// check; the risk it guarded is that a check answered for an earlier return
// lets work through after the page has gone away again. It must not.
it('must keep work held if a return check finishes after another pagehide', async () => {
let release: (() => void) | undefined;
let count = 0;
const router = createMemoryRouter([{ id: 'layouts/milo.layout', path: '/', loader: async () => { if (++count === 2) await new Promise<void>(resolve => { release = resolve; }); return { user: { metadata: { uid: 'staff-a' } } }; }, element: <Outlet />, children: [{ index: true, element: <InventorySessionBoundary>Private inventory label</InventorySessionBoundary> }] }]);
let scope: InventoryOperationScope | undefined;
function Private() { scope = useContext(InventoryOperationContext); return <p>Private inventory label</p>; }
const router = createMemoryRouter([{ id: 'layouts/milo.layout', path: '/', loader: async () => { if (++count === 2) await new Promise<void>(resolve => { release = resolve; }); return { user: { metadata: { uid: 'staff-a' } } }; }, element: <Outlet />, children: [{ index: true, element: <InventorySessionBoundary><Private /></InventorySessionBoundary> }] }]);
render(<RouterProvider router={router} />);
await screen.findByText('Private inventory label');
fireEvent(window, new Event('pagehide'));
fireEvent(window, new Event('pageshow'));
await waitFor(() => expect(release).toBeDefined());
fireEvent(window, new Event('pagehide'));
const operation = scope!.begin();
let settled = false;
void operation.settle().then(() => { settled = true; });
await act(async () => { release!(); });
expect(screen.queryByText('Private inventory label')).not.toBeInTheDocument();
await waitFor(() => expect(router.state.revalidation).toBe('idle'));
expect(scope!.held).toBe(true);
expect(settled).toBe(false);
// The next return checks again, and only then does the work go on.
fireEvent(window, new Event('pageshow'));
await waitFor(() => expect(settled).toBe(true));
expect(count).toBe(3);
expect(screen.getByText('Private inventory label')).toBeInTheDocument();
router.dispose();
});
9 changes: 5 additions & 4 deletions ui/provider/src/components/connections-power-pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ describe('Installation plan page', () => {
expect(screen.queryByText('No cable references recorded.')).toBeNull();
});

it('names the directory once in the breadcrumb, as Installation plans', () => {
it('names the directory once, in the back link, as Installation plans', () => {
show(PLAN);
const crumbs = document.querySelector('nav[aria-label="breadcrumb"]')!;
expect(crumbs.textContent?.match(/Installation plans/g)).toHaveLength(1);
expect(crumbs).not.toHaveTextContent(/Claims & registrations/);
const back = document.querySelector('.inventory-back-link')!;
expect(back).toHaveTextContent(/^Installation plans$/);
expect(document.querySelector('nav[aria-label="breadcrumb"]')).toBeNull();
expect(document.body).not.toHaveTextContent(/Claims & registrations/);
});

it('links the expected hardware to its model, and marks a registered device reporting another model in red', () => {
Expand Down
4 changes: 2 additions & 2 deletions ui/provider/src/components/device-placement-edit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('reported location editor', () => {
expect(screen.queryByDisplayValue('rack')).not.toBeInTheDocument();
expect(fetch).toHaveBeenCalledTimes(3);
});
it.each(['session', 'hidden', 'unmount', 'revalidation'])('revokes a delayed permission read on %s', async event => {
it.each(['session', 'unmount', 'revalidation'])('revokes a delayed permission read on %s', async event => {
let resolve!: (value: unknown) => void;
const fetch = vi.fn().mockImplementationOnce(() => new Promise(done => { resolve = done; }));
vi.stubGlobal('fetch', fetch);
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('reported location editor', () => {
expect(screen.getByRole('button', { name: 'Save changes' })).toBeDisabled();
expect(fetch).not.toHaveBeenCalled();
});
it.each(['session', 'navigation', 'pagehide/pageshow'])('revokes a delayed reference read across %s', async event => {
it.each(['session', 'navigation'])('revokes a delayed reference read across %s', async event => {
let resolve!: (value: unknown) => void;
const fetch = vi.fn().mockResolvedValueOnce(response({ status: { allowed: true } })).mockResolvedValueOnce(response(device)).mockImplementationOnce(() => new Promise(done => { resolve = done; }));
vi.stubGlobal('fetch', fetch);
Expand Down
11 changes: 2 additions & 9 deletions ui/provider/src/components/device-placement-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,8 @@ function DevicePlacementForm({ device, locations, issues }: { device: Device; lo
return { ...previous, rack, facility: facility && visible.some(record => record.kind === 'Facility' && record.metadata.name === facility) ? facility : previous.facility };
});
useLayoutEffect(() => {
const invalidate = () => { scope.current.invalidate(); setBlocked(true); setBaseline(undefined); };
const visibility = () => { if (document.visibilityState === 'hidden') invalidate(); };
window.addEventListener('pagehide', invalidate);
document.addEventListener('visibilitychange', visibility);
return () => {
scope.current.invalidate();
window.removeEventListener('pagehide', invalidate);
document.removeEventListener('visibilitychange', visibility);
};
// Hiding the tab is not a session boundary; unmounting ends the operation.
return () => { scope.current.invalidate(); };
}, []);
useLayoutEffect(() => {
scope.current.invalidate();
Expand Down
Loading
Loading