@@ -23,11 +23,11 @@ import {
23
23
PageSection ,
24
24
Title ,
25
25
CodeBlock ,
26
- CodeBlockCode , SimpleList , SimpleListGroup , SimpleListItem ,
26
+ CodeBlockCode , SimpleList , SimpleListGroup , SimpleListItem , Alert , ExpandableSection ,
27
27
} from "@patternfly/react-core" ;
28
28
import { apiBaseUrl } from "@app/config" ;
29
29
import { CheckCircleIcon , ExclamationCircleIcon , ExclamationTriangleIcon } from "@patternfly/react-icons" ;
30
- import { Table , TableHeader , TableBody , TableProps , TableVariant } from '@patternfly/react-table' ;
30
+ import { Table , Thead , Tr , Th , Tbody , Td } from '@patternfly/react-table' ;
31
31
32
32
type data = {
33
33
meta : {
@@ -419,26 +419,28 @@ const Dashboard: React.FunctionComponent = () => {
419
419
name : 'File name' ,
420
420
importTime : 'Import date' ,
421
421
gatherTime : 'Gather date' ,
422
+ insightsData : 'Insights data' ,
422
423
} ;
423
424
424
- const columns : TableProps [ 'cells' ] = [ 'File name' , 'Gather date' , 'Import date' ] ;
425
+ const insightsIcons = ( data ) => {
426
+ const nReports = JSON . parse ( data ) [ "reports" ] . length
425
427
426
- let rows : TableProps [ 'rows' ] = [
427
- [ 'Loading...' , 'Loading...' , 'Loading...' ] ,
428
- ] ;
429
-
430
- if ( importedMustGathers !== undefined ) {
431
- if ( importedMustGathers . data . length === 0 ) {
432
- rows = [
433
- [ 'No must-gathers imported' , '' , '' ] ,
434
- ] ;
428
+ if ( nReports === 0 ) {
429
+ return (
430
+ < Icon status = "success" className = "pf-u-ml-xs" >
431
+ < CheckCircleIcon />
432
+ </ Icon >
433
+ )
435
434
}
436
435
437
- rows = importedMustGathers . data . map ( ( mustGather ) => [
438
- < span onClick = { ( ) => setMustGatherInsightData ( mustGather . insightsData ) } > { mustGather . name } </ span > ,
439
- < span onClick = { ( ) => setMustGatherInsightData ( mustGather . insightsData ) } > { new Date ( mustGather . gatherTime ) . toLocaleString ( ) } </ span > ,
440
- < span onClick = { ( ) => setMustGatherInsightData ( mustGather . insightsData ) } > { new Date ( mustGather . importTime ) . toLocaleString ( ) } </ span > ,
441
- ] ) ;
436
+ return (
437
+ < >
438
+ { nReports }
439
+ < Icon status = "danger" className = "pf-u-ml-xs" >
440
+ < ExclamationCircleIcon />
441
+ </ Icon >
442
+ </ >
443
+ )
442
444
}
443
445
444
446
return (
@@ -451,13 +453,35 @@ const Dashboard: React.FunctionComponent = () => {
451
453
< Spinner aria-label = "Loading data" />
452
454
</ Bullseye >
453
455
) : (
454
- < Table
455
- variant = { TableVariant . compact }
456
- cells = { columns }
457
- rows = { rows }
458
- >
459
- < TableHeader />
460
- < TableBody />
456
+ < Table aria-label = "imported-must-gathers" >
457
+ < Thead >
458
+ < Tr >
459
+ < Th > { columnNames . name } </ Th >
460
+ < Th > { columnNames . gatherTime } </ Th >
461
+ < Th > { columnNames . importTime } </ Th >
462
+ < Th > { columnNames . insightsData } </ Th >
463
+ </ Tr >
464
+ </ Thead >
465
+ < Tbody >
466
+ { importedMustGathers . data . map ( ( mustGather ) => (
467
+ < Tr
468
+ key = { mustGather . name }
469
+ onRowClick = { ( ) => setMustGatherInsightData ( mustGather . insightsData ) }
470
+ isSelectable
471
+ isHoverable = { mustGather . insightsData !== undefined && mustGather . insightsData !== null }
472
+ >
473
+ < Td dataLabel = { columnNames . name } > { mustGather . name } </ Td >
474
+ < Td dataLabel = { columnNames . gatherTime } > { new Date ( mustGather . gatherTime ) . toLocaleString ( ) } </ Td >
475
+ < Td dataLabel = { columnNames . importTime } > { new Date ( mustGather . importTime ) . toLocaleString ( ) } </ Td >
476
+ < Td dataLabel = { columnNames . insightsData } > {
477
+ mustGather . insightsData === undefined || mustGather . insightsData === null ?
478
+ < span > -</ span >
479
+ :
480
+ insightsIcons ( mustGather . insightsData )
481
+ } </ Td >
482
+ </ Tr >
483
+ ) ) }
484
+ </ Tbody >
461
485
</ Table >
462
486
)
463
487
}
@@ -468,19 +492,24 @@ const Dashboard: React.FunctionComponent = () => {
468
492
469
493
const reportTable = ( report ) => {
470
494
return (
471
- < div className = "pf-u-mt-xl" >
472
- < Title headingLevel = "h2" size = "md" > { report [ "key" ] } ({ report [ "type" ] } - { report [ "component" ] } )</ Title >
473
-
495
+ < ExpandableSection
496
+ key = { report [ "key" ] }
497
+ className = "pf-u-mt-xl"
498
+ toggleContent = {
499
+ < Alert isInline isPlain variant = "danger" title = { `[FAIL] ${ report [ "key" ] } (${ report [ "type" ] } - ${ report [ "component" ] } )` } ouiaId = "DangerAlert" />
500
+ }
501
+ >
474
502
< CodeBlock className = "pf-u-mt-sm" >
475
- < CodeBlockCode id = "code-content" > { JSON . stringify ( report , null , 2 ) } </ CodeBlockCode >
503
+ < CodeBlockCode id = "code-content" > { JSON . stringify ( report [ "details" ] , null , 2 ) } </ CodeBlockCode >
476
504
</ CodeBlock >
477
- </ div >
505
+ </ ExpandableSection >
478
506
)
479
507
}
480
508
481
509
const mustGatherInsightsDataModalContent = ( data ) => {
482
510
const metadata = data [ "analysis_metadata" ]
483
511
const plugins = metadata [ "plugin_sets" ]
512
+ const reports = data [ "reports" ]
484
513
485
514
return (
486
515
< >
@@ -497,7 +526,11 @@ const Dashboard: React.FunctionComponent = () => {
497
526
</ SimpleListGroup >
498
527
</ SimpleList >
499
528
500
- { data [ "reports" ] . map ( ( report ) => reportTable ( report ) ) }
529
+ { reports . length === 0 ?
530
+ < Alert variant = "success" title = "All rules passed" ouiaId = "SuccessAlert" />
531
+ :
532
+ reports . map ( ( report ) => reportTable ( report ) )
533
+ }
501
534
</ >
502
535
)
503
536
}
@@ -540,17 +573,19 @@ const Dashboard: React.FunctionComponent = () => {
540
573
{ mustGatherInsightsDataModal ( ) }
541
574
542
575
< Grid hasGutter >
576
+ { /* line 0 */ }
577
+ < GridItem span = { 12 } > { importedMustGathersCard ( ) } </ GridItem >
578
+
543
579
{ /* line 1 */ }
544
580
< GridItem span = { 6 } > { clusterInventoryCard ( ) } </ GridItem >
545
- < GridItem span = { 6 } > { importedMustGathersCard ( ) } </ GridItem >
581
+ < GridItem span = { 6 } > { nodesStatusCard ( ) } </ GridItem >
546
582
547
583
{ /* line 2 */ }
548
584
< GridItem span = { 6 } > { subscriptionsCard ( ) } </ GridItem >
549
585
< GridItem span = { 6 } > { virtualMachineInstancesCard ( ) } </ GridItem >
550
586
551
587
{ /* line 3 */ }
552
588
< GridItem span = { 6 } > { podsCard ( ) } </ GridItem >
553
- < GridItem span = { 6 } > { nodesStatusCard ( ) } </ GridItem >
554
589
</ Grid >
555
590
</ PageSection >
556
591
</ Page >
0 commit comments