Skip to content

Commit

Permalink
Merge pull request #5077 from vojtechtrefny/master_fix-row-remove
Browse files Browse the repository at this point in the history
webui: Update request IDs when removing mount point row
  • Loading branch information
vojtechtrefny authored Aug 28, 2023
2 parents fcd58ea + f96a54a commit eda3584
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
12 changes: 11 additions & 1 deletion ui/webui/src/components/storage/MountPointMapping.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ const MountPointColumn = ({ handleRequestChange, idPrefix, isRequiredMountPoint,

const swapMountpoint = mountpoint === "swap";

useEffect(() => {
setMountPointText(request["mount-point"] || "");
}, [request]);

return (
<Flex direction={{ default: "column" }} spaceItems={{ default: "spaceItemsNone" }}>
<Flex spaceItems={{ default: "spaceItemsMd" }}>
Expand Down Expand Up @@ -298,7 +302,13 @@ const FormatColumn = ({ deviceData, handleRequestChange, idPrefix, request, requ

const MountPointRowRemove = ({ request, setRequests }) => {
const handleRemove = () => {
setRequests(requests => requests.filter(r => r["request-id"] !== request["request-id"]));
// remove row from requests and update requests with higher ID
setRequests(requests => requests.filter(r => r["request-id"] !== request["request-id"]).map(({
...r
}) => ({
...r,
"request-id": r["request-id"] > request["request-id"] ? r["request-id"] - 1 : r["request-id"],
})));
};

return (
Expand Down
20 changes: 19 additions & 1 deletion ui/webui/test/check-storage
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
# * either also reformatted if selected
# * either not selected (not part of the mountpoint assignment table)
self.remove_row(5)
self.remove_row(6)
self.remove_row(5)
self.wait_mount_point_table_column_helper(3, "format", present=False)
self.wait_mount_point_table_column_helper(4, "format", present=False)

Expand Down Expand Up @@ -866,6 +866,24 @@ class TestStorageMountPoints(anacondalib.VirtInstallMachineCase):
r.check_disk_row(disk, 3, f"{vgname}-home, 8.12 GB: mount, /home")
r.check_disk_row(disk, 4, f"{vgname}-swap, 902 MB: mount, swap")

i.back(previous_page=i.steps.CUSTOM_MOUNT_POINT)

# remove the /home row and check that row 3 is now swap
self.remove_row(3)

self.check_row_mountpoint(3, "swap")
self.check_row_device(3, f"{vgname}-swap")

i.next()

# verify review screen
disk = "vda"
r.check_disk(disk, "16.1 GB vda (0x1af4)")

r.check_disk_row(disk, 1, "vda2, 1.07 GB: mount, /boot")
r.check_disk_row(disk, 2, f"{vgname}-root, 6.01 GB: format as ext4, /")
r.check_disk_row(disk, 3, f"{vgname}-swap, 902 MB: mount, swap")

@nondestructive
def testUnusableFormats(self):
b = self.browser
Expand Down

0 comments on commit eda3584

Please sign in to comment.