Skip to content

Commit

Permalink
Unfilter OS dropdown in VM wizard when choosing flavor or workload
Browse files Browse the repository at this point in the history
When switching OS, the flavor and workload will be set to NULL
thus the user would have to pick suitable flavor & workload
for the new OS.

Signed-off-by: Ido Rosenzwig <irosenzw@redhat.com>
  • Loading branch information
irosenzw committed Aug 13, 2020
1 parent bfb5f0c commit 1753dee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Expand Up @@ -156,11 +156,22 @@ const osUpdater = ({ id, prevState, dispatch, getState }: UpdateOptions) => {
const isWindows = os?.startsWith('win');

dispatch(
vmWizardInternalActions[InternalActionType.UpdateVmSettingsField](
id,
VMSettingsField.MOUNT_WINDOWS_GUEST_TOOLS,
{ isHidden: asHidden(!isWindows, VMSettingsField.OPERATING_SYSTEM), value: isWindows },
),
vmWizardInternalActions[InternalActionType.UpdateVmSettings](id, {
[VMSettingsField.MOUNT_WINDOWS_GUEST_TOOLS]: {
isHidden: asHidden(!isWindows, VMSettingsField.OPERATING_SYSTEM),
value: isWindows,
},
[VMSettingsField.WORKLOAD_PROFILE]: { value: null },
[VMSettingsField.FLAVOR]: { value: null },
[VMSettingsField.MEMORY]: {
isHidden: asHidden(true, VMSettingsField.FLAVOR),
isRequired: asRequired(false, VMSettingsField.FLAVOR),
},
[VMSettingsField.CPU]: {
isHidden: asHidden(true, VMSettingsField.FLAVOR),
isRequired: asRequired(false, VMSettingsField.FLAVOR),
},
}),
);
};

Expand Down
Expand Up @@ -81,7 +81,7 @@ export const OSFlavor: React.FC<OSFlavorProps> = React.memo(
operatingSystems = [{ name: display, id: display }];
} else {
operatingSystems = openshiftFlag
? ignoreCaseSort(getOperatingSystems(vanillaTemplates, params), ['name'])
? ignoreCaseSort(getOperatingSystems(vanillaTemplates, params.userTemplate), ['name'])
: operatingSystemsNative;
}

Expand Down
Expand Up @@ -34,22 +34,13 @@ export const getFlavorLabel = (flavor: string) => {
return undefined;
};

export const getOperatingSystems = (
templates: TemplateKind[],
{ workload, flavor, userTemplate }: { workload: string; flavor: string; userTemplate: string },
) => {
let templatesWithLabels;
export const getOperatingSystems = (templates: TemplateKind[], userTemplate: string) => {
if (userTemplate) {
templatesWithLabels = [
return getTemplateOperatingSystems([
getTemplatesOfLabelType(templates, TEMPLATE_TYPE_VM).find((t) => getName(t) === userTemplate),
];
} else {
templatesWithLabels = getTemplatesWithLabels(
getTemplatesOfLabelType(templates, TEMPLATE_TYPE_BASE),
[getWorkloadLabel(workload), getFlavorLabel(flavor)],
);
]);
}
return getTemplateOperatingSystems(templatesWithLabels);
return getTemplateOperatingSystems(getTemplatesOfLabelType(templates, TEMPLATE_TYPE_BASE));
};

export const getWorkloadProfiles = (
Expand Down

0 comments on commit 1753dee

Please sign in to comment.