Skip to content

Commit 5bbf48e

Browse files
committed
Address PR review feedback
- Use ?? instead of || for count/length in StatusCard computed - Add .filter((c) => c) to workload cards getter for null safety - Initialize summaries.pods = null explicitly when no pod selector - Use normalizedType in useResourceSummary dispatch for consistency
1 parent 7627de0 commit 5bbf48e

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

shell/components/Resource/Detail/Card/StateCard/composables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export function useResourceSummary(type: string, opt: ResourceSummaryOpt) {
293293
const id = ++fetchId;
294294

295295
try {
296-
const result = await store.dispatch('cluster/fetchResourceSummary', { type, opt });
296+
const result = await store.dispatch('cluster/fetchResourceSummary', { type: normalizedType, opt });
297297

298298
if (id !== fetchId) {
299299
return;

shell/components/Resource/Detail/Card/StatusCard/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ const percent = (count: number, total: number) => {
106106
107107
const count = computed(() => {
108108
if (summaryStateCounts.value) {
109-
return props.summaryData?.count || 0;
109+
return props.summaryData?.count ?? 0;
110110
}
111111
112-
return props.resources?.length || 0;
112+
return props.resources?.length ?? 0;
113113
});
114114
115115
const segmentColors = computed(() => Object.keys(segmentAccumulator.value) as StateColor[]);

shell/models/workload.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ export default class Workload extends WorkloadService {
595595

596596
const podSelectorStr = this.podSelector;
597597

598+
summaries.pods = null;
599+
598600
if (podSelectorStr) {
599601
const filters = [nsFilter];
600602

@@ -931,6 +933,6 @@ export default class Workload extends WorkloadService {
931933
this.resourcesCard,
932934
this.insightCard,
933935
...this._cards
934-
];
936+
].filter((c) => c);
935937
}
936938
}

0 commit comments

Comments
 (0)