@@ -22,6 +22,7 @@ import {
22
22
Button ,
23
23
PaginationVariant ,
24
24
Pagination ,
25
+ Content ,
25
26
} from '@patternfly/react-core' ;
26
27
import {
27
28
Table ,
@@ -33,8 +34,9 @@ import {
33
34
ThProps ,
34
35
ActionsColumn ,
35
36
IActions ,
37
+ ExpandableRowContent ,
36
38
} from '@patternfly/react-table' ;
37
- import { FilterIcon } from '@patternfly/react-icons' ;
39
+ import { FilterIcon , LockedIcon } from '@patternfly/react-icons' ;
38
40
import { Workspace , WorkspaceState } from '~/shared/types' ;
39
41
40
42
export const Workspaces : React . FunctionComponent = ( ) => {
@@ -51,7 +53,12 @@ export const Workspaces: React.FunctionComponent = () => {
51
53
home : '/home' ,
52
54
data : [
53
55
{
54
- pvcName : 'data' ,
56
+ pvcName : 'Volume-1' ,
57
+ mountPath : '/data' ,
58
+ readOnly : true ,
59
+ } ,
60
+ {
61
+ pvcName : 'Volume-2' ,
55
62
mountPath : '/data' ,
56
63
readOnly : false ,
57
64
} ,
@@ -128,7 +135,6 @@ export const Workspaces: React.FunctionComponent = () => {
128
135
podConfig : 'Pod Config' ,
129
136
state : 'State' ,
130
137
homeVol : 'Home Vol' ,
131
- dataVol : 'Data Vol' ,
132
138
lastActivity : 'Last Activity' ,
133
139
} ;
134
140
@@ -140,6 +146,18 @@ export const Workspaces: React.FunctionComponent = () => {
140
146
const attributeContainerRef = React . useRef < HTMLDivElement | null > ( null ) ;
141
147
142
148
const [ searchValue , setSearchValue ] = React . useState ( '' ) ;
149
+ const [ expandedWorkspacesNames , setExpandedWorkspacesNames ] = React . useState < string [ ] > ( [ ] ) ;
150
+
151
+ const setWorkspaceExpanded = ( workspace : Workspace , isExpanding = true ) =>
152
+ setExpandedWorkspacesNames ( ( prevExpanded ) => {
153
+ const newExpandedWorkspacesNames = prevExpanded . filter ( ( wsName ) => wsName !== workspace . name ) ;
154
+ return isExpanding
155
+ ? [ ...newExpandedWorkspacesNames , workspace . name ]
156
+ : newExpandedWorkspacesNames ;
157
+ } ) ;
158
+
159
+ const isWorkspaceExpanded = ( workspace : Workspace ) =>
160
+ expandedWorkspacesNames . includes ( workspace . name ) ;
143
161
144
162
const searchInput = (
145
163
< SearchInput
@@ -421,6 +439,54 @@ export const Workspaces: React.FunctionComponent = () => {
421
439
setPage ( newPage ) ;
422
440
} ;
423
441
442
+ const workspaceDataVolRender = ( workspace : Workspace ) => {
443
+ const workspaceDataVol = workspace . podTemplate . volumes . data ;
444
+ console . log ( workspaceDataVol ) ;
445
+ return (
446
+ < >
447
+ < Content component = "h3" > Data Volumes:</ Content >
448
+ { workspaceDataVol . map ( ( data , index ) => (
449
+ < Content key = { `data-vol-${ index } ` } component = "blockquote" >
450
+ < div >
451
+ < div >
452
+ < Content component = "h5" > { data . pvcName } </ Content >
453
+ </ div >
454
+ < div >
455
+ < Content component = "small" >
456
+ mount path: { data . mountPath }
457
+ { data . readOnly && (
458
+ < Content component = "small" >
459
+ Data is readonly
460
+ < LockedIcon style = { { marginLeft : '3px' } } />
461
+ </ Content >
462
+ ) }
463
+ </ Content >
464
+ </ div >
465
+ </ div >
466
+ </ Content >
467
+ ) ) }
468
+ </ >
469
+ ) ;
470
+ } ;
471
+
472
+ const expandedRowRenderer = ( workspace : Workspace ) => (
473
+ < Tr >
474
+ < Td />
475
+ { Object . keys ( columnNames ) . map ( ( colName ) => {
476
+ switch ( colName ) {
477
+ case 'name' :
478
+ return (
479
+ < Td noPadding colSpan = { 1 } >
480
+ < ExpandableRowContent > { workspaceDataVolRender ( workspace ) } </ ExpandableRowContent >
481
+ </ Td >
482
+ ) ;
483
+ default :
484
+ return < Td /> ;
485
+ }
486
+ } ) }
487
+ </ Tr >
488
+ ) ;
489
+
424
490
return (
425
491
< PageSection >
426
492
< Title headingLevel = "h1" > Kubeflow Workspaces</ Title >
@@ -429,20 +495,27 @@ export const Workspaces: React.FunctionComponent = () => {
429
495
< Table aria-label = "Sortable table" ouiaId = "SortableTable" >
430
496
< Thead >
431
497
< Tr >
498
+ < Th />
432
499
< Th sort = { getSortParams ( 0 ) } > { columnNames . name } </ Th >
433
500
< Th sort = { getSortParams ( 1 ) } > { columnNames . kind } </ Th >
434
501
< Th sort = { getSortParams ( 2 ) } > { columnNames . image } </ Th >
435
502
< Th sort = { getSortParams ( 3 ) } > { columnNames . podConfig } </ Th >
436
503
< Th sort = { getSortParams ( 4 ) } > { columnNames . state } </ Th >
437
504
< Th sort = { getSortParams ( 5 ) } > { columnNames . homeVol } </ Th >
438
- < Th sort = { getSortParams ( 6 ) } > { columnNames . dataVol } </ Th >
439
- < Th sort = { getSortParams ( 7 ) } > { columnNames . lastActivity } </ Th >
505
+ < Th sort = { getSortParams ( 6 ) } > { columnNames . lastActivity } </ Th >
440
506
< Th screenReaderText = "Primary action" />
441
507
</ Tr >
442
508
</ Thead >
443
- < Tbody >
444
- { sortedWorkspaces . map ( ( workspace , rowIndex ) => (
445
- < Tr key = { rowIndex } >
509
+ { sortedWorkspaces . map ( ( workspace , rowIndex ) => (
510
+ < Tbody key = { rowIndex } isExpanded = { isWorkspaceExpanded ( workspace ) } >
511
+ < Tr >
512
+ < Td
513
+ expand = { {
514
+ rowIndex,
515
+ isExpanded : isWorkspaceExpanded ( workspace ) ,
516
+ onToggle : ( ) => setWorkspaceExpanded ( workspace , ! isWorkspaceExpanded ( workspace ) ) ,
517
+ } }
518
+ />
446
519
< Td dataLabel = { columnNames . name } > { workspace . name } </ Td >
447
520
< Td dataLabel = { columnNames . kind } > { workspace . kind } </ Td >
448
521
< Td dataLabel = { columnNames . image } > { workspace . options . imageConfig } </ Td >
@@ -453,9 +526,6 @@ export const Workspaces: React.FunctionComponent = () => {
453
526
</ Label >
454
527
</ Td >
455
528
< Td dataLabel = { columnNames . homeVol } > { workspace . podTemplate . volumes . home } </ Td >
456
- < Td dataLabel = { columnNames . dataVol } >
457
- { workspace . podTemplate . volumes . data [ 0 ] . pvcName || '' }
458
- </ Td >
459
529
< Td dataLabel = { columnNames . lastActivity } >
460
530
< Timestamp
461
531
date = { new Date ( workspace . status . activity . lastActivity ) }
@@ -468,8 +538,9 @@ export const Workspaces: React.FunctionComponent = () => {
468
538
< ActionsColumn items = { defaultActions ( workspace ) } />
469
539
</ Td >
470
540
</ Tr >
471
- ) ) }
472
- </ Tbody >
541
+ { isWorkspaceExpanded ( workspace ) && expandedRowRenderer ( workspace ) }
542
+ </ Tbody >
543
+ ) ) }
473
544
</ Table >
474
545
< Pagination
475
546
itemCount = { 333 }
0 commit comments