@@ -52,7 +52,7 @@ import { WorkspaceRestartActionModal } from '~/app/pages/Workspaces/workspaceAct
52
52
import { WorkspaceStopActionModal } from '~/app/pages/Workspaces/workspaceActions/WorkspaceStopActionModal' ;
53
53
import Filter , { FilteredColumn } from 'shared/components/Filter' ;
54
54
import { formatRam , formatCPU } from 'shared/utilities/WorkspaceResources' ;
55
- import { formatRam } from 'shared/utilities/WorkspaceUtils' ; //check if still exist
55
+ import { formatRam } from 'shared/utilities/WorkspaceUtils' ; //check if still exist
56
56
57
57
export enum ActionType {
58
58
ViewDetails ,
@@ -189,7 +189,7 @@ export const Workspaces: React.FunctionComponent = () => {
189
189
190
190
const getSortableRowValues = ( workspace : Workspace ) : ( string | number | undefined ) [ ] => {
191
191
const { name, kind, image, podConfig, state, homeVol, cpu, ram, lastActivity } = {
192
- redirectStatus : '' ,
192
+ redirectStatus : '' ,
193
193
name : workspace . name ,
194
194
kind : workspace . workspace_kind . name ,
195
195
image : workspace . pod_template . options . image_config . current . display_name ,
@@ -278,7 +278,7 @@ export const Workspaces: React.FunctionComponent = () => {
278
278
} ;
279
279
280
280
const workspaceDefaultActions = ( workspace : Workspace ) : IActions => {
281
- const workspaceState = workspace . status . state ;
281
+ const workspaceState = workspace . state ;
282
282
const workspaceActions = [
283
283
{
284
284
id : 'view-details' ,
@@ -463,98 +463,116 @@ export const Workspaces: React.FunctionComponent = () => {
463
463
Create Workspace
464
464
</ Button >
465
465
</ Content >
466
- < Table aria-label = "Sortable table" ouiaId = "SortableTable" >
467
- < Thead >
468
- < Tr >
469
- < Th />
470
- { Object . values ( columnNames ) . map ( ( columnName , index ) => (
471
- < Th
472
- key = { `${ columnName } -col-name` }
473
- sort = { columnName !== 'Redirect Status' ? getSortParams ( index ) : undefined }
474
- >
475
- { columnName }
476
- </ Th >
477
- ) ) }
478
- < Th screenReaderText = "Primary action" />
479
- </ Tr >
480
- </ Thead >
481
- { sortedWorkspaces . map ( ( workspace , rowIndex ) => (
482
- < Tbody
483
- id = "workspaces-table-content"
484
- key = { rowIndex }
485
- isExpanded = { isWorkspaceExpanded ( workspace ) }
486
- data-testid = "table-body"
487
- >
488
- < Tr id = { `workspaces-table-row-${ rowIndex + 1 } ` } >
489
- < Td
490
- expand = { {
491
- rowIndex,
492
- isExpanded : isWorkspaceExpanded ( workspace ) ,
493
- onToggle : ( ) =>
494
- setWorkspaceExpanded ( workspace , ! isWorkspaceExpanded ( workspace ) ) ,
495
- } }
496
- />
497
- < Td dataLabel = { columnNames . redirectStatus } >
498
- { workspaceRedirectStatus [ workspace . kind ]
499
- ? getRedirectStatusIcon (
500
- workspaceRedirectStatus [ workspace . kind ] ?. level ,
501
- workspaceRedirectStatus [ workspace . kind ] ?. message ||
502
- 'No API response available' ,
503
- )
504
- : getRedirectStatusIcon ( undefined , 'No API response available' ) }
505
- </ Td >
506
- < Td dataLabel = { columnNames . name } > { workspace . name } </ Td >
507
- < Td dataLabel = { columnNames . kind } >
508
- { kindLogoDict [ workspace . kind ] ? (
509
- < Tooltip content = { workspace . kind } >
510
- < Brand
511
- src = { kindLogoDict [ workspace . kind ] }
512
- alt = { workspace . kind }
513
- style = { { width : '20px' , height : '20px' , cursor : 'pointer' } }
514
- />
515
- </ Tooltip >
516
- ) : (
517
- < Tooltip content = { workspace . kind } >
518
- < CodeIcon />
519
- </ Tooltip >
520
- ) }
521
- </ Td >
522
- < Td dataLabel = { columnNames . image } > { workspace . options . imageConfig } </ Td >
523
- < Td dataLabel = { columnNames . podConfig } > { workspace . options . podConfig } </ Td >
524
- < Td dataLabel = { columnNames . state } >
525
- < Label color = { stateColors [ workspace . status . state ] } >
526
- { WorkspaceState [ workspace . status . state ] }
527
- </ Label >
528
- </ Td >
529
- < Td dataLabel = { columnNames . homeVol } > { workspace . podTemplate . volumes . home } </ Td >
530
- < Td dataLabel = { columnNames . cpu } > { `${ workspace . cpu } %` } </ Td >
531
- < Td dataLabel = { columnNames . ram } > { formatRam ( workspace . ram ) } </ Td >
532
- < Td dataLabel = { columnNames . lastActivity } >
533
- < Timestamp
534
- date = { new Date ( workspace . status . activity . lastActivity ) }
535
- tooltip = { { variant : TimestampTooltipVariant . default } }
466
+ { /* Show a loading spinner if data is still loading */ }
467
+ { ! loaded ? (
468
+ < Spinner size = "xl" />
469
+ ) : (
470
+ < Table
471
+ data-testid = "workspaces-table"
472
+ aria-label = "Sortable table"
473
+ ouiaId = "SortableTable"
474
+ >
475
+ < Thead >
476
+ < Tr >
477
+ < Th />
478
+ { Object . values ( columnNames ) . map ( ( columnName , index ) => (
479
+ < Th
480
+ key = { `${ columnName } -col-name` }
481
+ sort = { columnName !== 'Redirect Status' ? getSortParams ( index ) : undefined }
536
482
>
537
- 1 hour ago
538
- </ Timestamp >
539
- </ Td >
540
- < Td >
541
- < WorkspaceConnectAction workspace = { workspace } />
542
- </ Td >
543
- < Td isActionCell data-testid = "action-column" >
544
- < ActionsColumn
545
- items = { workspaceDefaultActions ( workspace ) . map ( ( action ) => ( {
546
- ...action ,
547
- 'data-testid' : `action-${ action . id || '' } ` ,
548
- } ) ) }
549
- />
550
- </ Td >
483
+ { columnName }
484
+ </ Th >
485
+ ) ) }
486
+ < Th screenReaderText = "Primary action" />
551
487
</ Tr >
552
- { isWorkspaceExpanded ( workspace ) && (
553
- < ExpandedWorkspaceRow workspace = { workspace } columnNames = { columnNames } />
554
- ) }
555
- </ Tbody >
556
- ) ) }
557
- </ Table >
488
+ </ Thead >
489
+ { sortedWorkspaces . map ( ( workspace , rowIndex ) => (
490
+ < Tbody
491
+ id = "workspaces-table-content"
492
+ key = { rowIndex }
493
+ isExpanded = { isWorkspaceExpanded ( workspace ) }
494
+ data-testid = "table-body"
495
+ >
496
+ < Tr
497
+ id = { `workspaces-table-row-${ rowIndex + 1 } ` }
498
+ data-testid = { `workspace-row-${ rowIndex } ` }
499
+ >
500
+ < Td
501
+ expand = { {
502
+ rowIndex,
503
+ isExpanded : isWorkspaceExpanded ( workspace ) ,
504
+ onToggle : ( ) =>
505
+ setWorkspaceExpanded ( workspace , ! isWorkspaceExpanded ( workspace ) ) ,
506
+ } }
507
+ />
508
+ < Td dataLabel = { columnNames . redirectStatus } >
509
+ { workspaceRedirectStatus [ workspace . kind ]
510
+ ? getRedirectStatusIcon (
511
+ workspaceRedirectStatus [ workspace . kind ] ?. level ,
512
+ workspaceRedirectStatus [ workspace . kind ] ?. message ||
513
+ 'No API response available' ,
514
+ )
515
+ : getRedirectStatusIcon ( undefined , 'No API response available' ) }
516
+ </ Td >
517
+ < Td data-testid = "workspace-name" dataLabel = { columnNames . name } >
518
+ { workspace . name }
519
+ </ Td >
520
+ < Td dataLabel = { columnNames . kind } >
521
+ { kindLogoDict [ workspace . workspace_kind . name ] ? (
522
+ < Tooltip content = { workspace . workspace_kind . name } >
523
+ < Brand
524
+ src = { kindLogoDict [ workspace . workspace_kind . name ] }
525
+ alt = { workspace . workspace_kind . name }
526
+ style = { { width : '20px' , height : '20px' , cursor : 'pointer' } }
527
+ />
528
+ </ Tooltip >
529
+ ) : (
530
+ < Tooltip content = { workspace . workspace_kind . name } >
531
+ < CodeIcon />
532
+ </ Tooltip >
533
+ ) }
534
+ </ Td >
535
+ < Td dataLabel = { columnNames . image } >
536
+ { workspace . pod_template . options . image_config . current . display_name }
537
+ </ Td >
538
+ < Td data-testid = "pod-config" dataLabel = { columnNames . podConfig } >
539
+ { workspace . pod_template . options . pod_config . current . display_name }
540
+ </ Td >
541
+ < Td data-testid = "state-label" dataLabel = { columnNames . state } >
542
+ < Label color = { stateColors [ workspace . state ] } > { workspace . state } </ Label > { ' ' }
543
+ </ Td >
544
+ < Td dataLabel = { columnNames . homeVol } >
545
+ { workspace . pod_template . volumes . home . pvc_name }
546
+ </ Td >
547
+ < Td dataLabel = { columnNames . cpu } > { formatCPU ( getCpuValue ( workspace ) ) } </ Td >
548
+ < Td dataLabel = { columnNames . ram } > { formatRam ( getRamValue ( workspace ) ) } </ Td >
549
+ < Td dataLabel = { columnNames . lastActivity } >
550
+ < Timestamp
551
+ date = { new Date ( workspace . activity . last_activity ) }
552
+ tooltip = { { variant : TimestampTooltipVariant . default } }
553
+ >
554
+ 1 hour ago
555
+ </ Timestamp >
556
+ </ Td >
557
+ < Td >
558
+ < WorkspaceConnectAction workspace = { workspace } />
559
+ </ Td >
560
+ < Td isActionCell data-testid = "action-column" >
561
+ < ActionsColumn
562
+ items = { workspaceDefaultActions ( workspace ) . map ( ( action ) => ( {
563
+ ...action ,
564
+ 'data-testid' : `action-${ typeof action . title === 'string' ? action . title . toLowerCase ( ) : '' } ` ,
565
+ } ) ) }
566
+ />
567
+ </ Td >
568
+ </ Tr >
569
+ { isWorkspaceExpanded ( workspace ) && (
570
+ < ExpandedWorkspaceRow workspace = { workspace } columnNames = { columnNames } />
571
+ ) }
572
+ </ Tbody >
573
+ ) ) }
574
+ </ Table >
575
+ ) }
558
576
{ isActionAlertModalOpen && chooseAlertModal ( ) }
559
577
< DeleteModal
560
578
isOpen = { workspaceToDelete != null }
0 commit comments