@@ -46,11 +46,11 @@ import { WorkspaceConnectAction } from '~/app/pages/Workspaces/WorkspaceConnectA
46
46
import { WorkspaceStartActionModal } from '~/app/pages/Workspaces/workspaceActions/WorkspaceStartActionModal' ;
47
47
import { WorkspaceRestartActionModal } from '~/app/pages/Workspaces/workspaceActions/WorkspaceRestartActionModal' ;
48
48
import { WorkspaceStopActionModal } from '~/app/pages/Workspaces/workspaceActions/WorkspaceStopActionModal' ;
49
+ import { WorkspaceAggregatedDetails } from '~/app/pages/Workspaces/DetailsAggregated/WorkspaceAggregatedDetails' ;
49
50
import Filter , { FilteredColumn } from 'shared/components/Filter' ;
50
51
import { formatRam } from 'shared/utilities/WorkspaceUtils' ;
51
52
52
53
export enum ActionType {
53
- ViewDetails ,
54
54
Edit ,
55
55
Delete ,
56
56
Start ,
@@ -341,11 +341,6 @@ export const Workspaces: React.FunctionComponent = () => {
341
341
342
342
// Actions
343
343
344
- const viewDetailsClick = React . useCallback ( ( workspace : Workspace ) => {
345
- setSelectedWorkspace ( workspace ) ;
346
- setActiveActionType ( ActionType . ViewDetails ) ;
347
- } , [ ] ) ;
348
-
349
344
const editAction = React . useCallback ( ( workspace : Workspace ) => {
350
345
setSelectedWorkspace ( workspace ) ;
351
346
setActiveActionType ( ActionType . Edit ) ;
@@ -383,11 +378,6 @@ export const Workspaces: React.FunctionComponent = () => {
383
378
const workspaceDefaultActions = ( workspace : Workspace ) : IActions => {
384
379
const workspaceState = workspace . status . state ;
385
380
const workspaceActions = [
386
- {
387
- id : 'view-details' ,
388
- title : 'View Details' ,
389
- onClick : ( ) => viewDetailsClick ( workspace ) ,
390
- } ,
391
381
{
392
382
id : 'edit' ,
393
383
title : 'Edit' ,
@@ -526,25 +516,49 @@ export const Workspaces: React.FunctionComponent = () => {
526
516
setPage ( newPage ) ;
527
517
} ;
528
518
529
- const workspaceDetailsContent = (
530
- < >
531
- { selectedWorkspace && (
532
- < WorkspaceDetails
533
- workspace = { selectedWorkspace }
534
- onCloseClick = { ( ) => selectWorkspace ( null ) }
535
- onEditClick = { ( ) => editAction ( selectedWorkspace ) }
536
- onDeleteClick = { ( ) => handleDeleteClick ( selectedWorkspace ) }
537
- />
538
- ) }
539
- </ >
540
- ) ;
519
+ const [ selectedWorkspaceNames , setSelectedWorkspaceNames ] = React . useState < string [ ] > ( [ ] ) ;
520
+ const setWorkspaceSelected = ( workspace : Workspace , isSelecting = true ) =>
521
+ setSelectedWorkspaceNames ( ( prevSelected ) => {
522
+ const otherSelectedWorkspaceNames = prevSelected . filter ( ( w ) => w !== workspace . name ) ;
523
+ return isSelecting
524
+ ? [ ...otherSelectedWorkspaceNames , workspace . name ]
525
+ : otherSelectedWorkspaceNames ;
526
+ } ) ;
527
+ const selectAllWorkspaces = ( isSelecting = true ) =>
528
+ setSelectedWorkspaceNames ( isSelecting ? sortedWorkspaces . map ( ( r ) => r . name ) : [ ] ) ;
529
+ const areAllWorkspacesSelected = selectedWorkspaceNames . length === sortedWorkspaces . length ;
530
+ const isWorkspaceSelected = ( workspace : Workspace ) =>
531
+ selectedWorkspaceNames . includes ( workspace . name ) ;
532
+
533
+ const workspaceDetailsContent = ( ) => {
534
+ const selectedWorkspaceForDetails =
535
+ selectedWorkspaceNames . length === 1
536
+ ? sortedWorkspaces . find ( ( w ) => w . name === selectedWorkspaceNames [ 0 ] )
537
+ : undefined ;
538
+ return (
539
+ < >
540
+ { selectedWorkspaceForDetails && (
541
+ < WorkspaceDetails
542
+ workspace = { selectedWorkspaceForDetails }
543
+ onCloseClick = { ( ) => selectAllWorkspaces ( false ) }
544
+ onEditClick = { ( ) => editAction ( selectedWorkspaceForDetails ) }
545
+ onDeleteClick = { ( ) => handleDeleteClick ( selectedWorkspaceForDetails ) }
546
+ />
547
+ ) }
548
+ { selectedWorkspaceNames . length > 1 && (
549
+ < WorkspaceAggregatedDetails
550
+ workspaceNames = { selectedWorkspaceNames }
551
+ onCloseClick = { ( ) => selectAllWorkspaces ( false ) }
552
+ onDeleteClick = { ( ) => console . log ( 'Delete selected workspaces' ) }
553
+ />
554
+ ) }
555
+ </ >
556
+ ) ;
557
+ } ;
541
558
542
559
return (
543
- < Drawer
544
- isInline
545
- isExpanded = { selectedWorkspace != null && activeActionType === ActionType . ViewDetails }
546
- >
547
- < DrawerContent panelContent = { workspaceDetailsContent } >
560
+ < Drawer isExpanded = { selectedWorkspaceNames . length >= 1 } >
561
+ < DrawerContent panelContent = { workspaceDetailsContent ( ) } >
548
562
< DrawerContentBody >
549
563
< PageSection isFilled >
550
564
< Content >
@@ -562,6 +576,13 @@ export const Workspaces: React.FunctionComponent = () => {
562
576
< Thead >
563
577
< Tr >
564
578
< Th />
579
+ < Th
580
+ select = { {
581
+ onSelect : ( _event , isSelecting ) => selectAllWorkspaces ( isSelecting ) ,
582
+ isSelected : areAllWorkspacesSelected ,
583
+ } }
584
+ aria-label = "Row select"
585
+ />
565
586
{ Object . values ( columnNames ) . map ( ( columnName , index ) => (
566
587
< Th
567
588
key = { `${ columnName } -col-name` }
@@ -589,6 +610,14 @@ export const Workspaces: React.FunctionComponent = () => {
589
610
setWorkspaceExpanded ( workspace , ! isWorkspaceExpanded ( workspace ) ) ,
590
611
} }
591
612
/>
613
+ < Td
614
+ select = { {
615
+ rowIndex,
616
+ onSelect : ( _event , isSelecting ) =>
617
+ setWorkspaceSelected ( workspace , isSelecting ) ,
618
+ isSelected : isWorkspaceSelected ( workspace ) ,
619
+ } }
620
+ />
592
621
< Td dataLabel = { columnNames . redirectStatus } >
593
622
{ workspaceRedirectStatus [ workspace . kind ]
594
623
? getRedirectStatusIcon (
@@ -645,7 +674,7 @@ export const Workspaces: React.FunctionComponent = () => {
645
674
</ Td >
646
675
</ Tr >
647
676
{ isWorkspaceExpanded ( workspace ) && (
648
- < ExpandedWorkspaceRow workspace = { workspace } columnNames = { columnNames } />
677
+ < ExpandedWorkspaceRow workspace = { workspace } />
649
678
) }
650
679
</ Tbody >
651
680
) ) }
0 commit comments