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
1 change: 1 addition & 0 deletions libs/locales/lib/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@
"ai:Service networks": "Service networks",
"ai:Set <bold>{{agent_location_label_key}}</bold> label in Agent resource to specify its location.": "Set <bold>{{agent_location_label_key}}</bold> label in Agent resource to specify its location.",
"ai:Set all the hosts to boot using iPXE script file": "Set all the hosts to boot using iPXE script file",
"ai:Show all available versions": "Show all available versions",
"ai:Show proxy settings": "Show proxy settings",
"ai:Single node cluster cannot contain more than 1 host.": "Single node cluster cannot contain more than 1 host.",
"ai:Single Node OpenShift disclaimer": "Single Node OpenShift disclaimer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
cpuArchitectures,
allowHighlyAvailable,
}) => {
const { values } = useFormikContext<ClusterDetailsValues>();
const { values, setFieldValue } = useFormikContext<ClusterDetailsValues>();
const { name, baseDnsDomain } = values;
const [openshiftVersionModalOpen, setOpenshiftVersionModalOpen] = React.useState(false);

Expand All @@ -68,6 +68,15 @@ export const ClusterDetailsFormFields: React.FC<ClusterDetailsFormFieldsProps> =
[versions],
);

React.useEffect(() => {
if (!versions.length && !values.openshiftVersion) {
const fallbackOpenShiftVersion = allVersions.find((version) => version.default);
setFieldValue('customOpenshiftSelect', fallbackOpenShiftVersion);
setFieldValue('openshiftVersion', fallbackOpenShiftVersion?.value);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const additionalSelectOptions = React.useMemo(() => {
if (
values.customOpenshiftSelect &&
Expand Down
20 changes: 10 additions & 10 deletions libs/ui-lib/lib/common/components/ui/OpenShiftVersionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const OpenShiftVersionDropdown = ({
const [isOpen, setOpen] = React.useState(false);
const { t } = useTranslation();
const fieldId = getFieldId(name, 'input');
const isDisabled = versions.length === 0;
const {
values: { customOpenshiftSelect },
} = useFormikContext<ClusterDetailsValues>();
Expand Down Expand Up @@ -107,28 +106,30 @@ export const OpenShiftVersionDropdown = ({
{dropdownItems}
</DropdownGroup>
),
<DropdownGroup label="Custom releases" key="custom-releases">
{customDropdownItems}
</DropdownGroup>,
customDropdownItems.length && (
<DropdownGroup label="Custom releases" key="custom-releases">
{customDropdownItems}
</DropdownGroup>
),
<DropdownGroup key="all-available-versions">
<DropdownItem key="all-versions" id="all-versions">
<DropdownItem key="all-versions" id="all-versions" onSelect={(e) => e.preventDefault()}>
<Button
variant="link"
isInline
onClick={() => showOpenshiftVersionModal()}
id="show-all-versions"
>
Show all available versions
{t('ai:Show all available versions')}
</Button>
</DropdownItem>
</DropdownGroup>,
];
].filter(Boolean);

const onSelect = React.useCallback(
(event?: React.MouseEvent<Element, MouseEvent>, val?: string | number) => {
const newLabel = event?.currentTarget.textContent;
const newValue = (val as string) || '';
if (newLabel && newValue !== 'all-versions') {
if (newLabel && event.currentTarget.id !== 'all-versions') {
setCurrent(newLabel);
setValue(newValue);
setOpen(false);
Expand All @@ -144,10 +145,9 @@ export const OpenShiftVersionDropdown = ({
ref={toggleRef}
isFullWidth
onClick={() => setOpen(!isOpen)}
isDisabled={isDisabled}
isExpanded={isOpen}
>
{current}
{current || t('ai:OpenShift version')}
</MenuToggle>
);

Expand Down
Loading