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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
SecurityFields,
useAlerts,
useFormikAutoSave,
ClustersAPI,
} from '../../../../common';
import { useDefaultConfiguration } from '../ClusterDefaultConfigurationContext';
import { useClusterWizardContext } from '../../clusterWizard/ClusterWizardContext';
Expand Down Expand Up @@ -45,6 +46,7 @@ import {
V2ClusterUpdateParams,
} from '@openshift-assisted/types/assisted-installer-service';
import { useNewFeatureSupportLevel } from '../../../../common/components/newFeatureSupportLevels';
import { useFeature } from '../../../hooks/use-feature';

const NetworkConfigurationForm: React.FC<{
cluster: Cluster;
Expand All @@ -65,6 +67,9 @@ const NetworkConfigurationForm: React.FC<{
useFormikContext<NetworkConfigurationValues>();
const isAutoSaveRunning = useFormikAutoSave();
const errorFields = getFormikErrorFields(errors, touched);
const isSingleClusterFeatureEnabled = useFeature('ASSISTED_INSTALLER_SINGLE_CLUSTER_FEATURE');
const { addAlert } = useAlerts();
const dispatch = useDispatch();

// DHCP allocation is currently not supported for Nutanix hosts
// https://issues.redhat.com/browse/MGMT-12382
Expand All @@ -79,6 +84,29 @@ const NetworkConfigurationForm: React.FC<{
}
}, [isHostsPlatformTypeNutanix, setFieldValue, values.vipDhcpAllocation]);

const onNext = React.useCallback(async () => {
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;
}
}
clusterWizardContext.moveNext();
}, [addAlert, cluster.id, clusterWizardContext, dispatch, isSingleClusterFeatureEnabled]);

const footer = (
<ClusterWizardFooter
cluster={cluster}
Expand All @@ -91,7 +119,7 @@ const NetworkConfigurationForm: React.FC<{
!isValid ||
!canNextNetwork({ cluster })
}
onNext={() => clusterWizardContext.moveNext()}
onNext={() => void onNext()}
onBack={() => clusterWizardContext.moveBack()}
isBackDisabled={isSubmitting || isAutoSaveRunning}
/>
Expand Down
30 changes: 1 addition & 29 deletions libs/ui-lib/lib/ocm/components/clusterWizard/HostDiscovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
useAlerts,
getHostDiscoveryInitialValues,
useFormikAutoSave,
ClustersAPI,
} from '../../../common';
import HostInventory from '../clusterConfiguration/HostInventory';
import { useClusterWizardContext } from './ClusterWizardContext';
Expand All @@ -23,17 +22,13 @@ import {
Cluster,
V2ClusterUpdateParams,
} from '@openshift-assisted/types/assisted-installer-service';
import { useFeature } from '../../hooks/use-feature';

const HostDiscoveryForm = ({ cluster }: { cluster: Cluster }) => {
const { alerts } = useAlerts();
const { errors, touched, isSubmitting, isValid } = useFormikContext<HostDiscoveryValues>();
const clusterWizardContext = useClusterWizardContext();
const isAutoSaveRunning = useFormikAutoSave();
const errorFields = getFormikErrorFields(errors, touched);
const isSingleClusterFeatureEnabled = useFeature('ASSISTED_INSTALLER_SINGLE_CLUSTER_FEATURE');
const { addAlert } = useAlerts();
const dispatch = useDispatch();

const isNextDisabled =
!isValid ||
Expand All @@ -42,36 +37,13 @@ const HostDiscoveryForm = ({ cluster }: { cluster: Cluster }) => {
isSubmitting ||
!canNextHostDiscovery({ cluster });

const onNext = React.useCallback(async () => {
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;
}
}
clusterWizardContext.moveNext();
}, [addAlert, cluster.id, clusterWizardContext, dispatch, isSingleClusterFeatureEnabled]);

const footer = (
<ClusterWizardFooter
cluster={cluster}
errorFields={errorFields}
isSubmitting={isSubmitting}
isNextDisabled={isNextDisabled}
onNext={() => void onNext()}
onNext={() => clusterWizardContext.moveNext()}
onBack={() => clusterWizardContext.moveBack()}
isBackDisabled={isSubmitting || isAutoSaveRunning}
/>
Expand Down
Loading