Skip to content

Commit

Permalink
home reuse: skip encryption screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed Sep 24, 2024
1 parent 2f454cc commit 8931df3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/components/storage/DiskEncryption.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ export class Page {
constructor (isBootIso, storageScenarioId) {
this.component = DiskEncryption;
this.id = "disk-encryption";
// TODO hide for home-reuse
this.isHidden = ["mount-point-mapping", "use-configured-storage"].includes(storageScenarioId);
this.isHidden = ["mount-point-mapping", "use-configured-storage", "home-reuse"].includes(storageScenarioId);
this.label = _("Disk encryption");
this.title = _("Encrypt the selected devices?");
this.usePageInit = usePageInit;
Expand Down
34 changes: 29 additions & 5 deletions src/components/storage/InstallationMethod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import {
useWizardFooter,
} from "@patternfly/react-core";

import { resetPartitioning } from "../../apis/storage_partitioning.js";
import {
applyStorage,
resetPartitioning,
} from "../../apis/storage_partitioning.js";

import { AnacondaWizardFooter } from "../AnacondaWizardFooter.jsx";
import { DialogsContext, FooterContext, OsReleaseContext, StorageContext } from "../Common.jsx";
Expand All @@ -44,6 +47,7 @@ const InstallationMethod = ({
onCritFail,
setIsFormDisabled,
setIsFormValid,
setStepNotification,
showStorage,
}) => {
const [isReclaimSpaceCheckboxChecked, setIsReclaimSpaceCheckboxChecked] = useState();
Expand All @@ -53,8 +57,9 @@ const InstallationMethod = ({
<CustomFooter
isFormDisabled={isFormDisabled}
isReclaimSpaceCheckboxChecked={isReclaimSpaceCheckboxChecked}
setStepNotification={setStepNotification}
/>
), [isFormDisabled, isReclaimSpaceCheckboxChecked]);
), [isFormDisabled, isReclaimSpaceCheckboxChecked, setStepNotification]);
useWizardFooter(getFooter);

return (
Expand Down Expand Up @@ -86,7 +91,7 @@ const InstallationMethod = ({
);
};

const CustomFooter = ({ isFormDisabled, isReclaimSpaceCheckboxChecked }) => {
const CustomFooter = ({ isFormDisabled, isReclaimSpaceCheckboxChecked, setStepNotification }) => {
const [isReclaimSpaceModalOpen, setIsReclaimSpaceModalOpen] = useState(false);
const [isNextClicked, setIsNextClicked] = useState(false);
const { goToNextStep } = useWizardContext();
Expand All @@ -102,7 +107,7 @@ const CustomFooter = ({ isFormDisabled, isReclaimSpaceCheckboxChecked }) => {
}
}, [isNextClicked, goToNextStep, newPartitioning, partitioning.path]);

const onNext = async () => {
const onNext = async ({ setIsFormDisabled }) => {
if (method === "MANUAL") {
setNewPartitioning(partitioning.path);
setIsNextClicked(true);
Expand All @@ -115,8 +120,27 @@ const CustomFooter = ({ isFormDisabled, isReclaimSpaceCheckboxChecked }) => {

if (willShowReclaimSpaceModal) {
setIsReclaimSpaceModalOpen(true);
} else {
} else if (storageScenarioId !== "home-reuse") {
setIsNextClicked(true);
} else {
setIsFormDisabled(true);
const step = new Page().id;
await applyStorage({
onFail: ex => {
console.error(ex);
setIsFormDisabled(false);
setStepNotification({ step, ...ex });
},
onSuccess: () => {
goToNextStep();

// Reset the state after the onNext call. Otherwise,
// React will try to render the current step again.
setIsFormDisabled(false);
setStepNotification();
},
partitioning: part,
});
}
}
};
Expand Down

0 comments on commit 8931df3

Please sign in to comment.