diff --git a/src/components/storage/InstallationDestination.jsx b/src/components/storage/InstallationDestination.jsx index ca2a556ba5..54f23a020e 100644 --- a/src/components/storage/InstallationDestination.jsx +++ b/src/components/storage/InstallationDestination.jsx @@ -20,6 +20,7 @@ import React, { useContext, useEffect, useRef, useState } from "react"; import { Alert, AlertActionCloseButton, + AlertGroup, Button, Chip, ChipGroup, @@ -31,9 +32,12 @@ import { SelectList, SelectOption, Spinner, + Text, + TextContent, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, + TextVariants, Title, } from "@patternfly/react-core"; import { SyncAltIcon, TimesIcon } from "@patternfly/react-icons"; @@ -393,20 +397,19 @@ export const InstallationDestination = ({ /> ); - const equalDisks = refUsableDisks.current && checkIfArraysAreEqual(refUsableDisks.current, diskSelection.usableDisks); const headingLevel = isBootIso ? "h2" : "h3"; return ( <> {_("Destination")} - {equalDisksNotify && equalDisks && - { setEqualDisksNotify(false) }} />} - />} + {!isRescanningDisks && diskSelection.usableDisks !== undefined && refUsableDisks.current !== undefined && + } {(diskSelection.usableDisks.length > 1 || (diskSelection.usableDisks.length === 1 && diskSelection.selectedDisks.length === 0)) @@ -436,3 +439,74 @@ export const InstallationDestination = ({ ); }; + +const DisksChangedAlert = ({ + deviceData, + equalDisksNotify, + refUsableDisks, + setEqualDisksNotify, + usableDisks, +}) => { + const [showChangedNotification, setShowChangedNotification] = useState(true); + const equalDisks = checkIfArraysAreEqual(refUsableDisks.current, usableDisks); + const disksAdded = usableDisks.filter(disk => !refUsableDisks.current.includes(disk)); + const disksRemoved = ( + refUsableDisks.current && + refUsableDisks.current.filter(disk => !usableDisks.includes(disk)) + ); + + return ( + + {equalDisksNotify && equalDisks && + { setEqualDisksNotify(false) }} />} + />} + {showChangedNotification && !equalDisks && + { setShowChangedNotification(false) }} />}> + + {disksAdded?.length > 0 && + + {cockpit.format( + cockpit.ngettext( + "The following disk was detected: $0", + "The following disks were detected: $0", + disksAdded.length + ), + disksAdded.map(disk => ( + cockpit.format( + "$0 ($1)", + deviceData[disk].name.v, + deviceData[disk].description.v + )) + ).join(", ") + )} + } + {disksRemoved?.length > 0 && + + {cockpit.format( + cockpit.ngettext( + "The following disk is no longer available: $0", + "The following disks are no longer available: $0", + disksRemoved.length + ), + disksRemoved.map(disk => ( + cockpit.format( + "$0 ($1)", + deviceData[disk].name.v, + deviceData[disk].description.v + )) + ).join(", ") + )} + } + + } + + ); +}; diff --git a/test/check-storage b/test/check-storage index 0e4876b8cf..b91beb8600 100755 --- a/test/check-storage +++ b/test/check-storage @@ -61,6 +61,9 @@ class TestStorage(anacondalib.VirtInstallMachineCase, StorageHelpers): dev = dev.split("/")[-1] s.rescan_disks() + # Check the newly added disk generated a notification + s.wait_disk_added(dev) + # Check that the disk selection persists when moving next and back s.check_disk_selected("vda", True) i.next() diff --git a/test/helpers/storage.py b/test/helpers/storage.py index 604998fe8c..9849e98936 100644 --- a/test/helpers/storage.py +++ b/test/helpers/storage.py @@ -94,6 +94,9 @@ def wait_no_disks_detected(self): def wait_no_disks_detected_not_present(self): self.browser.wait_not_present("#no-disks-detected-alert") + def wait_disk_added(self, disk): + self.browser.wait_in_text("#disks-changed-alert", f"The following disk was detected: {disk}") + @log_step(snapshots=True) def rescan_disks(self): self.browser.click(f"#{self._step}-rescan-disks")