Skip to content

Commit

Permalink
Merge pull request #369 from adamkankovsky/INSTALLER-3918
Browse files Browse the repository at this point in the history
Re-add alert confirmation before Cockpit Storage
  • Loading branch information
KKoukiou authored Aug 3, 2024
2 parents 59e4ac5 + 049487f commit ecf0397
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 37 deletions.
122 changes: 87 additions & 35 deletions src/components/storage/CockpitStorageIntegration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,50 @@ export const useMaybeBackdrop = () => {
return hasDialogOpen ? "cockpit-has-modal" : "";
};

const CockpitStorageConfirmationModal = ({ handleCancelOpenModal, handleConfirmOpenModal, showConfirmation }) => {
return (
<Modal
isOpen={showConfirmation}
onClose={handleCancelOpenModal}
title={_("Modify storage")}
titleIconVariant="warning"
variant="small"
actions={[
<Button
id={idPrefix + "-enter-storage-confirm"}
key="confirm"
variant="warning"
onClick={handleConfirmOpenModal}>
{_("Launch storage editor")}
</Button>,
<Button
id={idPrefix + "-enter-storage-cancel"}
key="cancel"
variant="link"
onClick={handleCancelOpenModal}>
{_("Cancel")}
</Button>
]}
>
<TextContent>
<Text>
{_("The advanced storage editor lets you resize, delete, and create partitions. It can set up LVM and much more.")}
</Text>
<Text component="strong">{_("Any changes you make will immediately affect your storage.")}</Text>
</TextContent>
</Modal>
);
};

export const CockpitStorageIntegration = ({
dispatch,
isFormDisabled,
onCritFail,
scenarioAvailability,
setShowStorage,
showStorage,
}) => {
const [showDialog, setShowDialog] = useState(false);
const [isConfirmed, setIsConfirmed] = useState(false);
const backdropClass = useMaybeBackdrop();

useEffect(() => {
Expand All @@ -130,42 +165,59 @@ export const CockpitStorageIntegration = ({
}
}, [onCritFail]);

const handleConfirmOpenModal = () => {
setIsConfirmed(true);
setShowStorage(true);
};

const handleCancelOpenModal = () => {
setShowStorage(false);
setIsConfirmed(false);
};

return (
<Modal
aria-label={_("Configure storage")}
className={backdropClass + " " + idPrefix + "-modal-page-section"}
footer={<ReturnToInstallationButton onAction={() => setShowDialog(true)} />}
hasNoBodyWrapper
isOpen={showStorage}
onClose={() => setShowDialog(true)}
showClose={false}
variant={ModalVariant.large}>
<Alert
isInline
title={_("Changes made here will immediately affect the system. There is no 'undo'.")}
variant="warning"
<>
<CockpitStorageConfirmationModal
handleCancelOpenModal={handleCancelOpenModal}
handleConfirmOpenModal={handleConfirmOpenModal}
showConfirmation={!isConfirmed}
/>
<Divider />
<div className={idPrefix + "-page-section-cockpit-storage"}>
<PageSection>
<iframe
src="/cockpit/@localhost/storage/index.html"
name="cockpit-storage"
id="cockpit-storage-frame"
className={idPrefix + "-iframe-cockpit-storage"} />
</PageSection>
<ModifyStorageSideBar />
</div>
{showDialog &&
<CheckStorageDialog
dispatch={dispatch}
isFormDisabled={isFormDisabled}
onCritFail={onCritFail}
scenarioAvailability={scenarioAvailability}
setShowDialog={setShowDialog}
setShowStorage={setShowStorage}
/>}
</Modal>
<Modal
aria-label={_("Configure storage")}
className={backdropClass + " " + idPrefix + "-modal-page-section"}
footer={<ReturnToInstallationButton onAction={() => setShowDialog(true)} />}
hasNoBodyWrapper
isOpen={isConfirmed}
onClose={() => setShowDialog(true)}
showClose={false}
variant={ModalVariant.large}>
<Alert
isInline
title={_("Changes made here will immediately affect the system. There is no 'undo'.")}
variant="warning"
/>
<Divider />
<div className={idPrefix + "-page-section-cockpit-storage"}>
<PageSection>
<iframe
src="/cockpit/@localhost/storage/index.html"
name="cockpit-storage"
id="cockpit-storage-frame"
className={idPrefix + "-iframe-cockpit-storage"} />
</PageSection>
<ModifyStorageSideBar />
</div>
{showDialog &&
<CheckStorageDialog
dispatch={dispatch}
isFormDisabled={isFormDisabled}
onCritFail={onCritFail}
scenarioAvailability={scenarioAvailability}
setShowDialog={setShowDialog}
setShowStorage={setShowStorage}
/>}
</Modal>
</>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/storage/InstallationMethod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ const InstallationMethod = ({
id={idPrefix + "-selector-form"}
onSubmit={e => { e.preventDefault(); return false }}
>
{showStorage &&
<CockpitStorageIntegration
dispatch={dispatch}
isFormDisabled={isFormDisabled}
onCritFail={onCritFail}
setShowStorage={setShowStorage}
showStorage={showStorage}
/>
/>}
<InstallationDestination
isEfi={isEfi}
dispatch={dispatch}
Expand Down
1 change: 1 addition & 0 deletions test/check-storage-basic
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class TestStorage(VirtInstallMachineCase, StorageHelpers):
i.open()
i.reach(i.steps.INSTALLATION_METHOD)
s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")
b._wait_present("iframe[name='cockpit-storage']")
b.switch_to_frame("cockpit-storage")
Expand Down
4 changes: 4 additions & 0 deletions test/check-storage-cockpit
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase):
s.wait_scenario_visible("use-configured-storage", False)
s.check_single_disk_destination("vda")
s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")

frame = "iframe[name='cockpit-storage']"
Expand Down Expand Up @@ -101,6 +102,7 @@ class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase):
s.wait_scenario_visible("use-configured-storage", False)
s.check_single_disk_destination("vda")
s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")

frame = "iframe[name='cockpit-storage']"
Expand Down Expand Up @@ -188,6 +190,7 @@ class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase):
s.wait_scenario_visible("use-configured-storage", False)
s.check_single_disk_destination("vda")
s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")

frame = "iframe[name='cockpit-storage']"
Expand Down Expand Up @@ -261,6 +264,7 @@ class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase):
s.wait_scenario_visible("use-configured-storage", False)
s.check_single_disk_destination("vda")
s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")

frame = "iframe[name='cockpit-storage']"
Expand Down
1 change: 1 addition & 0 deletions test/check-storage-mountpoints
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class TestStorageMountPoints(VirtInstallMachineCase, StorageCase):
s.check_single_disk_destination("vda")

s.modify_storage()
s.confirm_entering_cockpit_storage()
b.wait_visible(".cockpit-storage-integration-sidebar")
s.check_constraint("/", True)
s.check_constraint("biosboot", True)
Expand Down
3 changes: 3 additions & 0 deletions test/helpers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def check_constraint(self, constraint, required=True):
else:
self.browser.wait_visible(f"ul.cockpit-storage-integration-requirements-hint-list:nth-of-type(2) li:contains('{constraint}')")

def confirm_entering_cockpit_storage(self):
self.browser.click("#cockpit-storage-integration-enter-storage-confirm")

def return_to_installation(self):
self.browser.click("#cockpit-storage-integration-return-to-installation-button")

Expand Down

0 comments on commit ecf0397

Please sign in to comment.