@@ -4,11 +4,13 @@ import { CephBlockPoolRadosNamespaceModel } from '@odf/shared';
4
4
import { healthStateMapping , HealthStateMappingValues } from '@odf/shared' ;
5
5
import { getLatestDate } from '@odf/shared/details-page/datetime' ;
6
6
import { getName , getNamespace } from '@odf/shared/selectors' ;
7
+ import { GrayUnknownIcon } from '@odf/shared/status/icons' ;
7
8
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook' ;
8
9
import { referenceForModel } from '@odf/shared/utils' ;
9
10
import {
10
11
StatusIconAndText ,
11
12
useK8sWatchResource ,
13
+ HealthState ,
12
14
} from '@openshift-console/dynamic-plugin-sdk' ;
13
15
import * as _ from 'lodash-es' ;
14
16
import { TFunction } from 'react-i18next' ;
@@ -41,20 +43,29 @@ import { getColor } from './states';
41
43
import { ImageStateLegendMap , healthStateMessage } from './states' ;
42
44
import './mirroring-card.scss' ;
43
45
46
+ const defaultState = {
47
+ priority : - 1 ,
48
+ health : HealthState . UNKNOWN ,
49
+ icon : < GrayUnknownIcon title = "Unknown" /> ,
50
+ } ;
51
+
44
52
const aggregateHealth = (
45
53
poolObj : StoragePoolKind ,
46
54
radosNamespaces : CephBlockPoolRadosNamespaceKind [ ]
47
55
) : HealthStateMappingValues [ ] => {
48
56
let mirroringHealth : HealthStateMappingValues =
49
- healthStateMapping [ poolObj . status ?. mirroringStatus ?. summary ?. health ] ;
57
+ healthStateMapping [ poolObj . status ?. mirroringStatus ?. summary ?. health ] ||
58
+ defaultState ;
50
59
let imageHealth : HealthStateMappingValues =
51
- healthStateMapping [ poolObj . status ?. mirroringStatus ?. summary ?. image_health ] ;
60
+ healthStateMapping [
61
+ poolObj . status ?. mirroringStatus ?. summary ?. image_health
62
+ ] || defaultState ;
52
63
radosNamespaces . forEach ( ( radosNamespace ) => {
53
64
// Mirroring health
54
65
const radosNamespaceMirroringHealth : HealthStateMappingValues =
55
66
healthStateMapping [
56
67
radosNamespace . status ?. mirroringStatus ?. summary ?. health
57
- ] ;
68
+ ] || defaultState ;
58
69
if ( ! ! radosNamespaceMirroringHealth ) {
59
70
mirroringHealth =
60
71
mirroringHealth . priority > radosNamespaceMirroringHealth . priority
@@ -66,7 +77,7 @@ const aggregateHealth = (
66
77
const radosNamespaceImageHealth : HealthStateMappingValues =
67
78
healthStateMapping [
68
79
radosNamespace . status ?. mirroringStatus ?. summary ?. image_health
69
- ] ;
80
+ ] || defaultState ;
70
81
if ( ! ! radosNamespaceImageHealth ) {
71
82
imageHealth =
72
83
imageHealth . priority > radosNamespaceImageHealth . priority
0 commit comments