Skip to content

Commit

Permalink
webui: if device selection changed since last partitioning request re…
Browse files Browse the repository at this point in the history
…do the partitioning
  • Loading branch information
KKoukiou committed Jul 5, 2023
1 parent 2698770 commit 9630c50
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/webui/src/components/AnacondaWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const AnacondaWizard = ({ dispatch, storageData, localizationData, onAddE
label: _("Storage configuration")
}, {
component: CustomMountPoint,
data: { deviceData: storageData.devices, partitioningData: lastPartitioning, dispatch },
data: { deviceData: storageData.devices, diskSelection: storageData.diskSelection, partitioningData: lastPartitioning, dispatch },
id: "custom-mountpoint",
label: _("Custom mount point"),
isHidden: storageScenarioId !== "custom-mount-point"
Expand Down
11 changes: 8 additions & 3 deletions ui/webui/src/components/storage/CustomMountPoint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const MountpointCheckbox = ({ reformat, isRootMountPoint, handleCheckReFormat, p
);
};

export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPrefix, setIsFormValid, onAddErrorNotification, toggleContextHelp, stepNotification }) => {
export const CustomMountPoint = ({ deviceData, diskSelection, partitioningData, dispatch, idPrefix, setIsFormValid, onAddErrorNotification, toggleContextHelp, stepNotification }) => {
const [creatingPartitioning, setCreatingPartitioning] = useState(true);
useEffect(() => {
const validateMountPoints = requests => {
Expand All @@ -131,8 +131,13 @@ export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPre
validateMountPoints(partitioningData?.requests);
}, [partitioningData?.requests, setIsFormValid]);

// If device selection changed since the last partitioning request redo the partitioning
const selectedDevicesPaths = diskSelection.selectedDisks.map(d => deviceData[d].path.v) || [];
const partitioningDevicesPaths = partitioningData?.requests.map(r => r["device-spec"]) || [];
const canReusePartitioning = selectedDevicesPaths.length === partitioningDevicesPaths.length && selectedDevicesPaths.every(d => partitioningDevicesPaths.includes(d));

useEffect(() => {
if (partitioningData?.method === "MANUAL") {
if (canReusePartitioning) {
setCreatingPartitioning(false);
} else {
/* Reset the bootloader drive before we schedule partitions
Expand All @@ -145,7 +150,7 @@ export const CustomMountPoint = ({ deviceData, partitioningData, dispatch, idPre
.then(() => createPartitioning({ method: "MANUAL" }))
.then(() => setCreatingPartitioning(false));
}
}, [partitioningData?.method]);
}, [canReusePartitioning]);

if (creatingPartitioning) {
return <EmptyStatePanel loading />;
Expand Down
18 changes: 17 additions & 1 deletion ui/webui/test/check-storage
Original file line number Diff line number Diff line change
Expand Up @@ -536,18 +536,34 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
self.udevadm_settle()

partitions = {}
partitions[disk1] = [f"{disk1}2", f"{disk1}3"]

# Select first only vdb disk and verify that the partitioning request is correct
partitions[disk2] = [f"{disk2}1"]
self.select_mountpoint(i, s, [disk2], partitions)

self.check_partition(1, "/dev/vdb1")

# Go back and change the disk selection. The partitioning should be re-created
b.click("button:contains(Back)")
b.click("button:contains(Back)")
b.click("button:contains(Back)")

partitions[disk1] = [f"{disk1}2", f"{disk1}3"]
self.select_mountpoint(i, s, [disk1, disk2], partitions)

self.check_partition(1, "/dev/vda1")

self.check_partition(2, "/dev/vda2")
self.check_format_type(2, "xfs")
self.select_from_dropdown(2, "boot", "/boot")
self.check_reformat(2, False)

self.check_partition(3, "/dev/vda3")
self.check_format_type(3, "xfs")
self.select_from_dropdown(3, "root", "/")
self.check_reformat(3, True)

self.check_partition(4, "/dev/vdb1")
self.check_format_type(4, "xfs")
self.select_from_dropdown(4, "home", "/home")
self.check_reformat(4, False)
Expand Down

0 comments on commit 9630c50

Please sign in to comment.