77 */
88import { createColumnHelper } from '@tanstack/react-table'
99
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'
1711import { Servers24Icon } from '@oxide/design-system/icons/react'
1812
19- import { EmptyCell } from '~/table/cells/EmptyCell'
2013import { makeLinkCell } from '~/table/cells/LinkCell'
2114import { useQueryTable } from '~/table/QueryTable'
22- import { Badge , type BadgeColor } from '~/ui/lib/Badge'
2315import { EmptyMessage } from '~/ui/lib/EmptyMessage'
2416import { pb } from '~/util/path-builder'
2517
26- const STATE_BADGE_COLORS : Record < SledState , BadgeColor > = {
27- active : 'default' ,
28- decommissioned : 'neutral' ,
29- }
18+ import { ProvisionPolicyBadge , SledKindBadge , SledStateBadge } from './sled/SledBadges'
3019
3120const sledList = getListQFn ( 'sledList' , { } )
3221
3322export async function clientLoader ( ) {
34- await queryClient . prefetchQuery ( sledList . optionsFn ( ) )
23+ await queryClient . fetchQuery ( sledList . optionsFn ( ) )
3524 return null
3625}
3726
@@ -58,35 +47,16 @@ const staticCols = [
5847 columns : [
5948 colHelper . accessor ( 'policy' , {
6049 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 ( ) } /> ,
7151 } ) ,
7252 colHelper . accessor ( 'policy' , {
7353 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 ( ) } /> ,
8355 } ) ,
8456 ] ,
8557 } ) ,
8658 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 ( ) } /> ,
9060 } ) ,
9161]
9262
0 commit comments