diff --git a/libs/ui-lib/lib/ocm/hooks/useInfraEnvId.ts b/libs/ui-lib/lib/ocm/hooks/useInfraEnvId.ts index 8dca06a67a..1e9ddd2c40 100644 --- a/libs/ui-lib/lib/ocm/hooks/useInfraEnvId.ts +++ b/libs/ui-lib/lib/ocm/hooks/useInfraEnvId.ts @@ -55,12 +55,12 @@ export default function useInfraEnvId( ]); React.useEffect(() => { - if (!clusterId) { + if (!clusterId && !isSingleClusterFeatureEnabled) { setError('Missing clusterId to load infrastructure environment'); } else if (!infraEnvId) { void findInfraEnvId(); } - }, [clusterId, findInfraEnvId, infraEnvId]); + }, [clusterId, findInfraEnvId, infraEnvId, isSingleClusterFeatureEnabled]); return { infraEnvId, error }; } diff --git a/libs/ui-lib/lib/ocm/services/InfraEnvsService.ts b/libs/ui-lib/lib/ocm/services/InfraEnvsService.ts index d122399700..35d5f7ceae 100644 --- a/libs/ui-lib/lib/ocm/services/InfraEnvsService.ts +++ b/libs/ui-lib/lib/ocm/services/InfraEnvsService.ts @@ -21,7 +21,10 @@ const InfraEnvsService = { const { data: infraEnvs } = await InfraEnvsAPI.list( !isSingleClusterFeatureEnabled ? clusterId : '', ); - if (infraEnvs.length > 0) { + if (isSingleClusterFeatureEnabled) { + return infraEnvs[0].id; + } + if (infraEnvs.length > 0 && clusterId) { InfraEnvCache.updateInfraEnvs(clusterId, infraEnvs); infraEnvId = InfraEnvCache.getInfraEnvId(clusterId, cpuArchitecture); }