Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libs/ui-lib/lib/common/api/assisted-service/ClustersAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ const ClustersAPI = {
params,
);
},

updateInstallConfig(clusterId: Cluster['id'], config: string) {
return client.patch(`${ClustersAPI.makeBaseURI(clusterId)}/install-config`, config, {
headers: { 'Content-Type': 'application/json' },
});
},
};

export default ClustersAPI;
30 changes: 28 additions & 2 deletions libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { useLocation, useNavigate } from 'react-router-dom-v5-compat';
import { useDispatch } from 'react-redux';
import { useAlerts, LoadingState, ClusterWizardStep, ErrorState } from '../../../common';
import { usePullSecret } from '../../hooks';
import { getApiErrorMessage, handleApiError, isUnknownServerError } from '../../../common/api';
import {
ClustersAPI,
getApiErrorMessage,
handleApiError,
isUnknownServerError,
} from '../../../common/api';
import { setServerUpdateError, updateCluster } from '../../store/slices/current-cluster/slice';
import { useClusterWizardContext } from './ClusterWizardContext';
import { canNextClusterDetails, ClusterWizardFlowStateNew } from './wizardTransition';
Expand All @@ -18,6 +23,7 @@ import {
UISettingService,
} from '../../services';
import { Cluster, InfraEnv } from '@openshift-assisted/types/assisted-installer-service';
import { useFeature } from '../../hooks/use-feature';

type ClusterDetailsProps = {
cluster?: Cluster;
Expand All @@ -38,6 +44,7 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
latestVersions: versions,
} = useOpenShiftVersionsContext();
const location = useLocation();
const isSingleClusterFeatureEnabled = useFeature('ASSISTED_INSTALLER_SINGLE_CLUSTER_FEATURE');

const handleClusterUpdate = React.useCallback(
async (
Expand Down Expand Up @@ -76,6 +83,25 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
const searchParams = new URLSearchParams(location.search);
const isAssistedMigration = searchParams.get('source') === 'assisted_migration';
const cluster = await ClustersService.create(params, isAssistedMigration);
if (isSingleClusterFeatureEnabled) {
try {
await ClustersAPI.updateInstallConfig(
cluster.id,
JSON.stringify(JSON.stringify({ featureSet: 'TechPreviewNoUpgrade' })),
);
} catch (e) {
handleApiError(e, () =>
addAlert({
title: 'Failed to update install-config',
message: getApiErrorMessage(e),
}),
);
if (isUnknownServerError(e as Error)) {
dispatch(setServerUpdateError());
}
return;
}
}
navigate(`../${cluster.id}`, { state: ClusterWizardFlowStateNew });
await UISettingService.update(cluster.id, { addCustomManifests });
//TO-DO: Assisted-Migration. Provisional code. Needs to be removed when MTV integration be finished
Expand All @@ -91,7 +117,7 @@ const ClusterDetails = ({ cluster, infraEnv }: ClusterDetailsProps) => {
}
}
},
[clearAlerts, location.search, navigate, addAlert, dispatch],
[clearAlerts, location.search, navigate, addAlert, dispatch, isSingleClusterFeatureEnabled],
);

const navigation = <ClusterWizardNavigation cluster={cluster} />;
Expand Down
Loading