Skip to content

Commit baf1cb3

Browse files
authored
Upgrade risk widget should show total clusters with risk not percent (stolostron#3713)
Signed-off-by: zlayne <zlayne@redhat.com>
1 parent e18cf07 commit baf1cb3

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

frontend/public/locales/en/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@
680680
"Cluster landscape": "Cluster landscape",
681681
"Cluster list": "Cluster list",
682682
"Cluster name": "Cluster name",
683+
"cluster needs to be reviewed before updating": "cluster needs to be reviewed before updating",
683684
"Cluster network host prefix": "Cluster network host prefix",
684685
"Cluster node pools": "Cluster node pools",
685686
"Cluster OS image": "Cluster OS image",
@@ -745,6 +746,7 @@
745746
"clusterPools": "Cluster pools",
746747
"Clusters": "Clusters",
747748
"clusters affected": "clusters affected",
749+
"clusters need to be reviewed before updating": "clusters need to be reviewed before updating",
748750
"Clusters with pending policies": "Clusters with pending policies",
749751
"Clusters with policy violations": "Clusters with policy violations",
750752
"Clusters without policy violations": "Clusters without policy violations",

frontend/src/routes/Home/Overview/OverviewPageBeta.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default function OverviewPageBeta(props: { selectedClusterLabels: Record<
216216
}
217217
}, [managedClusterIds])
218218

219-
const { criticalUpdateCount, warningUpdateCount, infoUpdateCount, percentOfClustersWithRisk } = useMemo(() => {
219+
const { criticalUpdateCount, warningUpdateCount, infoUpdateCount, clustersWithRiskPredictors } = useMemo(() => {
220220
const reducedUpgradeRiskPredictions = upgradeRiskPredictions.reduce((acc: any[], curr: any) => {
221221
if (curr.body && curr.body.predictions) {
222222
return [...acc, ...curr.body.predictions]
@@ -451,8 +451,11 @@ export default function OverviewPageBeta(props: { selectedClusterLabels: Record<
451451
</Popover>
452452
}
453453
summaryTotalHeader={{
454-
num: `${percentOfClustersWithRisk}%`,
455-
text: 'of clusters need to be reviewed before updating',
454+
num: `${clustersWithRiskPredictors}`,
455+
text:
456+
clustersWithRiskPredictors === 1
457+
? t('cluster needs to be reviewed before updating')
458+
: t('clusters need to be reviewed before updating'),
456459
}}
457460
summaryData={[
458461
{ icon: <CriticalRiskIcon />, label: t('Critical'), count: criticalUpdateCount },

frontend/src/routes/Home/Overview/__snapshots__/overviewDataFunctions.test.tsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,18 @@ Object {
168168

169169
exports[`Correctly returns parseUpgradeRiskPredictions with no predictions 1`] = `
170170
Object {
171+
"clustersWithRiskPredictors": 0,
171172
"criticalUpdateCount": 0,
172173
"infoUpdateCount": 0,
173-
"percentOfClustersWithRisk": 0,
174174
"warningUpdateCount": 0,
175175
}
176176
`;
177177

178178
exports[`Correctly returns parseUpgradeRiskPredictions with predictions 1`] = `
179179
Object {
180+
"clustersWithRiskPredictors": 2,
180181
"criticalUpdateCount": 1,
181182
"infoUpdateCount": 1,
182-
"percentOfClustersWithRisk": 50,
183183
"warningUpdateCount": 1,
184184
}
185185
`;

frontend/src/routes/Home/Overview/overviewDataFunctions.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,10 @@ export function parseUpgradeRiskPredictions(upgradeRiskPredictions: any) {
143143
let criticalUpdateCount = 0
144144
let warningUpdateCount = 0
145145
let infoUpdateCount = 0
146-
let percentOfClustersWithRisk = 0
147-
let totalClusters = 0
148146
let clustersWithRiskPredictors = 0
149147

150148
if (upgradeRiskPredictions.length > 0) {
151149
upgradeRiskPredictions.forEach((cluster: any) => {
152-
totalClusters++
153150
if (
154151
cluster.upgrade_risks_predictors &&
155152
cluster.upgrade_risks_predictors.alerts &&
@@ -172,14 +169,12 @@ export function parseUpgradeRiskPredictions(upgradeRiskPredictions: any) {
172169
}
173170
})
174171
}
175-
if (totalClusters > 0) {
176-
percentOfClustersWithRisk = parseFloat(((clustersWithRiskPredictors / totalClusters) * 100).toFixed(1))
177-
}
172+
178173
return {
179174
criticalUpdateCount,
180175
warningUpdateCount,
181176
infoUpdateCount,
182-
percentOfClustersWithRisk,
177+
clustersWithRiskPredictors,
183178
}
184179
}
185180

0 commit comments

Comments
 (0)