Skip to content

Commit

Permalink
MGMT-17540: Remove unnecessary calls to openshift-versions API in clu…
Browse files Browse the repository at this point in the history
…ster creation page [FOLLOWUP, BACKPORT 2.33] (#2639)

* Fix issues with the Openshift versions context in Day2

* Fix day2 tests
  • Loading branch information
jgyselov authored Jul 12, 2024
1 parent 0b0fe5e commit 051009e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 0 additions & 1 deletion libs/ui-lib-tests/cypress/support/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -155,15 +156,17 @@ export const HostsClusterDetailTabContent = ({
ocpConsoleUrl={ocmCluster?.console?.url}
canEdit={ocmCluster.canEdit}
>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingState />}
cluster={day2Cluster}
cpuArchitecture={infraEnv?.cpuArchitecture as CpuArchitecture}
openshiftVersion={day2Cluster.openshiftVersion}
platformType={day2Cluster.platform?.type}
>
<AddHosts />
</NewFeatureSupportLevelProvider>
<OpenshiftVersionsContextProvider>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingState />}
cluster={day2Cluster}
cpuArchitecture={infraEnv?.cpuArchitecture as CpuArchitecture}
openshiftVersion={day2Cluster.openshiftVersion}
platformType={day2Cluster.platform?.type}
>
<AddHosts />
</NewFeatureSupportLevelProvider>
</OpenshiftVersionsContextProvider>
</AddHostsContextProvider>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -138,28 +139,30 @@ const AssistedInstallerDetailCard = ({
const isOutdatedClusterData = uiState === ResourceUIState.POLLING_ERROR;
return (
<AlertsContextProvider>
<SentryErrorMonitorContextProvider>
<ModalDialogsContextProvider>
<ClusterDefaultConfigurationProvider
loadingUI={<LoadingCard />}
errorUI={<LoadingDefaultConfigFailedCard />}
>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingCard />}
cluster={cluster}
cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture}
openshiftVersion={cluster.openshiftVersion}
platformType={cluster.platform?.type}
<OpenshiftVersionsContextProvider>
<SentryErrorMonitorContextProvider>
<ModalDialogsContextProvider>
<ClusterDefaultConfigurationProvider
loadingUI={<LoadingCard />}
errorUI={<LoadingDefaultConfigFailedCard />}
>
{content}
</NewFeatureSupportLevelProvider>
{isOutdatedClusterData && <ClusterPollingErrorModal />}
<CancelInstallationModal />
<ResetClusterModal />
<DiscoveryImageModal />
</ClusterDefaultConfigurationProvider>
</ModalDialogsContextProvider>
</SentryErrorMonitorContextProvider>
<NewFeatureSupportLevelProvider
loadingUi={<LoadingCard />}
cluster={cluster}
cpuArchitecture={infraEnv.cpuArchitecture as CpuArchitecture}
openshiftVersion={cluster.openshiftVersion}
platformType={cluster.platform?.type}
>
{content}
</NewFeatureSupportLevelProvider>
{isOutdatedClusterData && <ClusterPollingErrorModal />}
<CancelInstallationModal />
<ResetClusterModal />
<DiscoveryImageModal />
</ClusterDefaultConfigurationProvider>
</ModalDialogsContextProvider>
</SentryErrorMonitorContextProvider>
</OpenshiftVersionsContextProvider>
</AlertsContextProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,12 +54,16 @@ const AssistedInstallerExtraDetailCard: React.FC<AssistedInstallerExtraDetailCar
);
};

const Wrapper: React.FC<AssistedInstallerExtraDetailCardProps> = (props) => (
<Provider store={storeDay1}>
<AlertsContextProvider>
<AssistedInstallerExtraDetailCard {...props} />
</AlertsContextProvider>
</Provider>
);
const Wrapper: React.FC<AssistedInstallerExtraDetailCardProps> = (props) => {
return (
<Provider store={storeDay1}>
<AlertsContextProvider>
<OpenshiftVersionsContextProvider>
<AssistedInstallerExtraDetailCard {...props} />
</OpenshiftVersionsContextProvider>
</AlertsContextProvider>
</Provider>
);
};

export default Wrapper;

0 comments on commit 051009e

Please sign in to comment.