7
7
*/
8
8
import { createColumnHelper } from '@tanstack/react-table'
9
9
10
- import {
11
- getListQFn ,
12
- queryClient ,
13
- type Sled ,
14
- type SledPolicy ,
15
- type SledState ,
16
- } from '@oxide/api'
10
+ import { getListQFn , queryClient , type Sled } from '@oxide/api'
17
11
import { Servers24Icon } from '@oxide/design-system/icons/react'
18
12
19
- import { EmptyCell } from '~/table/cells/EmptyCell'
20
13
import { makeLinkCell } from '~/table/cells/LinkCell'
21
14
import { useQueryTable } from '~/table/QueryTable'
22
- import { Badge , type BadgeColor } from '~/ui/lib/Badge'
23
15
import { EmptyMessage } from '~/ui/lib/EmptyMessage'
24
16
import { pb } from '~/util/path-builder'
25
17
26
- const STATE_BADGE_COLORS : Record < SledState , BadgeColor > = {
27
- active : 'default' ,
28
- decommissioned : 'neutral' ,
29
- }
18
+ import { ProvisionPolicyBadge , SledKindBadge , SledStateBadge } from './sled/SledBadges'
30
19
31
20
const sledList = getListQFn ( 'sledList' , { } )
32
21
33
22
export async function clientLoader ( ) {
34
- await queryClient . prefetchQuery ( sledList . optionsFn ( ) )
23
+ await queryClient . fetchQuery ( sledList . optionsFn ( ) )
35
24
return null
36
25
}
37
26
@@ -58,35 +47,16 @@ const staticCols = [
58
47
columns : [
59
48
colHelper . accessor ( 'policy' , {
60
49
header : 'Kind' ,
61
- cell : ( info ) => {
62
- // need to cast because inference is broken inside groups
63
- // https://github.com/TanStack/table/issues/5065
64
- const policy : SledPolicy = info . getValue ( )
65
- return policy . kind === 'expunged' ? (
66
- < Badge color = "neutral" > Expunged</ Badge >
67
- ) : (
68
- < Badge > In service</ Badge >
69
- )
70
- } ,
50
+ cell : ( info ) => < SledKindBadge policy = { info . getValue ( ) } /> ,
71
51
} ) ,
72
52
colHelper . accessor ( 'policy' , {
73
53
header : 'Provision policy' ,
74
- cell : ( info ) => {
75
- const policy : SledPolicy = info . getValue ( )
76
- if ( policy . kind === 'expunged' ) return < EmptyCell />
77
- return policy . provisionPolicy === 'provisionable' ? (
78
- < Badge > Provisionable</ Badge >
79
- ) : (
80
- < Badge color = "neutral" > Not provisionable</ Badge >
81
- )
82
- } ,
54
+ cell : ( info ) => < ProvisionPolicyBadge policy = { info . getValue ( ) } /> ,
83
55
} ) ,
84
56
] ,
85
57
} ) ,
86
58
colHelper . accessor ( 'state' , {
87
- cell : ( info ) => (
88
- < Badge color = { STATE_BADGE_COLORS [ info . getValue ( ) ] } > { info . getValue ( ) } </ Badge >
89
- ) ,
59
+ cell : ( info ) => < SledStateBadge state = { info . getValue ( ) } /> ,
90
60
} ) ,
91
61
]
92
62
0 commit comments