Skip to content

Commit e2b0a7d

Browse files
authored
Add state and policy columns to physical disks table (#2151)
* add more data to disks table * add decommissioned disk to list * use neutral color for decommissioned / expunged badges * reorder columns * update test to include new policy and state columns * more efficient expectations
1 parent a5af899 commit e2b0a7d

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

app/pages/system/inventory/DisksTab.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ const staticCols = [
3636
}),
3737
colHelper.accessor('model', { header: 'model number' }),
3838
colHelper.accessor('serial', { header: 'serial number' }),
39+
colHelper.accessor('policy', {
40+
cell: (info) => {
41+
const policy = info.getValue().kind
42+
const color = policy === 'in_service' ? 'default' : 'neutral'
43+
return <Badge color={color}>{policy.replace(/_/g, ' ')}</Badge>
44+
},
45+
}),
46+
colHelper.accessor('state', {
47+
cell: (info) => {
48+
const state = info.getValue()
49+
const color = state === 'active' ? 'default' : 'neutral'
50+
return <Badge color={color}>{state}</Badge>
51+
},
52+
}),
3953
]
4054

4155
export function DisksTab() {

mock-api/physical-disk.ts

+16
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,20 @@ export const physicalDisks: Json<PhysicalDisk>[] = [
4444
form_factor: 'm2',
4545
serial: 'CA73ANUYLJ9',
4646
},
47+
{
48+
...base,
49+
id: '3a9f895a-e0da-4a1e-abf2-ce431d6c4c2e',
50+
form_factor: 'm2',
51+
serial: '7C15PW5D9N2',
52+
policy: { kind: 'expunged' as const },
53+
state: 'active' as const,
54+
},
55+
{
56+
...base,
57+
id: 'ba1c3581-b35b-48a5-924a-cb19921dca54',
58+
form_factor: 'm2',
59+
serial: 'F02106C3R2A',
60+
policy: { kind: 'expunged' as const },
61+
state: 'decommissioned' as const,
62+
},
4763
]

test/e2e/inventory.e2e.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,20 @@ test('Disk inventory page', async ({ page }) => {
4646

4747
const table = page.getByRole('table')
4848
await expectRowVisible(table, { id: physicalDisks[0].id, 'Form factor': 'U.2' })
49-
await expectRowVisible(table, { id: physicalDisks[3].id, 'Form factor': 'M.2' })
49+
await expectRowVisible(table, {
50+
id: physicalDisks[3].id,
51+
'Form factor': 'M.2',
52+
policy: 'in service',
53+
state: 'active',
54+
})
55+
await expectRowVisible(table, {
56+
id: physicalDisks[4].id,
57+
policy: 'expunged',
58+
state: 'active',
59+
})
60+
await expectRowVisible(table, {
61+
id: physicalDisks[5].id,
62+
policy: 'expunged',
63+
state: 'decommissioned',
64+
})
5065
})

0 commit comments

Comments
 (0)