diff --git a/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.tsx b/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.tsx index af17f90634..5c9cd5825b 100644 --- a/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.tsx @@ -16,6 +16,7 @@ import { SecurityFields, useAlerts, useFormikAutoSave, + ClustersAPI, } from '../../../../common'; import { useDefaultConfiguration } from '../ClusterDefaultConfigurationContext'; import { useClusterWizardContext } from '../../clusterWizard/ClusterWizardContext'; @@ -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; @@ -65,6 +67,9 @@ const NetworkConfigurationForm: React.FC<{ useFormikContext(); 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 @@ -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 = ( clusterWizardContext.moveNext()} + onNext={() => void onNext()} onBack={() => clusterWizardContext.moveBack()} isBackDisabled={isSubmitting || isAutoSaveRunning} /> diff --git a/libs/ui-lib/lib/ocm/components/clusterWizard/HostDiscovery.tsx b/libs/ui-lib/lib/ocm/components/clusterWizard/HostDiscovery.tsx index 7d9056441a..dc3e4b5f82 100644 --- a/libs/ui-lib/lib/ocm/components/clusterWizard/HostDiscovery.tsx +++ b/libs/ui-lib/lib/ocm/components/clusterWizard/HostDiscovery.tsx @@ -8,7 +8,6 @@ import { useAlerts, getHostDiscoveryInitialValues, useFormikAutoSave, - ClustersAPI, } from '../../../common'; import HostInventory from '../clusterConfiguration/HostInventory'; import { useClusterWizardContext } from './ClusterWizardContext'; @@ -23,7 +22,6 @@ import { Cluster, V2ClusterUpdateParams, } from '@openshift-assisted/types/assisted-installer-service'; -import { useFeature } from '../../hooks/use-feature'; const HostDiscoveryForm = ({ cluster }: { cluster: Cluster }) => { const { alerts } = useAlerts(); @@ -31,9 +29,6 @@ const HostDiscoveryForm = ({ cluster }: { cluster: Cluster }) => { 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 || @@ -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 = ( void onNext()} + onNext={() => clusterWizardContext.moveNext()} onBack={() => clusterWizardContext.moveBack()} isBackDisabled={isSubmitting || isAutoSaveRunning} />