Skip to content

Commit

Permalink
Ensure that URL path is always set when loading the app
Browse files Browse the repository at this point in the history
This fixes the 'Launch storage editor' button being disabled on Live ISO.

Resolves: rhbz#2336488
  • Loading branch information
KKoukiou committed Jan 21, 2025
1 parent 6d689ee commit 3c2d61f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
14 changes: 12 additions & 2 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, useState } from "react";
import React, { useContext, useEffect, useState } from "react";
import {
PageSection,
PageSectionTypes,
Expand All @@ -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);
Expand All @@ -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, setCurrentStepId]);

const createSteps = (stepsOrder, componentProps) => {
return stepsOrder.map(s => {
const isVisited = firstStepId === s.id || currentStepId === s.id;
Expand Down
10 changes: 1 addition & 9 deletions src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
import cockpit from "cockpit";

import { usePageLocation } from "hooks";

import React, { useCallback, useEffect, useState } from "react";
import {
Bullseye,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -108,6 +99,7 @@ export const Application = ({ conf, dispatch, isFetching, onCritFail, osRelease,
title={title}
dispatch={dispatch}
conf={conf}
setCurrentStepId={setCurrentStepId}
showStorage={showStorage}
/>
</>
Expand Down
17 changes: 17 additions & 0 deletions test/check-storage-cockpit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c2d61f

Please sign in to comment.