Skip to content

Commit 4f4a7de

Browse files
Merge pull request #2131 from SanjalKatiyar/mirroring_dashboard
Fix BlockPool dashboard - mirroring card
2 parents 84da487 + bc96021 commit 4f4a7de

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/ocs/dashboards/block-pool/mirroring-card.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { CephBlockPoolRadosNamespaceModel } from '@odf/shared';
44
import { healthStateMapping, HealthStateMappingValues } from '@odf/shared';
55
import { getLatestDate } from '@odf/shared/details-page/datetime';
66
import { getName, getNamespace } from '@odf/shared/selectors';
7+
import { GrayUnknownIcon } from '@odf/shared/status/icons';
78
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
89
import { referenceForModel } from '@odf/shared/utils';
910
import {
1011
StatusIconAndText,
1112
useK8sWatchResource,
13+
HealthState,
1214
} from '@openshift-console/dynamic-plugin-sdk';
1315
import * as _ from 'lodash-es';
1416
import { TFunction } from 'react-i18next';
@@ -41,20 +43,29 @@ import { getColor } from './states';
4143
import { ImageStateLegendMap, healthStateMessage } from './states';
4244
import './mirroring-card.scss';
4345

46+
const defaultState = {
47+
priority: -1,
48+
health: HealthState.UNKNOWN,
49+
icon: <GrayUnknownIcon title="Unknown" />,
50+
};
51+
4452
const aggregateHealth = (
4553
poolObj: StoragePoolKind,
4654
radosNamespaces: CephBlockPoolRadosNamespaceKind[]
4755
): HealthStateMappingValues[] => {
4856
let mirroringHealth: HealthStateMappingValues =
49-
healthStateMapping[poolObj.status?.mirroringStatus?.summary?.health];
57+
healthStateMapping[poolObj.status?.mirroringStatus?.summary?.health] ||
58+
defaultState;
5059
let imageHealth: HealthStateMappingValues =
51-
healthStateMapping[poolObj.status?.mirroringStatus?.summary?.image_health];
60+
healthStateMapping[
61+
poolObj.status?.mirroringStatus?.summary?.image_health
62+
] || defaultState;
5263
radosNamespaces.forEach((radosNamespace) => {
5364
// Mirroring health
5465
const radosNamespaceMirroringHealth: HealthStateMappingValues =
5566
healthStateMapping[
5667
radosNamespace.status?.mirroringStatus?.summary?.health
57-
];
68+
] || defaultState;
5869
if (!!radosNamespaceMirroringHealth) {
5970
mirroringHealth =
6071
mirroringHealth.priority > radosNamespaceMirroringHealth.priority
@@ -66,7 +77,7 @@ const aggregateHealth = (
6677
const radosNamespaceImageHealth: HealthStateMappingValues =
6778
healthStateMapping[
6879
radosNamespace.status?.mirroringStatus?.summary?.image_health
69-
];
80+
] || defaultState;
7081
if (!!radosNamespaceImageHealth) {
7182
imageHealth =
7283
imageHealth.priority > radosNamespaceImageHealth.priority

0 commit comments

Comments
 (0)