refactor(striker-ui): rename HTML input variables to improve readability

main
Tsu-ba-me 3 years ago
parent 092f57927f
commit 2f215f2de6
  1. 74
      striker-ui/components/ProvisionServerDialog.tsx

@ -1003,11 +1003,11 @@ const ProvisionServerDialog = ({
SelectItem[] SelectItem[]
>([]); >([]);
const [cpuCoresValue, setCPUCoresValue] = useState<number>(1); const [inputCPUCoresValue, setInputCPUCoresValue] = useState<number>(1);
const [inputCPUCoresMax, setInputCPUCoresMax] = useState<number>(0); const [inputCPUCoresMax, setInputCPUCoresMax] = useState<number>(0);
const [memoryValue, setMemoryValue] = useState<bigint>(BIGINT_ZERO); const [memory, setMemory] = useState<bigint>(BIGINT_ZERO);
const [memoryValueMax, setMemoryValueMax] = useState<bigint>(BIGINT_ZERO); const [memoryMax, setMemoryMax] = useState<bigint>(BIGINT_ZERO);
const [inputMemoryMax, setInputMemoryMax] = useState<string>('0'); const [inputMemoryMax, setInputMemoryMax] = useState<string>('0');
const [inputMemoryValue, setInputMemoryValue] = useState<string>(''); const [inputMemoryValue, setInputMemoryValue] = useState<string>('');
const [inputMemoryUnit, setInputMemoryUnit] = useState<DataSizeUnit>('B'); const [inputMemoryUnit, setInputMemoryUnit] = useState<DataSizeUnit>('B');
@ -1016,10 +1016,12 @@ const ProvisionServerDialog = ({
addVirtualDisk(), addVirtualDisk(),
); );
const [installISOFileUUID, setInstallISOFileUUID] = useState<string>(''); const [inputInstallISOFileUUID, setInputInstallISOFileUUID] =
const [driverISOFileUUID, setDriverISOFileUUID] = useState<string>(''); useState<string>('');
const [inputDriverISOFileUUID, setInputDriverISOFileUUID] =
useState<string>('');
const [anvilValue, setAnvilValue] = useState<string>(''); const [inputAnvilValue, setInputAnvilValue] = useState<string>('');
const [includeAnvilUUIDs, setIncludeAnvilUUIDs] = useState<string[]>([]); const [includeAnvilUUIDs, setIncludeAnvilUUIDs] = useState<string[]>([]);
const [includeFileUUIDs, setIncludeFileUUIDs] = useState<string[]>([]); const [includeFileUUIDs, setIncludeFileUUIDs] = useState<string[]>([]);
@ -1029,13 +1031,13 @@ const ProvisionServerDialog = ({
const updateLimits: UpdateLimitsFunction = ({ const updateLimits: UpdateLimitsFunction = ({
allAnvils: ulAllAnvils = allAnvils, allAnvils: ulAllAnvils = allAnvils,
cpuCores: ulCPUCores = cpuCoresValue, cpuCores: ulCPUCores = inputCPUCoresValue,
fileUUIDs: ulFileUUIDs = [installISOFileUUID, driverISOFileUUID], fileUUIDs: ulFileUUIDs = [inputInstallISOFileUUID, inputDriverISOFileUUID],
includeAnvilUUIDs: ulIncludeAnvilUUIDs = filterBlanks([anvilValue]), includeAnvilUUIDs: ulIncludeAnvilUUIDs = filterBlanks([inputAnvilValue]),
includeFileUUIDs: ulIncludeFileUUIDs, includeFileUUIDs: ulIncludeFileUUIDs,
includeStorageGroupUUIDs: ulIncludeStorageGroupUUIDs, includeStorageGroupUUIDs: ulIncludeStorageGroupUUIDs,
inputMemoryUnit: ulInputMemoryUnit = inputMemoryUnit, inputMemoryUnit: ulInputMemoryUnit = inputMemoryUnit,
memory: ulMemory = memoryValue, memory: ulMemory = memory,
storageGroupUUIDMapToFree: storageGroupUUIDMapToFree:
ulStorageGroupUUIDMapToFree = storageGroupUUIDMapToFree, ulStorageGroupUUIDMapToFree = storageGroupUUIDMapToFree,
virtualDisks: ulVirtualDisks = virtualDisks, virtualDisks: ulVirtualDisks = virtualDisks,
@ -1063,7 +1065,7 @@ const ProvisionServerDialog = ({
); );
setInputCPUCoresMax(maxCPUCores); setInputCPUCoresMax(maxCPUCores);
setMemoryValueMax(maxMemory); setMemoryMax(maxMemory);
ulVirtualDisks.maxes = maxVirtualDiskSizes; ulVirtualDisks.maxes = maxVirtualDiskSizes;
setVirtualDisks({ ...ulVirtualDisks }); setVirtualDisks({ ...ulVirtualDisks });
@ -1102,11 +1104,11 @@ const ProvisionServerDialog = ({
dSizeToBytes( dSizeToBytes(
value, value,
unit, unit,
(convertedMemoryValue) => { (convertedMemory) => {
setMemoryValue(convertedMemoryValue); setMemory(convertedMemory);
updateLimits({ updateLimits({
memory: convertedMemoryValue, memory: convertedMemory,
}); });
}, },
() => () =>
@ -1116,26 +1118,26 @@ const ProvisionServerDialog = ({
); );
}; };
const handleInstallISOFileUUIDChange = (uuid: string) => { const handleInputInstallISOFileUUIDChange = (uuid: string) => {
setInstallISOFileUUID(uuid); setInputInstallISOFileUUID(uuid);
updateLimits({ updateLimits({
fileUUIDs: [uuid, driverISOFileUUID], fileUUIDs: [uuid, inputDriverISOFileUUID],
}); });
}; };
const handleDriverISOFileUUIDChange = (uuid: string) => { const handleInputDriverISOFileUUIDChange = (uuid: string) => {
setDriverISOFileUUID(uuid); setInputDriverISOFileUUID(uuid);
updateLimits({ updateLimits({
fileUUIDs: [installISOFileUUID, uuid], fileUUIDs: [inputInstallISOFileUUID, uuid],
}); });
}; };
const handleAnvilValueChange = (uuid: string) => { const handleInputAnvilValueChange = (uuid: string) => {
const havcIncludeAnvilUUIDs = filterBlanks([uuid]); const havcIncludeAnvilUUIDs = filterBlanks([uuid]);
setAnvilValue(uuid); setInputAnvilValue(uuid);
updateLimits({ updateLimits({
includeAnvilUUIDs: havcIncludeAnvilUUIDs, includeAnvilUUIDs: havcIncludeAnvilUUIDs,
@ -1204,13 +1206,13 @@ const ProvisionServerDialog = ({
}} }}
> >
<OutlinedInputWithLabel id="ps-server-name" label="Server name" /> <OutlinedInputWithLabel id="ps-server-name" label="Server name" />
{createOutlinedSlider('ps-cpu-cores', 'CPU cores', cpuCoresValue, { {createOutlinedSlider('ps-cpu-cores', 'CPU cores', inputCPUCoresValue, {
sliderProps: { sliderProps: {
onChange: (value) => { onChange: (value) => {
const newCPUCoresValue = value as number; const newCPUCoresValue = value as number;
if (newCPUCoresValue !== cpuCoresValue) { if (newCPUCoresValue !== inputCPUCoresValue) {
setCPUCoresValue(newCPUCoresValue); setInputCPUCoresValue(newCPUCoresValue);
updateLimits({ updateLimits({
cpuCores: newCPUCoresValue, cpuCores: newCPUCoresValue,
@ -1222,7 +1224,7 @@ const ProvisionServerDialog = ({
}, },
})} })}
<BodyText <BodyText
text={`Memory: ${memoryValue.toString()}, Max: ${memoryValueMax.toString()}`} text={`Memory: ${memory.toString()}, Max: ${memoryMax.toString()}`}
/> />
{createOutlinedInputWithSelect('ps-memory', 'Memory', DATA_SIZE_UNITS, { {createOutlinedInputWithSelect('ps-memory', 'Memory', DATA_SIZE_UNITS, {
inputWithLabelProps: { inputWithLabelProps: {
@ -1276,10 +1278,11 @@ const ProvisionServerDialog = ({
onChange: ({ target: { value } }) => { onChange: ({ target: { value } }) => {
const newInstallISOFileUUID = value as string; const newInstallISOFileUUID = value as string;
handleInstallISOFileUUIDChange(newInstallISOFileUUID); handleInputInstallISOFileUUIDChange(newInstallISOFileUUID);
}, },
onClearIndicatorClick: () => handleInstallISOFileUUIDChange(''), onClearIndicatorClick: () =>
value: installISOFileUUID, handleInputInstallISOFileUUIDChange(''),
value: inputInstallISOFileUUID,
}, },
}, },
)} )}
@ -1293,10 +1296,11 @@ const ProvisionServerDialog = ({
onChange: ({ target: { value } }) => { onChange: ({ target: { value } }) => {
const newDriverISOFileUUID = value as string; const newDriverISOFileUUID = value as string;
handleDriverISOFileUUIDChange(newDriverISOFileUUID); handleInputDriverISOFileUUIDChange(newDriverISOFileUUID);
}, },
onClearIndicatorClick: () => handleDriverISOFileUUIDChange(''), onClearIndicatorClick: () =>
value: driverISOFileUUID, handleInputDriverISOFileUUIDChange(''),
value: inputDriverISOFileUUID,
}, },
}, },
)} )}
@ -1306,10 +1310,10 @@ const ProvisionServerDialog = ({
onChange: ({ target: { value } }) => { onChange: ({ target: { value } }) => {
const newAnvilUUID: string = value as string; const newAnvilUUID: string = value as string;
handleAnvilValueChange(newAnvilUUID); handleInputAnvilValueChange(newAnvilUUID);
}, },
onClearIndicatorClick: () => handleAnvilValueChange(''), onClearIndicatorClick: () => handleInputAnvilValueChange(''),
value: anvilValue, value: inputAnvilValue,
}, },
})} })}
<Autocomplete <Autocomplete

Loading…
Cancel
Save