@@ -37,7 +37,7 @@ import { CodeIcon, FilterIcon } from '@patternfly/react-icons';
3737import { WorkspaceKind } from '~/shared/api/backendApiTypes' ;
3838import useWorkspaceKinds from '~/app/hooks/useWorkspaceKinds' ;
3939import { useWorkspaceCountPerKind } from '~/app/hooks/useWorkspaceCountPerKind' ;
40- import { WorkspaceKindsColumnNames } from '~/app/types' ;
40+ import { WorkspaceKindsColumns } from '~/app/types' ;
4141import ThemeAwareSearchInput from '~/app/components/ThemeAwareSearchInput' ;
4242import CustomEmptyState from '~/shared/components/CustomEmptyState' ;
4343
@@ -47,13 +47,20 @@ export enum ActionType {
4747
4848export const WorkspaceKinds : React . FunctionComponent = ( ) => {
4949 // Table columns
50- const columnNames : WorkspaceKindsColumnNames = {
51- icon : '' ,
52- name : 'Name' ,
53- description : 'Description' ,
54- deprecated : 'Status' ,
55- numberOfWorkspaces : 'Number of workspaces' ,
56- } ;
50+ const columns : WorkspaceKindsColumns = React . useMemo (
51+ ( ) => ( {
52+ icon : { name : '' , label : 'Icon' , id : 'icon' } ,
53+ name : { name : 'Name' , label : 'Name' , id : 'name' } ,
54+ description : { name : 'Description' , label : 'Description' , id : 'description' } ,
55+ deprecated : { name : 'Status' , label : 'Status' , id : 'status' } ,
56+ numberOfWorkspaces : {
57+ name : 'Number of workspaces' ,
58+ label : 'Number of workspaces' ,
59+ id : 'number-of-workspaces' ,
60+ } ,
61+ } ) ,
62+ [ ] ,
63+ ) ;
5764
5865 const [ workspaceKinds , workspaceKindsLoaded , workspaceKindsError ] = useWorkspaceKinds ( ) ;
5966 const workspaceCountPerKind = useWorkspaceCountPerKind ( ) ;
@@ -509,30 +516,27 @@ export const WorkspaceKinds: React.FunctionComponent = () => {
509516 < Table aria-label = "Sortable table" ouiaId = "SortableTable" >
510517 < Thead >
511518 < Tr >
512- < Th aria-label = "WorkspaceKind Icon" />
513- { Object . values ( columnNames )
514- . filter ( ( name ) => name !== '' )
515- . map ( ( columnName , index ) => (
516- < Th
517- key = { `${ columnName } -col-name` }
518- sort = {
519- columnName === 'Name' || columnName === 'Status'
520- ? getSortParams ( index )
521- : undefined
522- }
523- >
524- { columnName }
525- </ Th >
526- ) ) }
519+ { Object . values ( columns ) . map ( ( column , index ) => (
520+ < Th
521+ aria-label = { `${ column . label } column` }
522+ key = { `${ column . id } -column` }
523+ sort = {
524+ column . id === 'name' || column . id === 'status'
525+ ? getSortParams ( index )
526+ : undefined
527+ }
528+ >
529+ { column . name }
530+ </ Th >
531+ ) ) }
527532 < Th screenReaderText = "Primary action" />
528533 </ Tr >
529534 </ Thead >
530535 { filteredWorkspaceKinds . length > 0 &&
531536 filteredWorkspaceKinds . map ( ( workspaceKind , rowIndex ) => (
532537 < Tbody id = "workspace-kind-table-content" key = { rowIndex } data-testid = "table-body" >
533538 < Tr id = { `workspace-kind-table-row-${ rowIndex + 1 } ` } >
534- < Td />
535- < Td dataLabel = { columnNames . icon } style = { { width : '50px' } } >
539+ < Td dataLabel = { columns . icon . name } style = { { width : '50px' } } >
536540 { workspaceKind . icon . url ? (
537541 < Brand
538542 src = { workspaceKind . icon . url }
@@ -543,9 +547,9 @@ export const WorkspaceKinds: React.FunctionComponent = () => {
543547 < CodeIcon />
544548 ) }
545549 </ Td >
546- < Td dataLabel = { columnNames . name } > { workspaceKind . name } </ Td >
550+ < Td dataLabel = { columns . name . name } > { workspaceKind . name } </ Td >
547551 < Td
548- dataLabel = { columnNames . description }
552+ dataLabel = { columns . description . name }
549553 style = { { maxWidth : '200px' , overflow : 'hidden' } }
550554 >
551555 < Tooltip content = { workspaceKind . description } >
@@ -556,7 +560,7 @@ export const WorkspaceKinds: React.FunctionComponent = () => {
556560 </ span >
557561 </ Tooltip >
558562 </ Td >
559- < Td dataLabel = { columnNames . deprecated } >
563+ < Td dataLabel = { columns . deprecated . name } >
560564 { workspaceKind . deprecated ? (
561565 < Tooltip content = { workspaceKind . deprecationMessage } >
562566 < Label color = "red" > Deprecated</ Label >
@@ -565,7 +569,7 @@ export const WorkspaceKinds: React.FunctionComponent = () => {
565569 < Label color = "green" > Active</ Label >
566570 ) }
567571 </ Td >
568- < Td dataLabel = { columnNames . numberOfWorkspaces } >
572+ < Td dataLabel = { columns . numberOfWorkspaces . name } >
569573 { workspaceCountPerKind [ workspaceKind . name ] ?? 0 }
570574 </ Td >
571575
0 commit comments