From 051009eb04cead4fcc5be4f600ec53720474797c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julie=20Gyselov=C3=A1?= Date: Fri, 12 Jul 2024 13:49:15 +0200 Subject: [PATCH] MGMT-17540: Remove unnecessary calls to openshift-versions API in cluster creation page [FOLLOWUP, BACKPORT 2.33] (#2639) * Fix issues with the Openshift versions context in Day2 * Fix day2 tests --- .../integration/day-2/1-first-access.cy.ts | 2 - .../cypress/support/interceptors.ts | 1 - .../HostsClusterDetailTabContent.tsx | 21 +++++---- .../AssistedInstallerDetailCard.tsx | 45 ++++++++++--------- .../AssistedInstallerExtraDetailCard.tsx | 19 +++++--- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/libs/ui-lib-tests/cypress/integration/day-2/1-first-access.cy.ts b/libs/ui-lib-tests/cypress/integration/day-2/1-first-access.cy.ts index 368caa10b6..327850486d 100644 --- a/libs/ui-lib-tests/cypress/integration/day-2/1-first-access.cy.ts +++ b/libs/ui-lib-tests/cypress/integration/day-2/1-first-access.cy.ts @@ -39,8 +39,6 @@ describe(`Day2 flow`, () => { }); it('Creates a Day2 cluster when the cluster has metrics', () => { - Cypress.env('OPENSHIFT_VERSIONS_DELAY', true); - cy.findByRole('button', { name: 'Add hosts (With metrics)' }).click(); cy.wait('@create-day2-cluster').then(() => { setLastWizardSignal('CREATED_DAY2_CLUSTER'); diff --git a/libs/ui-lib-tests/cypress/support/interceptors.ts b/libs/ui-lib-tests/cypress/support/interceptors.ts index 7cbd05b0b1..99914eba07 100644 --- a/libs/ui-lib-tests/cypress/support/interceptors.ts +++ b/libs/ui-lib-tests/cypress/support/interceptors.ts @@ -366,7 +366,6 @@ const addPlatformFeatureIntercepts = () => { cy.intercept('GET', '/api/assisted-install/v2/openshift-versions*', (req) => { req.reply({ body: fixtures.openShiftVersions, - delay: Cypress.env('OPENSHIFT_VERSIONS_DELAY') ? 3 * 1000 : 0, }); }).as('openshift-versions'); diff --git a/libs/ui-lib/lib/ocm/components/HostsClusterDetailTab/HostsClusterDetailTabContent.tsx b/libs/ui-lib/lib/ocm/components/HostsClusterDetailTab/HostsClusterDetailTabContent.tsx index abf59b70cc..8f6a1fa422 100644 --- a/libs/ui-lib/lib/ocm/components/HostsClusterDetailTab/HostsClusterDetailTabContent.tsx +++ b/libs/ui-lib/lib/ocm/components/HostsClusterDetailTab/HostsClusterDetailTabContent.tsx @@ -23,6 +23,7 @@ import { import useInfraEnv from '../../hooks/useInfraEnv'; import { mapOcmArchToCpuArchitecture } from '../../services/CpuArchitectureService'; import { Cluster } from '@openshift-assisted/types/assisted-installer-service'; +import { OpenshiftVersionsContextProvider } from '../clusterWizard/OpenshiftVersionsContext'; export const HostsClusterDetailTabContent = ({ cluster: ocmCluster, @@ -155,15 +156,17 @@ export const HostsClusterDetailTabContent = ({ ocpConsoleUrl={ocmCluster?.console?.url} canEdit={ocmCluster.canEdit} > - } - cluster={day2Cluster} - cpuArchitecture={infraEnv?.cpuArchitecture as CpuArchitecture} - openshiftVersion={day2Cluster.openshiftVersion} - platformType={day2Cluster.platform?.type} - > - - + + } + cluster={day2Cluster} + cpuArchitecture={infraEnv?.cpuArchitecture as CpuArchitecture} + openshiftVersion={day2Cluster.openshiftVersion} + platformType={day2Cluster.platform?.type} + > + + + ); }; diff --git a/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerDetailCard.tsx b/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerDetailCard.tsx index ba842e3227..fea2a67fb1 100644 --- a/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerDetailCard.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerDetailCard.tsx @@ -30,6 +30,7 @@ import { usePullSecret } from '../../hooks'; import { Cluster } from '@openshift-assisted/types/assisted-installer-service'; import { useFeatureDetection } from '../../hooks/use-feature-detection'; import { BrowserRouter } from 'react-router-dom'; +import { OpenshiftVersionsContextProvider } from '../clusterWizard/OpenshiftVersionsContext'; type AssistedInstallerDetailCardProps = { aiClusterId: string; @@ -138,28 +139,30 @@ const AssistedInstallerDetailCard = ({ const isOutdatedClusterData = uiState === ResourceUIState.POLLING_ERROR; return ( - - - } - errorUI={} - > - } - cluster={cluster} - cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture} - openshiftVersion={cluster.openshiftVersion} - platformType={cluster.platform?.type} + + + + } + errorUI={} > - {content} - - {isOutdatedClusterData && } - - - - - - + } + cluster={cluster} + cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture} + openshiftVersion={cluster.openshiftVersion} + platformType={cluster.platform?.type} + > + {content} + + {isOutdatedClusterData && } + + + + + + + ); }; diff --git a/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerExtraDetailCard.tsx b/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerExtraDetailCard.tsx index 122136356a..ba2d9e185f 100644 --- a/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerExtraDetailCard.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterDetail/AssistedInstallerExtraDetailCard.tsx @@ -11,6 +11,7 @@ import useInfraEnv from '../../hooks/useInfraEnv'; import { usePullSecret } from '../../hooks'; import { selectCurrentClusterState } from '../../store/slices/current-cluster/selectors'; import { useFeatureDetection } from '../../hooks/use-feature-detection'; +import { OpenshiftVersionsContextProvider } from '../clusterWizard/OpenshiftVersionsContext'; type AssistedInstallerExtraDetailCardProps = { allEnabledFeatures: FeatureListType; @@ -53,12 +54,16 @@ const AssistedInstallerExtraDetailCard: React.FC = (props) => ( - - - - - -); +const Wrapper: React.FC = (props) => { + return ( + + + + + + + + ); +}; export default Wrapper;