diff --git a/pkg/harvester/components/health/ComponentChecksTable.vue b/pkg/harvester/components/health/ComponentChecksTable.vue index 419d843a..ce82acc2 100644 --- a/pkg/harvester/components/health/ComponentChecksTable.vue +++ b/pkg/harvester/components/health/ComponentChecksTable.vue @@ -10,7 +10,7 @@ import { _CREATE, _EDIT, _VIEW } from '@shell/config/query-params'; import { HCI } from '../../types'; import { AFFECTED_RESOURCES_TRUNCATE_COUNT, MESSAGE_TRUNCATE_LENGTH, activeAffectedResourceNames, affectedResourceLabel, - allAffectedResourceNames, ignoreRuleName, ignoredResourceCount, resourceIgnoredBy, severityColor + allAffectedResourceNames, hasIgnored, ignoreRuleName, ignoredResourceCount, resourceIgnoredBy, severityColor } from '../../utils/component-health'; const props = defineProps({ @@ -22,10 +22,6 @@ const props = defineProps({ type: Array, default: () => [], }, - showIgnored: { - type: Boolean, - default: false, - }, // what is typed in the filter box of the table this one sits in filterText: { type: String, @@ -133,9 +129,17 @@ const hasActions = computed(() => rowsWithActions.value.some((row) => row.availa const expandedMessageIds = ref([]); const expandedResourceIds = ref([]); +const shownIgnoredIds = ref([]); -function affectedResourceNames(row) { - return props.showIgnored ? allAffectedResourceNames(row) : activeAffectedResourceNames(row); +// a check ignored as a whole lists all its resources, the others only the ones still reported +function listedResourceNames(row) { + return row.ignored ? allAffectedResourceNames(row) : activeAffectedResourceNames(row); +} + +function ignoredResourceNames(row) { + const active = activeAffectedResourceNames(row); + + return allAffectedResourceNames(row).filter((name) => !active.includes(name)); } // called from the template, where the refs are unwrapped, so the array is changed in place @@ -157,23 +161,25 @@ function displayedMessage(row, message) { return expandedMessageIds.value.includes(row.id) || !isMessageTruncated(message) ? message : message.slice(0, MESSAGE_TRUNCATE_LENGTH); } +// the ignored resources come after the others, once their link is used function visibleAffectedResourceNames(row) { - const names = affectedResourceNames(row); + const names = listedResourceNames(row); + const shown = expandedResourceIds.value.includes(row.id) ? names : names.slice(0, AFFECTED_RESOURCES_TRUNCATE_COUNT); - return expandedResourceIds.value.includes(row.id) ? names : names.slice(0, AFFECTED_RESOURCES_TRUNCATE_COUNT); + return shownIgnoredIds.value.includes(row.id) ? [...shown, ...ignoredResourceNames(row)] : shown; } function remainingAffectedResourcesCount(row) { - return Math.max(affectedResourceNames(row).length - AFFECTED_RESOURCES_TRUNCATE_COUNT, 0); + return Math.max(listedResourceNames(row).length - AFFECTED_RESOURCES_TRUNCATE_COUNT, 0); } function isResourceIgnored(row, name) { return row.ignored || !!resourceIgnoredBy(row, name); } -// the ignored resources that are left out of the list -function hiddenIgnoredCount(row) { - return props.showIgnored ? 0 : ignoredResourceCount(row); +// the ignored resources of a check that is still reported, which have a link of their own +function ignoredLinkCount(row) { + return row.ignored ? 0 : ignoredResourceCount(row); } @@ -204,7 +210,7 @@ function hiddenIgnoredCount(row) { />