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 @@ -14,7 +14,7 @@ import {
OsImage,
} from '../../../types';
import { ClusterImageSetK8sResource } from '../../../types/k8s/cluster-image-set';
import { getOCPVersions, getSelectedVersion } from '../../helpers';
import { getOCPVersions } from '../../helpers';
import { useTranslation } from '../../../../common/hooks/use-translation-wrapper';
import {
ClusterDetailsFormFields,
Expand Down Expand Up @@ -46,17 +46,14 @@ export const ClusterDeploymentDetailsFormWrapper = ({
}) => {
const { activeStep, goToPrevStep, goToNextStep, close } = useWizardContext();
const { syncError } = React.useContext(ClusterDeploymentWizardContext);
const { submitForm, isSubmitting, isValid, isValidating, dirty } =
useFormikContext<ClusterDetailsValues>();
const { isSubmitting, isValid, isValidating } = useFormikContext<ClusterDetailsValues>();
const { t } = useTranslation();

// ClusterDeploymentDetailsFormWrapper is exclusively used by ClusterDeploymentWizard (edit flow).
// No form submission needed here—just navigate to the next step.
const handleOnNext = React.useCallback(() => {
if (dirty) {
void submitForm();
} else {
void goToNextStep();
}
}, [dirty, goToNextStep, submitForm]);
void goToNextStep();
}, [goToNextStep]);

const footer = React.useMemo(
() => (
Expand Down Expand Up @@ -93,7 +90,6 @@ export const ClusterDeploymentDetailsFormWrapper = ({
};

export const ClusterDeploymentDetailsForm: React.FC<ClusterDeploymentDetailsFormProps> = ({
agentClusterInstall,
clusterDeployment,
clusterImages,
extensionAfter,
Expand All @@ -111,26 +107,21 @@ export const ClusterDeploymentDetailsForm: React.FC<ClusterDeploymentDetailsForm
[clusterImages, isNutanix, osImages],
);

const forceOpenshiftVersion = agentClusterInstall
? getSelectedVersion(clusterImages, agentClusterInstall)
: undefined;
const isEditFlow = !!clusterDeployment;

const { values } = useFormikContext<ClusterDetailsValues>();

const [cpuArchitectures, allowHighlyAvailable] = React.useMemo(() => {
const cpuArchitectures = [CpuArchitecture.x86, CpuArchitecture.ARM, CpuArchitecture.s390x];
const version = allVersions.find(
(ver) => ver.value === values.openshiftVersion || ver.version === forceOpenshiftVersion,
);
const version = allVersions.find((ver) => ver.value === values.openshiftVersion);
const isMulti = version?.cpuArchitectures?.[0] === CpuArchitecture.MULTI;

const highlyAvailableSupported = toNumber(version?.version?.split('.')?.[1]) >= 18;
return [
(isMulti ? cpuArchitectures : version?.cpuArchitectures) as SupportedCpuArchitecture[],
highlyAvailableSupported && !isMulti,
];
}, [allVersions, forceOpenshiftVersion, values.openshiftVersion]);
}, [allVersions, values.openshiftVersion]);

return (
<>
Expand All @@ -148,7 +139,6 @@ export const ClusterDeploymentDetailsForm: React.FC<ClusterDeploymentDetailsForm
versions={versions}
allVersions={allVersions}
isEditFlow={isEditFlow}
forceOpenshiftVersion={forceOpenshiftVersion}
extensionAfter={extensionAfter}
isNutanix={isNutanix}
cpuArchitectures={cpuArchitectures}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { getNetworkType } from '../../helpers';

export type ClusterDetailsFormFieldsProps = {
isEditFlow: boolean;
forceOpenshiftVersion?: string;
extensionAfter?: { [key: string]: React.ReactElement };
versions: OpenshiftVersionOptionType[];
allVersions: OpenshiftVersionOptionType[];
Expand Down Expand Up @@ -52,7 +51,6 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
isEditFlow,
versions,
allVersions,
forceOpenshiftVersion,
extensionAfter,
isNutanix,
cpuArchitectures,
Expand All @@ -65,7 +63,7 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
const { name, baseDnsDomain } = values;

React.useEffect(() => {
if (!versions.length && !values.openshiftVersion) {
if (!versions.length && !values.openshiftVersion && !isEditFlow) {
const fallbackOpenShiftVersion = allVersions.find((version) => version.default);
setFieldValue('customOpenshiftSelect', fallbackOpenShiftVersion?.value);
setFieldValue('openshiftVersion', fallbackOpenShiftVersion?.value);
Expand Down Expand Up @@ -140,9 +138,11 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
isRequired
/>
)}
{forceOpenshiftVersion ? (
{isEditFlow ? (
<StaticTextField name="openshiftVersion" label="OpenShift version" isRequired>
{t('ai:OpenShift')} {forceOpenshiftVersion}
{t('ai:OpenShift')}{' '}
{allVersions.find((v) => v.value === values.openshiftVersion)?.version ||
values.openshiftVersion}
</StaticTextField>
) : (
<>
Expand Down
Loading