From 6d5836492331c4058d4c19e443e46c69449a5665 Mon Sep 17 00:00:00 2001 From: Katerina Koukiou Date: Tue, 21 Jan 2025 14:58:01 +0100 Subject: [PATCH] Ensure that URL path is always set when loading the app This fixes the 'Launch storage editor' button being disabled on Live ISO. Resolves: rhbz#2336488 --- src/components/AnacondaWizard.jsx | 14 ++++++++++++-- src/components/app.jsx | 10 +--------- test/check-storage-cockpit | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/components/AnacondaWizard.jsx b/src/components/AnacondaWizard.jsx index 5c8717c93f..d8a02f2245 100644 --- a/src/components/AnacondaWizard.jsx +++ b/src/components/AnacondaWizard.jsx @@ -18,7 +18,7 @@ import cockpit from "cockpit"; import { usePageLocation } from "hooks"; -import React, { useContext, useState } from "react"; +import React, { useContext, useEffect, useState } from "react"; import { PageSection, PageSectionTypes, @@ -33,7 +33,7 @@ import { AnacondaPage } from "./AnacondaPage.jsx"; import { AnacondaWizardFooter } from "./AnacondaWizardFooter.jsx"; import { getSteps } from "./steps.js"; -export const AnacondaWizard = ({ currentStepId, dispatch, isFetching, onCritFail, showStorage }) => { +export const AnacondaWizard = ({ currentStepId, dispatch, isFetching, onCritFail, setCurrentStepId, showStorage }) => { // The Form should be disabled while backend checks are in progress // or the page initialization is in progress const [isFormDisabled, setIsFormDisabled] = useState(false); @@ -57,6 +57,16 @@ export const AnacondaWizard = ({ currentStepId, dispatch, isFetching, onCritFail const stepsOrder = getSteps(userInterfaceConfig, isBootIso, storageScenarioId); const firstStepId = stepsOrder.filter(s => !s.isHidden)[0].id; + useEffect(() => { + if (path[0] && path[0] !== currentStepId) { + // If path is set respect it + setCurrentStepId(path[0]); + } else if (!currentStepId) { + // Otherwise set the first step as the current step + setCurrentStepId(firstStepId); + } + }, [currentStepId, firstStepId, path, setCurrentStepId]); + const createSteps = (stepsOrder, componentProps) => { return stepsOrder.map(s => { const isVisited = firstStepId === s.id || currentStepId === s.id; diff --git a/src/components/app.jsx b/src/components/app.jsx index f8549e86d6..35220dc64f 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -16,8 +16,6 @@ */ import cockpit from "cockpit"; -import { usePageLocation } from "hooks"; - import React, { useCallback, useEffect, useState } from "react"; import { Bullseye, @@ -56,13 +54,6 @@ export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease, 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) { @@ -108,6 +99,7 @@ export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease, title={title} dispatch={dispatch} conf={conf} + setCurrentStepId={setCurrentStepId} showStorage={showStorage} /> diff --git a/test/check-storage-cockpit b/test/check-storage-cockpit index 9b2c725222..4966f20cee 100755 --- a/test/check-storage-cockpit +++ b/test/check-storage-cockpit @@ -21,9 +21,26 @@ from review import Review from storage import Storage from storagelib import StorageCase # pylint: disable=import-error from testlib import nondestructive, test_main # pylint: disable=import-error +from utils import pretend_live_iso class TestStorageCockpitIntegration(VirtInstallMachineCase, StorageCase): + @nondestructive + def testBasicLiveISO(self): + # Test that the 'Modify storage' button is available on the first page + # https://bugzilla.redhat.com/show_bug.cgi?id=2336488 + b = self.browser + m = self.machine + i = Installer(b, m, scenario="use-configured-storage") + s = Storage(b, m) + + pretend_live_iso(self, i) + + i.open() + s.check_disk_selected("vda") + s.modify_storage() + s.confirm_entering_cockpit_storage() + @nondestructive def testEncryptedUnlock(self): b = self.browser