Skip to content

Commit 5f65989

Browse files
authored
Merge branch 'master' into add-reset-button-to-disconnected-assisted-installer-ui
2 parents 4ba0545 + 2aca314 commit 5f65989

File tree

5 files changed

+34
-32
lines changed

5 files changed

+34
-32
lines changed

libs/locales/lib/en/translation.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@
841841
"ai:This IP is being allocated by the DHCP server": "This IP is being allocated by the DHCP server",
842842
"ai:This IP was allocated by the DHCP server.": "This IP was allocated by the DHCP server.",
843843
"ai:This name will replace the original discovered hostname.": "This name will replace the original discovered hostname.",
844-
"ai:This option is not available for Nutanix platform": "This option is not available for Nutanix platform",
844+
"ai:This option is not available with the selected OpenShift version": "This option is not available with the selected OpenShift version",
845845
"ai:This option is not editable after the draft cluster is created": "This option is not editable after the draft cluster is created",
846846
"ai:this script.": "this script.",
847847
"ai:This stage may take a while to finish. To view detailed information, click the events log link below.": "This stage might take a while to finish. To view detailed information, click the events log link.",

libs/ui-lib/lib/cim/components/ClusterDeployment/ClusterDeploymentDetailsForm.tsx

+12-15
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import {
1717
ClusterDetailsFormFieldsProps,
1818
} from './ClusterDetailsFormFields';
1919
import { useFormikContext } from 'formik';
20-
import { ClusterDetailsValues, CpuArchitecture, SupportedCpuArchitecture } from '../../../common';
20+
import { ClusterDetailsValues, CpuArchitecture } from '../../../common';
2121
import { ClusterDeploymentWizardContext } from './ClusterDeploymentWizardContext';
2222
import { ValidationSection } from './components/ValidationSection';
23+
import { toNumber } from 'lodash-es';
2324

2425
type ClusterDeploymentDetailsFormProps = {
2526
clusterImages: ClusterImageSetK8sResource[];
@@ -109,22 +110,17 @@ const ClusterDeploymentDetailsForm: React.FC<ClusterDeploymentDetailsFormProps>
109110

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

112-
const cpuArchitectures = React.useMemo(() => {
113+
const [cpuArchitectures, allowHighlyAvailable] = React.useMemo(() => {
113114
const cpuArchitectures = [CpuArchitecture.x86, CpuArchitecture.ARM, CpuArchitecture.s390x];
114-
if (!osImages) {
115-
return cpuArchitectures;
116-
}
117-
118-
const openshiftVersion = versions
119-
.find((ver) => ver.value === values.openshiftVersion)
120-
?.version.split('.')
121-
.slice(0, 2)
122-
.join('.');
115+
const version = allVersions.find((ver) => ver.value === values.openshiftVersion);
116+
const isMulti = version?.cpuArchitectures?.[0] === CpuArchitecture.MULTI;
123117

124-
return osImages
125-
.filter((osImage) => osImage.openshiftVersion === openshiftVersion)
126-
.map((osImage) => osImage.cpuArchitecture as SupportedCpuArchitecture);
127-
}, [osImages, versions, values.openshiftVersion]);
118+
const highlyAvailableSupported = toNumber(version?.version?.split('.')?.[1]) >= 18;
119+
return [
120+
isMulti ? cpuArchitectures : version?.cpuArchitectures,
121+
highlyAvailableSupported && !isMulti,
122+
];
123+
}, [allVersions, values.openshiftVersion]);
128124

129125
return (
130126
<>
@@ -146,6 +142,7 @@ const ClusterDeploymentDetailsForm: React.FC<ClusterDeploymentDetailsFormProps>
146142
extensionAfter={extensionAfter}
147143
isNutanix={isNutanix}
148144
cpuArchitectures={cpuArchitectures}
145+
allowHighlyAvailable={allowHighlyAvailable}
149146
/>
150147
</StackItem>
151148
</>

libs/ui-lib/lib/cim/components/ClusterDeployment/ClusterDetailsFormFields.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type ClusterDetailsFormFieldsProps = {
2424
allVersions: OpenshiftVersionOptionType[];
2525
isNutanix?: boolean;
2626
cpuArchitectures?: string[];
27+
allowHighlyAvailable?: boolean;
2728
};
2829

2930
export const BaseDnsHelperText: React.FC<{ name?: string; baseDnsDomain?: string }> = ({
@@ -52,6 +53,7 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
5253
extensionAfter,
5354
isNutanix,
5455
cpuArchitectures,
56+
allowHighlyAvailable,
5557
}) => {
5658
const { values } = useFormikContext<ClusterDetailsValues>();
5759
const { name, baseDnsDomain } = values;
@@ -146,7 +148,10 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
146148
)}
147149
</>
148150
)}
149-
<ControlPlaneNodesDropdown isNutanix={isNutanix} isDisabled={isEditFlow} />
151+
<ControlPlaneNodesDropdown
152+
isDisabled={isEditFlow}
153+
allowHighlyAvailable={allowHighlyAvailable}
154+
/>
150155
{!isNutanix && (
151156
<CpuArchitectureDropdown cpuArchitectures={cpuArchitectures} isDisabled={isEditFlow} />
152157
)}

libs/ui-lib/lib/cim/components/helpers/versions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const getSelectedVersion = (
113113
);
114114

115115
return selectedClusterImage
116-
? getOCPVersions([selectedClusterImage])?.[0]?.version
116+
? getOCPVersions([selectedClusterImage], undefined, undefined, true)?.[0]?.version
117117
: agentClusterInstall?.spec?.imageSetRef?.name;
118118
};
119119

libs/ui-lib/lib/common/components/clusterConfiguration/ControlPlaneNodesDropdown.tsx

+14-14
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ interface ControlPlaneNodesOption {
1111
label: string;
1212
}
1313

14-
const isDropdownItemEnabled = (controlPlaneNodeCount: number, isNutanix?: boolean): boolean => {
15-
return (controlPlaneNodeCount === 1 && !isNutanix) || controlPlaneNodeCount !== 1;
16-
};
17-
1814
const ControlPlaneNodesDropdown = ({
1915
isDisabled = false,
20-
isNutanix,
16+
allowHighlyAvailable,
2117
}: {
2218
isDisabled?: boolean;
23-
isNutanix?: boolean;
19+
allowHighlyAvailable?: boolean;
2420
}) => {
2521
const { t } = useTranslation();
26-
const [{ name, value: selectedValue }, , { setValue }] = useField<number | 3>(
27-
'controlPlaneCount',
28-
);
22+
const [{ name, value: selectedValue }, , { setValue }] = useField<number>('controlPlaneCount');
23+
const [controlPlanelOpen, setControlPlanelOpen] = React.useState(false);
24+
const fieldId = getFieldId(name, 'input');
2925

3026
const options: ControlPlaneNodesOption[] = [
3127
{ value: 1, label: t('ai:1 (Single Node OpenShift - not highly available cluster)') },
@@ -34,14 +30,21 @@ const ControlPlaneNodesDropdown = ({
3430
{ value: 5, label: t('ai:5 (highly available cluster++)') },
3531
];
3632

33+
React.useEffect(() => {
34+
if (!allowHighlyAvailable && [4, 5].includes(selectedValue)) {
35+
setValue(3);
36+
}
37+
}, [allowHighlyAvailable, selectedValue, setValue]);
38+
3739
const dropdownItems = options.map(({ value, label }) => {
38-
const isItemEnabled = isDropdownItemEnabled(value, isNutanix);
39-
const disabledReason = t('ai:This option is not available for Nutanix platform');
40+
const isItemEnabled = [1, 3].includes(value) || allowHighlyAvailable;
41+
const disabledReason = t('ai:This option is not available with the selected OpenShift version');
4042
return (
4143
<DropdownItem
4244
key={value}
4345
id={value.toString()}
4446
isAriaDisabled={!isItemEnabled}
47+
isDisabled={!isItemEnabled}
4548
selected={selectedValue === value}
4649
value={value}
4750
>
@@ -52,9 +55,6 @@ const ControlPlaneNodesDropdown = ({
5255
);
5356
});
5457

55-
const [controlPlanelOpen, setControlPlanelOpen] = React.useState(false);
56-
const fieldId = getFieldId(name, 'input');
57-
5858
const onControlPlaneSelect = (e?: React.SyntheticEvent<HTMLDivElement>) => {
5959
const val = e?.currentTarget.id as string;
6060
setValue(toNumber(val));

0 commit comments

Comments
 (0)