From 949afb4f626d0ddd951e40c964b5ff5909b08d95 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Mon, 2 May 2022 18:02:14 -0400 Subject: [PATCH] fix(striker-ui): add clear to file selects --- .../components/ProvisionServerDialog.tsx | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/striker-ui/components/ProvisionServerDialog.tsx b/striker-ui/components/ProvisionServerDialog.tsx index 260aa01c..50feb0a2 100644 --- a/striker-ui/components/ProvisionServerDialog.tsx +++ b/striker-ui/components/ProvisionServerDialog.tsx @@ -1064,6 +1064,42 @@ const ProvisionServerDialog = ({ ); }; + const handleInstallISOFileUUIDChange = (uuid: string) => { + setInstallISOFileUUID(uuid); + + updateLimits( + [ + allAnvils, + storageGroupUUIDMapToFree, + cpuCoresValue, + memoryValue, + virtualDisks.sizes, + virtualDisks.inputStorageGroupUUIDs, + [uuid, driverISOFileUUID], + ], + inputMemoryUnit, + virtualDisks, + ); + }; + + const handleDriverISOFileUUIDChange = (uuid: string) => { + setDriverISOFileUUID(uuid); + + updateLimits( + [ + allAnvils, + storageGroupUUIDMapToFree, + cpuCoresValue, + memoryValue, + virtualDisks.sizes, + virtualDisks.inputStorageGroupUUIDs, + [installISOFileUUID, uuid], + ], + inputMemoryUnit, + virtualDisks, + ); + }; + useEffect(() => { const data = MOCK_DATA; @@ -1245,21 +1281,10 @@ const ProvisionServerDialog = ({ onChange: ({ target: { value } }) => { const newInstallISOFileUUID = value as string; - setInstallISOFileUUID(newInstallISOFileUUID); - - updateLimits( - [ - allAnvils, - storageGroupUUIDMapToFree, - cpuCoresValue, - memoryValue, - virtualDisks.sizes, - virtualDisks.inputStorageGroupUUIDs, - [newInstallISOFileUUID, driverISOFileUUID], - ], - inputMemoryUnit, - virtualDisks, - ); + handleInstallISOFileUUIDChange(newInstallISOFileUUID); + }, + onClearIndicatorClick: () => { + handleInstallISOFileUUIDChange(''); }, value: installISOFileUUID, }, @@ -1275,21 +1300,10 @@ const ProvisionServerDialog = ({ onChange: ({ target: { value } }) => { const newDriverISOFileUUID = value as string; - setDriverISOFileUUID(newDriverISOFileUUID); - - updateLimits( - [ - allAnvils, - storageGroupUUIDMapToFree, - cpuCoresValue, - memoryValue, - virtualDisks.sizes, - virtualDisks.inputStorageGroupUUIDs, - [installISOFileUUID, newDriverISOFileUUID], - ], - inputMemoryUnit, - virtualDisks, - ); + handleDriverISOFileUUIDChange(newDriverISOFileUUID); + }, + onClearIndicatorClick: () => { + handleDriverISOFileUUIDChange(''); }, value: driverISOFileUUID, },