Skip to content

Commit

Permalink
make display more like API data
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Dec 18, 2024
1 parent d242c76 commit 8d2a713
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
19 changes: 9 additions & 10 deletions app/pages/system/inventory/SledsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ import {
type SledPolicy,
type SledState,
} from '@oxide/api'
import {
Checkmark12Icon,
Close12Icon,
Servers24Icon,
} from '@oxide/design-system/icons/react'
import { Servers24Icon } from '@oxide/design-system/icons/react'

import { EmptyCell } from '~/table/cells/EmptyCell'
import { makeLinkCell } from '~/table/cells/LinkCell'
import { useQueryTable } from '~/table/QueryTable'
import { Badge, type BadgeColor } from '~/ui/lib/Badge'
Expand Down Expand Up @@ -71,13 +68,15 @@ const staticCols = [
},
}),
colHelper.accessor('policy', {
header: 'Provisionable',
header: 'Provision policy',
cell: (info) => {
const policy: SledPolicy = info.getValue()
const yes = <Checkmark12Icon className="text-accent" aria-label="Yes" />
const no = <Close12Icon aria-label="No" />
if (policy.kind === 'expunged') return no
return policy.provisionPolicy === 'provisionable' ? yes : no
if (policy.kind === 'expunged') return <EmptyCell />
return policy.provisionPolicy === 'provisionable' ? (
<Badge>Provisionable</Badge>
) : (
<Badge color="neutral">Not provisionable</Badge>
)
},
}),
],
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/inventory.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ test('Sled inventory page', async ({ page }) => {
id: sleds[0].id,
'serial number': sleds[0].baseboard.serial,
Kind: 'In service',
// Provisionable: 'Yes',
'Provision policy': 'Provisionable',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[1].id,
'serial number': sleds[1].baseboard.serial,
Kind: 'In service',
// Provisionable: 'No',
'Provision policy': 'Not provisionable',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[2].id,
'serial number': sleds[2].baseboard.serial,
Kind: 'Expunged',
// Provisionable: 'No',
'Provision policy': '',
state: 'active',
})
await expectRowVisible(sledsTable, {
id: sleds[3].id,
'serial number': sleds[3].baseboard.serial,
Kind: 'Expunged',
// Provisionable: 'No',
'Provision policy': '',
state: 'decommissioned',
})

Expand Down

0 comments on commit 8d2a713

Please sign in to comment.