Skip to content

Commit

Permalink
webui: fix logic for when to re-create the partitioning
Browse files Browse the repository at this point in the history
  • Loading branch information
KKoukiou committed Aug 2, 2023
1 parent 04656ae commit 56454f5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ui/webui/src/components/storage/MountPointMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,31 @@ const MountPointMappingContent = ({ deviceData, partitioningData, dispatch, idPr
}
};

const getDeviceChildren = ({ deviceData, device }) => {
const children = [];
const deviceChildren = deviceData[device]?.children?.v || [];

if (deviceChildren.length === 0) {
children.push(device);
} else {
deviceChildren.forEach(child => {
children.push(...getDeviceChildren({ deviceData, device: child }));
});
}

return children;
};

export const MountPointMapping = ({ deviceData, diskSelection, partitioningData, dispatch, idPrefix, setIsFormValid, onAddErrorNotification, stepNotification }) => {
const [creatingPartitioning, setCreatingPartitioning] = useState(true);

// If device selection changed since the last partitioning request redo the partitioning
const selectedDevices = diskSelection.selectedDisks;
const partitioningDevices = partitioningData?.requests?.map(r => r["device-spec"]) || [];
const canReusePartitioning = selectedDevices.length === partitioningDevices.length && selectedDevices.every(d => partitioningDevices.includes(d));
const selectedDeviceChildren = selectedDevices
.map(device => getDeviceChildren({ deviceData, device }))
.flat(1);
const canReusePartitioning = selectedDeviceChildren.length === partitioningDevices.length && selectedDeviceChildren.every(d => partitioningDevices.includes(d));

useEffect(() => {
if (canReusePartitioning) {
Expand Down

0 comments on commit 56454f5

Please sign in to comment.