fix(striker-ui): auto-select only prop in provision server

main
Tsu-ba-me 1 year ago
parent cfaa492a12
commit 8c380db940
  1. 43
      striker-ui/components/ProvisionServerDialog.tsx

@ -1500,10 +1500,51 @@ const ProvisionServerDialog = ({
setFileSelectItems(ueFileSelectItems); setFileSelectItems(ueFileSelectItems);
setStorageGroupSelectItems(ueStorageGroupSelectItems); setStorageGroupSelectItems(ueStorageGroupSelectItems);
initLimits({ const limits: Parameters<UpdateLimitsFunction>[0] = {
allAnvils: ueAllAnvils, allAnvils: ueAllAnvils,
storageGroupUUIDMapToData: ueStorageGroupUUIDMapToData, storageGroupUUIDMapToData: ueStorageGroupUUIDMapToData,
};
// Auto-select the only option when there's only 1.
// Reminder to update the form limits after changing any value.
if (ueAnvilSelectItems.length === 1) {
const {
0: { value: uuid },
} = ueAnvilSelectItems;
setInputAnvilValue(uuid);
limits.includeAnvilUUIDs = [uuid];
}
if (ueFileSelectItems.length === 1) {
const {
0: { value: uuid },
} = ueFileSelectItems;
setInputInstallISOFileUUID(uuid);
limits.fileUUIDs = [uuid, ''];
}
if (ueStorageGroupSelectItems.length === 1) {
const {
0: { value: uuid },
} = ueStorageGroupSelectItems;
setVirtualDisks((previous) => {
const current = { ...previous };
current.inputStorageGroupUUIDs[0] = uuid;
limits.virtualDisks = current;
return current;
}); });
}
initLimits(limits);
setOSAutocompleteOptions( setOSAutocompleteOptions(
Object.entries(data.oses as Record<string, string>).map( Object.entries(data.oses as Record<string, string>).map(

Loading…
Cancel
Save