@@ -25,13 +25,22 @@ import {
25
25
ActionsColumn ,
26
26
IActions ,
27
27
} from '@patternfly/react-table' ;
28
+ import {
29
+ InfoCircleIcon ,
30
+ ExclamationTriangleIcon ,
31
+ TimesCircleIcon ,
32
+ QuestionCircleIcon ,
33
+ CodeIcon ,
34
+ } from '@patternfly/react-icons' ;
28
35
import { useState } from 'react' ;
29
- import { CodeIcon } from '@patternfly/react-icons' ;
30
36
import { Workspace , WorkspacesColumnNames , WorkspaceState } from '~/shared/types' ;
31
37
import { WorkspaceDetails } from '~/app/pages/Workspaces/Details/WorkspaceDetails' ;
32
38
import { ExpandedWorkspaceRow } from '~/app/pages/Workspaces/ExpandedWorkspaceRow' ;
33
39
import DeleteModal from '~/shared/components/DeleteModal' ;
34
- import { buildKindLogoDictionary } from '~/app/actions/WorkspaceKindsActions' ;
40
+ import {
41
+ buildKindLogoDictionary ,
42
+ buildWorkspaceRedirectStatus ,
43
+ } from '~/app/actions/WorkspaceKindsActions' ;
35
44
import useWorkspaceKinds from '~/app/hooks/useWorkspaceKinds' ;
36
45
import { WorkspaceConnectAction } from '~/app/pages/Workspaces/WorkspaceConnectAction' ;
37
46
import { WorkspaceStartActionModal } from '~/app/pages/Workspaces/workspaceActions/WorkspaceStartActionModal' ;
@@ -107,6 +116,10 @@ export const Workspaces: React.FunctionComponent = () => {
107
116
state : WorkspaceState . Paused ,
108
117
stateMessage : 'It is paused.' ,
109
118
} ,
119
+ redirectStatus : {
120
+ level : 'Info' ,
121
+ text : 'This is informational' , // Tooltip text
122
+ } ,
110
123
} ,
111
124
{
112
125
name : 'My Other Jupyter Notebook' ,
@@ -162,15 +175,26 @@ export const Workspaces: React.FunctionComponent = () => {
162
175
state : WorkspaceState . Running ,
163
176
stateMessage : 'It is running.' ,
164
177
} ,
178
+ redirectStatus : {
179
+ level : 'Danger' ,
180
+ text : 'This is dangerous' ,
181
+ } ,
165
182
} ,
166
183
] ;
167
184
168
185
const [ workspaceKinds ] = useWorkspaceKinds ( ) ;
169
186
let kindLogoDict : Record < string , string > = { } ;
170
187
kindLogoDict = buildKindLogoDictionary ( workspaceKinds ) ;
171
188
189
+ let workspaceRedirectStatus : Record <
190
+ string ,
191
+ { to : string ; message : string ; level : string } | null
192
+ > = { } ; // Initialize the redirect status dictionary
193
+ workspaceRedirectStatus = buildWorkspaceRedirectStatus ( workspaceKinds ) ; // Populate the dictionary
194
+
172
195
// Table columns
173
196
const columnNames : WorkspacesColumnNames = {
197
+ redirectStatus : 'Redirect Status' ,
174
198
name : 'Name' ,
175
199
kind : 'Kind' ,
176
200
image : 'Image' ,
@@ -266,18 +290,20 @@ export const Workspaces: React.FunctionComponent = () => {
266
290
const [ activeSortDirection , setActiveSortDirection ] = React . useState < 'asc' | 'desc' | null > ( null ) ;
267
291
268
292
const getSortableRowValues = ( workspace : Workspace ) : ( string | number ) [ ] => {
269
- const { name, kind, image, podConfig, state, homeVol, cpu, ram, lastActivity } = {
270
- name : workspace . name ,
271
- kind : workspace . kind ,
272
- image : workspace . options . imageConfig ,
273
- podConfig : workspace . options . podConfig ,
274
- state : WorkspaceState [ workspace . status . state ] ,
275
- homeVol : workspace . podTemplate . volumes . home ,
276
- cpu : workspace . cpu ,
277
- ram : workspace . ram ,
278
- lastActivity : workspace . status . activity . lastActivity ,
279
- } ;
280
- return [ name , kind , image , podConfig , state , homeVol , cpu , ram , lastActivity ] ;
293
+ const { redirectStatus, name, kind, image, podConfig, state, homeVol, cpu, ram, lastActivity } =
294
+ {
295
+ redirectStatus : '' ,
296
+ name : workspace . name ,
297
+ kind : workspace . kind ,
298
+ image : workspace . options . imageConfig ,
299
+ podConfig : workspace . options . podConfig ,
300
+ state : WorkspaceState [ workspace . status . state ] ,
301
+ homeVol : workspace . podTemplate . volumes . home ,
302
+ cpu : workspace . cpu ,
303
+ ram : workspace . ram ,
304
+ lastActivity : workspace . status . activity . lastActivity ,
305
+ } ;
306
+ return [ redirectStatus , name , kind , image , podConfig , state , homeVol , cpu , ram , lastActivity ] ;
281
307
} ;
282
308
283
309
let sortedWorkspaces = workspaces ;
@@ -436,6 +462,43 @@ export const Workspaces: React.FunctionComponent = () => {
436
462
| 'yellow'
437
463
) [ ] = [ 'green' , 'orange' , 'yellow' , 'blue' , 'red' , 'purple' ] ;
438
464
465
+ // Redirect Status Icons
466
+
467
+ const getRedirectStatusIcon = ( level : string | undefined , message : string ) => {
468
+ switch ( level ) {
469
+ case 'Info' :
470
+ return (
471
+ < Tooltip content = { message } >
472
+ < InfoCircleIcon color = "blue" aria-hidden = "true" />
473
+ </ Tooltip >
474
+ ) ;
475
+ case 'Warning' :
476
+ return (
477
+ < Tooltip content = { message } >
478
+ < ExclamationTriangleIcon color = "orange" aria-hidden = "true" />
479
+ </ Tooltip >
480
+ ) ;
481
+ case 'Danger' :
482
+ return (
483
+ < Tooltip content = { message } >
484
+ < TimesCircleIcon color = "red" aria-hidden = "true" />
485
+ </ Tooltip >
486
+ ) ;
487
+ case undefined :
488
+ return (
489
+ < Tooltip content = { message } >
490
+ < QuestionCircleIcon color = "gray" aria-hidden = "true" />
491
+ </ Tooltip >
492
+ ) ;
493
+ default :
494
+ return (
495
+ < Tooltip content = { `Invalid level: ${ level } ` } >
496
+ < QuestionCircleIcon color = "gray" aria-hidden = "true" />
497
+ </ Tooltip >
498
+ ) ;
499
+ }
500
+ } ;
501
+
439
502
// Pagination
440
503
441
504
const [ page , setPage ] = React . useState ( 1 ) ;
@@ -494,7 +557,10 @@ export const Workspaces: React.FunctionComponent = () => {
494
557
< Tr >
495
558
< Th />
496
559
{ Object . values ( columnNames ) . map ( ( columnName , index ) => (
497
- < Th key = { `${ columnName } -col-name` } sort = { getSortParams ( index ) } >
560
+ < Th
561
+ key = { `${ columnName } -col-name` }
562
+ sort = { columnName !== 'Redirect Status' ? getSortParams ( index ) : undefined }
563
+ >
498
564
{ columnName }
499
565
</ Th >
500
566
) ) }
@@ -517,6 +583,15 @@ export const Workspaces: React.FunctionComponent = () => {
517
583
setWorkspaceExpanded ( workspace , ! isWorkspaceExpanded ( workspace ) ) ,
518
584
} }
519
585
/>
586
+ < Td dataLabel = { columnNames . redirectStatus } >
587
+ { workspaceRedirectStatus [ workspace . kind ]
588
+ ? getRedirectStatusIcon (
589
+ workspaceRedirectStatus [ workspace . kind ] ?. level ,
590
+ workspaceRedirectStatus [ workspace . kind ] ?. message ||
591
+ 'No API response available' ,
592
+ )
593
+ : getRedirectStatusIcon ( undefined , 'No API response available' ) }
594
+ </ Td >
520
595
< Td dataLabel = { columnNames . name } > { workspace . name } </ Td >
521
596
< Td dataLabel = { columnNames . kind } >
522
597
{ kindLogoDict [ workspace . kind ] ? (
0 commit comments