Skip to content

Commit 146ad3d

Browse files
Merge pull request #3321 from galkremer1/CNV-75833-fix-useClusterObservabilityDisabled
CNV-75833: useClusterObservabilityDisabled should only be used in ACM
2 parents bab684d + a6f1c8a commit 146ad3d

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/utils/hooks/useAlerts/useAlerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const useAlerts: UseAlerts = () => {
103103
return {
104104
alerts: allAlerts,
105105
error: observabilityError || (isACMPage ? metricError : singleClusterAlerts.error),
106-
loaded: isACMPage ? metricLoaded : singleClusterAlerts.loaded,
106+
loaded: isACMPage ? metricLoaded && observabilityLoaded : singleClusterAlerts.loaded,
107107
};
108108
};
109109

src/utils/hooks/useAlerts/utils/useClusterObservabilityDisabled.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { modelToGroupVersionKind } from '@kubevirt-ui-ext/kubevirt-api/console';
44
import useKubevirtWatchResource from '@kubevirt-utils/hooks/useKubevirtWatchResource/useKubevirtWatchResource';
55
import { getLabel, getName } from '@kubevirt-utils/resources/shared';
66
import { ManagedClusterModel } from '@multicluster/constants';
7+
import useIsACMPage from '@multicluster/useIsACMPage';
78
import { K8sResourceCommon } from '@openshift-console/dynamic-plugin-sdk';
89
import { useHubClusterName } from '@stolostron/multicluster-sdk';
910

@@ -33,6 +34,7 @@ export const useClusterObservabilityDisabled = (
3334
error: Error | unknown;
3435
loaded: boolean;
3536
} => {
37+
const isACMPage = useIsACMPage();
3638
const [hubClusterName] = useHubClusterName();
3739

3840
const [managedClusterData, loaded, loadError] = useKubevirtWatchResource<
@@ -46,7 +48,7 @@ export const useClusterObservabilityDisabled = (
4648
const { cnvInstalledClusters, loaded: cnvLoaded } = useClusterCNVInstalled();
4749

4850
const { disabledClusters, enabledClusters: rawEnabledClusters } = useMemo(() => {
49-
if (!managedClusterData) {
51+
if (!isACMPage || !managedClusterData) {
5052
return { disabledClusters: [], enabledClusters: [] };
5153
}
5254

@@ -79,7 +81,7 @@ export const useClusterObservabilityDisabled = (
7981
});
8082

8183
return { disabledClusters: disabled, enabledClusters: enabled };
82-
}, [managedClusterData]);
84+
}, [isACMPage, managedClusterData]);
8385

8486
const enabledClusters = useMemo(() => {
8587
if (!onlyCNVClusters || !cnvLoaded) {
@@ -88,6 +90,16 @@ export const useClusterObservabilityDisabled = (
8890
return rawEnabledClusters.filter((clusterName) => cnvInstalledClusters.includes(clusterName));
8991
}, [onlyCNVClusters, cnvLoaded, rawEnabledClusters, cnvInstalledClusters]);
9092

93+
// For non-ACM pages, return loaded=true immediately to avoid blocking consumers
94+
if (!isACMPage) {
95+
return {
96+
disabledClusters: [],
97+
enabledClusters: [],
98+
error: undefined,
99+
loaded: true,
100+
};
101+
}
102+
91103
return {
92104
disabledClusters,
93105
enabledClusters,

src/views/clusteroverview/MigrationsTab/hooks/useMigrationCardData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const useMigrationCardDataAndFilters: UseMigrationCardDataAndFilters = (duration
119119

120120
return {
121121
filters,
122-
loaded: vmimsLoaded && vmisLoaded,
122+
loaded: vmimsLoaded && vmisLoaded && observabilityLoaded,
123123
loadErrors: observabilityError || vmimsErrors || vmisErrors,
124124
migrationsTableFilteredData: data,
125125
migrationsTableUnfilteredData: unfilteredData,

src/views/clusteroverview/OverviewTab/vm-statuses-card/VMStatusesCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const VMStatusesCard: FC = () => {
6868
const { otherStatuses, otherStatusesCount, primaryStatuses } = getVMStatuses(vms || []);
6969

7070
const displayError = observabilityError || error;
71+
const isLoaded = loaded && observabilityLoaded;
7172

7273
return (
7374
<Card className="vm-statuses-card" data-test-id="vm-statuses-card">
@@ -79,12 +80,12 @@ const VMStatusesCard: FC = () => {
7980
<ErrorAlert error={displayError} />
8081
</CardBody>
8182
)}
82-
{!loaded && !displayError && (
83+
{!isLoaded && !displayError && (
8384
<CardBody>
8485
<LoadingEmptyState />
8586
</CardBody>
8687
)}
87-
{loaded && (
88+
{isLoaded && (
8889
<>
8990
<div className="vm-statuses-card__body">
9091
<Grid hasGutter>

0 commit comments

Comments
 (0)