@@ -16,32 +16,18 @@ import {
16
16
} from '@oxide/api'
17
17
import { Servers24Icon } from '@oxide/design-system/icons/react'
18
18
19
+ import { EmptyCell } from '~/table/cells/EmptyCell'
19
20
import { makeLinkCell } from '~/table/cells/LinkCell'
20
21
import { useQueryTable } from '~/table/QueryTable'
21
22
import { Badge , type BadgeColor } from '~/ui/lib/Badge'
22
23
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
23
24
import { pb } from '~/util/path-builder'
24
25
25
- const POLICY_KIND_BADGE_COLORS : Record < SledPolicy [ 'kind' ] , BadgeColor > = {
26
- in_service : 'default' ,
27
- expunged : 'neutral' ,
28
- }
29
-
30
26
const STATE_BADGE_COLORS : Record < SledState , BadgeColor > = {
31
27
active : 'default' ,
32
28
decommissioned : 'neutral' ,
33
29
}
34
30
35
- const EmptyState = ( ) => {
36
- return (
37
- < EmptyMessage
38
- icon = { < Servers24Icon /> }
39
- title = "Something went wrong"
40
- body = "We expected some racks here, but none were found"
41
- />
42
- )
43
- }
44
-
45
31
const sledList = getListQFn ( 'sledList' , { } )
46
32
47
33
export async function loader ( ) {
@@ -55,16 +41,45 @@ const staticCols = [
55
41
cell : makeLinkCell ( ( sledId ) => pb . sled ( { sledId } ) ) ,
56
42
} ) ,
57
43
// TODO: colHelper.accessor('baseboard.serviceAddress', { header: 'service address' }),
58
- colHelper . accessor ( 'baseboard.part' , { header : 'part number' } ) ,
59
- colHelper . accessor ( 'baseboard.serial' , { header : 'serial number' } ) ,
60
- colHelper . accessor ( 'baseboard.revision' , { header : 'revision' } ) ,
61
- colHelper . accessor ( 'policy.kind' , {
62
- header : 'policy' ,
63
- cell : ( info ) => (
64
- < Badge color = { POLICY_KIND_BADGE_COLORS [ info . getValue ( ) ] } >
65
- { info . getValue ( ) . replace ( / _ / g, ' ' ) }
66
- </ Badge >
67
- ) ,
44
+ colHelper . group ( {
45
+ id : 'baseboard' ,
46
+ header : 'Baseboard' ,
47
+ columns : [
48
+ colHelper . accessor ( 'baseboard.part' , { header : 'part number' } ) ,
49
+ colHelper . accessor ( 'baseboard.serial' , { header : 'serial number' } ) ,
50
+ colHelper . accessor ( 'baseboard.revision' , { header : 'revision' } ) ,
51
+ ] ,
52
+ } ) ,
53
+ colHelper . group ( {
54
+ id : 'policy' ,
55
+ header : 'Policy' ,
56
+ columns : [
57
+ colHelper . accessor ( 'policy' , {
58
+ header : 'Kind' ,
59
+ cell : ( info ) => {
60
+ // need to cast because inference is broken inside groups
61
+ // https://github.com/TanStack/table/issues/5065
62
+ const policy : SledPolicy = info . getValue ( )
63
+ return policy . kind === 'expunged' ? (
64
+ < Badge color = "neutral" > Expunged</ Badge >
65
+ ) : (
66
+ < Badge > In service</ Badge >
67
+ )
68
+ } ,
69
+ } ) ,
70
+ colHelper . accessor ( 'policy' , {
71
+ header : 'Provision policy' ,
72
+ cell : ( info ) => {
73
+ const policy : SledPolicy = info . getValue ( )
74
+ if ( policy . kind === 'expunged' ) return < EmptyCell />
75
+ return policy . provisionPolicy === 'provisionable' ? (
76
+ < Badge > Provisionable</ Badge >
77
+ ) : (
78
+ < Badge color = "neutral" > Not provisionable</ Badge >
79
+ )
80
+ } ,
81
+ } ) ,
82
+ ] ,
68
83
} ) ,
69
84
colHelper . accessor ( 'state' , {
70
85
cell : ( info ) => (
@@ -75,7 +90,7 @@ const staticCols = [
75
90
76
91
Component . displayName = 'SledsTab'
77
92
export function Component ( ) {
78
- const emptyState = < EmptyState />
93
+ const emptyState = < EmptyMessage icon = { < Servers24Icon /> } title = "No sleds found" />
79
94
const { table } = useQueryTable ( { query : sledList , columns : staticCols , emptyState } )
80
95
return table
81
96
}
0 commit comments