Skip to content

Commit

Permalink
Do not permit clicking 'Modify storage' button when installation has …
Browse files Browse the repository at this point in the history
…been started
  • Loading branch information
KKoukiou committed Nov 8, 2024
1 parent a07eafe commit 9a6a09b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/components/AnacondaHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import "./AnacondaHeader.scss";
const _ = cockpit.gettext;
const N_ = cockpit.noop;

export const AnacondaHeader = ({ dispatch, isFormDisabled, onCritFail, reportLinkURL, setShowStorage, showStorage, title }) => {
export const AnacondaHeader = ({ currentStepId, dispatch, isFormDisabled, onCritFail, reportLinkURL, setShowStorage, showStorage, title }) => {
const [beta, setBeta] = useState();
const network = useContext(NetworkContext);
const isConnected = network.connected;
Expand All @@ -57,6 +57,7 @@ export const AnacondaHeader = ({ dispatch, isFormDisabled, onCritFail, reportLin
</TextContent>
{beta && <Beta />}
<HeaderKebab
currentStepId={currentStepId}
dispatch={dispatch}
isConnected={isConnected}
isFormDisabled={isFormDisabled}
Expand Down
14 changes: 3 additions & 11 deletions src/components/AnacondaWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import cockpit from "cockpit";

import { usePageLocation } from "hooks";

import React, { useContext, useEffect, useState } from "react";
import React, { useContext, useState } from "react";
import {
PageSection,
PageSectionTypes,
Expand All @@ -32,25 +32,17 @@ import { AnacondaWizardFooter } from "./AnacondaWizardFooter.jsx";
import { FooterContext, StorageContext, SystemTypeContext } from "./Common.jsx";
import { getSteps } from "./steps.js";

export const AnacondaWizard = ({ dispatch, isFetching, onCritFail, showStorage }) => {
export const AnacondaWizard = ({ currentStepId, dispatch, isFetching, onCritFail, showStorage }) => {
// The Form should be disabled while backend checks are in progress
// or the page initialization is in progress
const [isFormDisabled, setIsFormDisabled] = useState(false);
// The Form should be marked as invalid when the user filled data
// are failing the validation
const [isFormValid, setIsFormValid] = useState(false);
const [currentStepId, setCurrentStepId] = useState();
const { storageScenarioId } = useContext(StorageContext);
const isBootIso = useContext(SystemTypeContext) === "BOOT_ISO";
const { path } = usePageLocation();

useEffect(() => {
if (!currentStepId) {
return;
}
cockpit.location.go([currentStepId]);
}, [currentStepId]);

const componentProps = {
dispatch,
isFormDisabled: isFormDisabled || isFetching,
Expand Down Expand Up @@ -112,7 +104,7 @@ export const AnacondaWizard = ({ dispatch, isFetching, onCritFail, showStorage }
setIsFormDisabled(true);
}

setCurrentStepId(newStep.id);
cockpit.location.go([newStep.id]);
};

const finalStep = stepsOrder[stepsOrder.length - 1];
Expand Down
4 changes: 2 additions & 2 deletions src/components/HeaderKebab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const AnacondaAboutModal = ({ isModalOpen, setIsAboutModalOpen }) => {
);
};

export const HeaderKebab = ({ dispatch, isConnected, onCritFail, reportLinkURL, setShowStorage, showStorage }) => {
export const HeaderKebab = ({ currentStepId, dispatch, isConnected, onCritFail, reportLinkURL, setShowStorage, showStorage }) => {
const [isOpen, setIsOpen] = useState(false);
const [isAboutModalOpen, setIsAboutModalOpen] = useState(false);
const [isReportIssueOpen, setIsReportIssueOpen] = useState(false);
Expand All @@ -128,7 +128,7 @@ export const HeaderKebab = ({ dispatch, isConnected, onCritFail, reportLinkURL,

const dropdownItems = [
<ModifyStorage
idPrefix="header-kebab"
currentStepId={currentStepId}
key="modify-storage"
setShowStorage={setShowStorage}
/>,
Expand Down
12 changes: 12 additions & 0 deletions src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
import cockpit from "cockpit";

import { usePageLocation } from "hooks";

import React, { useCallback, useEffect, useState } from "react";
import {
Bullseye,
Expand Down Expand Up @@ -51,7 +53,15 @@ export const ApplicationLoading = () => (
export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease, reportLinkURL }) => {
const [storeInitialized, setStoreInitialized] = useState(false);
const [showStorage, setShowStorage] = useState(false);
const [currentStepId, setCurrentStepId] = useState();
const address = useAddress();
const { path } = usePageLocation();

useEffect(() => {
if (path[0] !== currentStepId) {
setCurrentStepId(path[0]);
}
}, [path, currentStepId]);

useEffect(() => {
if (!address) {
Expand Down Expand Up @@ -81,6 +91,7 @@ export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease,
<PageGroup
stickyOnBreakpoint={{ default: "top" }}>
<AnacondaHeader
currentStepId={currentStepId}
dispatch={dispatch}
title={title}
reportLinkURL={reportLinkURL}
Expand All @@ -90,6 +101,7 @@ export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease,
/>
</PageGroup>
<AnacondaWizard
currentStepId={currentStepId}
isFetching={isFetching}
onCritFail={onCritFail}
title={title}
Expand Down
9 changes: 8 additions & 1 deletion src/components/storage/CockpitStorageIntegration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { getDeviceByName, getDeviceByPath } from "../../helpers/storage.js";
import { EmptyStatePanel } from "cockpit-components-empty-state";

import { StorageContext, TargetSystemRootContext } from "../Common.jsx";
import { getSteps } from "../steps.js";
import {
useDiskFreeSpace,
useDiskTotalSpace,
Expand Down Expand Up @@ -634,7 +635,7 @@ const ModifyStorageSideBar = () => {
);
};

export const ModifyStorage = ({ setShowStorage }) => {
export const ModifyStorage = ({ currentStepId, setShowStorage }) => {
const targetSystemRoot = useContext(TargetSystemRootContext);
const { diskSelection } = useContext(StorageContext);
const devices = useOriginalDevices();
Expand All @@ -646,10 +647,16 @@ export const ModifyStorage = ({ setShowStorage }) => {
efi: isEfi,
mount_point_prefix: targetSystemRoot,
});
const isDisabled = useMemo(() => {
const steps = getSteps();
const currentStep = steps.find(step => step.id === currentStepId);
return currentStep?.isFinal;
}, [currentStepId]);

return (
<DropdownItem
id="modify-storage"
isDisabled={isDisabled}
onClick={() => {
window.sessionStorage.setItem("cockpit_anaconda", cockpitAnaconda);
setShowStorage(true);
Expand Down
4 changes: 4 additions & 0 deletions test/check-progress
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class TestInstallationProgress(VirtInstallMachineCase):
ignore=[".logo", "#betanag-icon"],
)

# Check that at this stage 'Modify Storage' is not available
b.click("#toggle-kebab")
b.wait_visible("li.pf-m-disabled #modify-storage")

self.handleReboot()


Expand Down

0 comments on commit 9a6a09b

Please sign in to comment.