@@ -10,11 +10,16 @@ import { createColumnHelper } from '@tanstack/react-table'
1010import {
1111 getListQFn ,
1212 queryClient ,
13+ SledPolicy ,
1314 type Sled ,
1415 type SledProvisionPolicy ,
1516 type SledState ,
1617} from '@oxide/api'
17- import { Servers24Icon } from '@oxide/design-system/icons/react'
18+ import {
19+ Checkmark12Icon ,
20+ Close12Icon ,
21+ Servers24Icon ,
22+ } from '@oxide/design-system/icons/react'
1823
1924import { makeLinkCell } from '~/table/cells/LinkCell'
2025import { useQueryTable } from '~/table/QueryTable'
@@ -45,24 +50,45 @@ const staticCols = [
4550 cell : makeLinkCell ( ( sledId ) => pb . sled ( { sledId } ) ) ,
4651 } ) ,
4752 // TODO: colHelper.accessor('baseboard.serviceAddress', { header: 'service address' }),
48- colHelper . accessor ( 'baseboard.part' , { header : 'part number' } ) ,
49- colHelper . accessor ( 'baseboard.serial' , { header : 'serial number' } ) ,
50- colHelper . accessor ( 'baseboard.revision' , { header : 'revision' } ) ,
51- colHelper . accessor ( 'policy' , {
52- header : 'policy' ,
53- cell : ( info ) => {
54- const policy = info . getValue ( )
55- if ( policy . kind === 'expunged' ) return < Badge color = "neutral" > Expunged</ Badge >
56- const [ label , color ] = PROV_POLICY_DISP [ policy . provisionPolicy ]
57- return (
58- < div className = "space-x-0.5" >
59- < Badge > In service</ Badge >
60- < Badge variant = "solid" color = { color } >
61- { label }
62- </ Badge >
63- </ div >
64- )
65- } ,
53+ colHelper . group ( {
54+ id : 'baseboard' ,
55+ header : 'Baseboard' ,
56+ columns : [
57+ colHelper . accessor ( 'baseboard.part' , { header : 'part number' } ) ,
58+ colHelper . accessor ( 'baseboard.serial' , { header : 'serial number' } ) ,
59+ colHelper . accessor ( 'baseboard.revision' , { header : 'revision' } ) ,
60+ ] ,
61+ } ) ,
62+ colHelper . group ( {
63+ id : 'policy' ,
64+ header : 'Policy' ,
65+ columns : [
66+ colHelper . accessor ( 'policy' , {
67+ header : 'Kind' ,
68+ cell : ( info ) => {
69+ // need to cast because inference is broken inside groups
70+ // https://github.com/TanStack/table/issues/5065
71+ const policy : SledPolicy = info . getValue ( )
72+ return policy . kind === 'expunged' ? (
73+ < Badge color = "neutral" > Expunged</ Badge >
74+ ) : (
75+ < Badge > In service</ Badge >
76+ )
77+ } ,
78+ } ) ,
79+ colHelper . accessor ( 'policy' , {
80+ header : 'Provisionable' ,
81+ cell : ( info ) => {
82+ const policy : SledPolicy = info . getValue ( )
83+ if ( policy . kind === 'expunged' ) return < Close12Icon />
84+ return policy . provisionPolicy === 'provisionable' ? (
85+ < Checkmark12Icon className = "text-accent" />
86+ ) : (
87+ < Close12Icon />
88+ )
89+ } ,
90+ } ) ,
91+ ] ,
6692 } ) ,
6793 colHelper . accessor ( 'state' , {
6894 cell : ( info ) => (
0 commit comments