diff --git a/ui/webui/src/components/AnacondaWizard.jsx b/ui/webui/src/components/AnacondaWizard.jsx index 865aa2a6a2b..575ec7b6d9d 100644 --- a/ui/webui/src/components/AnacondaWizard.jsx +++ b/ui/webui/src/components/AnacondaWizard.jsx @@ -50,12 +50,12 @@ import { resetPartitioning, getRequiredMountPoints, } from "../apis/storage.js"; -import { SystemTypeContext } from "./Common.jsx"; +import { SystemTypeContext, OsReleaseContext } from "./Common.jsx"; const _ = cockpit.gettext; const N_ = cockpit.noop; -export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationData, onCritFail, title, conf }) => { +export const AnacondaWizard = ({ dispatch, storageData, localizationData, onCritFail, title, conf }) => { const [isFormDisabled, setIsFormDisabled] = useState(false); const [isFormValid, setIsFormValid] = useState(false); const [requiredMountPoints, setRequiredMountPoints] = useState(); @@ -63,6 +63,7 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD const [stepNotification, setStepNotification] = useState(); const [storageEncryption, setStorageEncryption] = useState(getStorageEncryptionState()); const [storageScenarioId, setStorageScenarioId] = useState(window.sessionStorage.getItem("storage-scenario-id") || getDefaultScenario().id); + const osRelease = useContext(OsReleaseContext); const isBootIso = useContext(SystemTypeContext) === "BOOT_ISO"; const availableDevices = useMemo(() => { @@ -145,7 +146,6 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD requests: storageData.partitioning ? storageData.partitioning.requests : null, language, localizationData, - osRelease, storageScenarioId, }, ...getReviewConfigurationProps() @@ -153,9 +153,6 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD { component: InstallationProgress, id: "installation-progress", - data: { - osRelease - } } ]; @@ -212,7 +209,6 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD stepNotification={stepNotification} isFormDisabled={isFormDisabled} setIsFormDisabled={setIsFormDisabled} - osRelease={osRelease} {...s.data} /> diff --git a/ui/webui/src/components/Common.jsx b/ui/webui/src/components/Common.jsx index e563895f202..bb47e1bab73 100644 --- a/ui/webui/src/components/Common.jsx +++ b/ui/webui/src/components/Common.jsx @@ -22,6 +22,7 @@ export const AddressContext = createContext(""); export const ConfContext = createContext(); export const LanguageContext = createContext(""); export const SystemTypeContext = createContext(null); +export const OsReleaseContext = createContext(null); export const FormGroupHelpPopover = ({ helpContent }) => { return ( diff --git a/ui/webui/src/components/HeaderKebab.jsx b/ui/webui/src/components/HeaderKebab.jsx index 0238ba3ce10..01bacacdaf5 100644 --- a/ui/webui/src/components/HeaderKebab.jsx +++ b/ui/webui/src/components/HeaderKebab.jsx @@ -16,7 +16,7 @@ */ import cockpit from "cockpit"; -import React, { useState, useEffect } from "react"; +import React, { useContext, useState, useEffect } from "react"; import { AboutModal, Button, @@ -37,9 +37,9 @@ import { EllipsisVIcon } from "@patternfly/react-icons"; -import { read_os_release as readOsRelease } from "os-release.js"; import { getAnacondaVersion } from "../helpers/product.js"; import { UserIssue } from "./Error.jsx"; +import { OsReleaseContext } from "./Common.jsx"; import "./HeaderKebab.scss"; @@ -63,15 +63,7 @@ const AboutModalVersions = () => { }; const ProductName = () => { - const [osRelease, setOsRelease] = useState(); - - useEffect(() => { - readOsRelease().then(setOsRelease); - }, []); - - if (!osRelease) { - return null; - } + const osRelease = useContext(OsReleaseContext); return ( diff --git a/ui/webui/src/components/app.jsx b/ui/webui/src/components/app.jsx index 324a482ef93..e952d4e85c0 100644 --- a/ui/webui/src/components/app.jsx +++ b/ui/webui/src/components/app.jsx @@ -25,7 +25,7 @@ import { import { read_os_release as readOsRelease } from "os-release.js"; import { WithDialogs } from "dialogs.jsx"; -import { AddressContext, LanguageContext, SystemTypeContext } from "./Common.jsx"; +import { AddressContext, LanguageContext, SystemTypeContext, OsReleaseContext } from "./Common.jsx"; import { AnacondaHeader } from "./AnacondaHeader.jsx"; import { AnacondaWizard } from "./AnacondaWizard.jsx"; import { CriticalError, errorHandlerWithContext, bugzillaPrefiledReportURL } from "./Error.jsx"; @@ -113,35 +113,36 @@ export const Application = () => { }); const page = ( - - {criticalError && - } - - - - - - - + + {criticalError && + } + + + - - - - + + + + + + + + + ); return ( diff --git a/ui/webui/src/components/installation/InstallationProgress.jsx b/ui/webui/src/components/installation/InstallationProgress.jsx index 9911b0b988c..525a1a51243 100644 --- a/ui/webui/src/components/installation/InstallationProgress.jsx +++ b/ui/webui/src/components/installation/InstallationProgress.jsx @@ -33,7 +33,7 @@ import { } from "@patternfly/react-icons"; import { EmptyStatePanel } from "cockpit-components-empty-state.jsx"; -import { SystemTypeContext } from "../Common.jsx"; +import { SystemTypeContext, OsReleaseContext } from "../Common.jsx"; import { BossClient, getSteps, installWithTasks } from "../../apis/boss.js"; import { exitGui } from "../../helpers/exit.js"; @@ -43,13 +43,14 @@ import "./InstallationProgress.scss"; const _ = cockpit.gettext; const N_ = cockpit.noop; -export const InstallationProgress = ({ onCritFail, idPrefix, osRelease }) => { +export const InstallationProgress = ({ onCritFail, idPrefix }) => { const [status, setStatus] = useState(); const [statusMessage, setStatusMessage] = useState(""); const [steps, setSteps] = useState(); const [currentProgressStep, setCurrentProgressStep] = useState(0); const refStatusMessage = useRef(""); const isBootIso = useContext(SystemTypeContext) === "BOOT_ISO"; + const osRelease = useContext(OsReleaseContext); useEffect(() => { installWithTasks() diff --git a/ui/webui/src/components/review/ReviewConfiguration.jsx b/ui/webui/src/components/review/ReviewConfiguration.jsx index dc5bd26e8be..2200c4a2668 100644 --- a/ui/webui/src/components/review/ReviewConfiguration.jsx +++ b/ui/webui/src/components/review/ReviewConfiguration.jsx @@ -15,7 +15,7 @@ * along with This program; If not, see . */ import cockpit from "cockpit"; -import React, { useEffect, useState } from "react"; +import React, { useContext, useEffect, useState } from "react"; import { Button, @@ -34,6 +34,7 @@ import { import { checkDeviceInSubTree } from "../../helpers/storage.js"; import { getScenario } from "../storage/InstallationScenario.jsx"; +import { OsReleaseContext } from "../Common.jsx"; import "./ReviewConfiguration.scss"; @@ -97,8 +98,9 @@ const DeviceRow = ({ deviceData, disk, requests }) => { ); }; -export const ReviewConfiguration = ({ deviceData, diskSelection, language, localizationData, osRelease, requests, idPrefix, setIsFormValid, storageScenarioId }) => { +export const ReviewConfiguration = ({ deviceData, diskSelection, language, localizationData, requests, idPrefix, setIsFormValid, storageScenarioId }) => { const [encrypt, setEncrypt] = useState(); + const osRelease = useContext(OsReleaseContext); useEffect(() => { const initializeEncrypt = async () => { diff --git a/ui/webui/src/components/storage/InstallationMethod.jsx b/ui/webui/src/components/storage/InstallationMethod.jsx index 22a1cc1be17..1c9a845db84 100644 --- a/ui/webui/src/components/storage/InstallationMethod.jsx +++ b/ui/webui/src/components/storage/InstallationMethod.jsx @@ -34,7 +34,6 @@ export const InstallationMethod = ({ idPrefix, isFormDisabled, onCritFail, - osRelease, setIsFormValid, setIsFormDisabled, setStorageScenarioId,