Skip to content

Commit

Permalink
webui: pass osRelease through context
Browse files Browse the repository at this point in the history
  • Loading branch information
KKoukiou committed Oct 17, 2023
1 parent b8785e7 commit 0eb6b06
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 51 deletions.
10 changes: 3 additions & 7 deletions ui/webui/src/components/AnacondaWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,20 @@ 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();
const [reusePartitioning, setReusePartitioning] = useState(false);
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(() => {
Expand Down Expand Up @@ -145,17 +146,13 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD
requests: storageData.partitioning ? storageData.partitioning.requests : null,
language,
localizationData,
osRelease,
storageScenarioId,
},
...getReviewConfigurationProps()
},
{
component: InstallationProgress,
id: "installation-progress",
data: {
osRelease
}
}
];

Expand Down Expand Up @@ -212,7 +209,6 @@ export const AnacondaWizard = ({ dispatch, osRelease, storageData, localizationD
stepNotification={stepNotification}
isFormDisabled={isFormDisabled}
setIsFormDisabled={setIsFormDisabled}
osRelease={osRelease}
{...s.data}
/>
</AnacondaPage>
Expand Down
1 change: 1 addition & 0 deletions ui/webui/src/components/Common.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
14 changes: 3 additions & 11 deletions ui/webui/src/components/HeaderKebab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import cockpit from "cockpit";

import React, { useState, useEffect } from "react";
import React, { useContext, useState, useEffect } from "react";
import {
AboutModal,
Button,
Expand All @@ -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";

Expand All @@ -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 (
<Stack hasGutter>
Expand Down
57 changes: 29 additions & 28 deletions ui/webui/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -113,35 +113,36 @@ export const Application = () => {
});

const page = (
<SystemTypeContext.Provider value={systemType}>
{criticalError &&
<CriticalError exception={criticalError} isConnected={state.network.connected} reportLinkURL={bzReportURL} />}
<Page
data-debug={conf.Anaconda.debug}
>
<PageGroup stickyOnBreakpoint={{ default: "top" }}>
<AnacondaHeader
title={title}
reportLinkURL={bzReportURL}
isConnected={state.network.connected}
onCritFail={onCritFail}
/>
</PageGroup>
<AddressContext.Provider value={address}>
<WithDialogs>
<AnacondaWizard
onCritFail={onCritFail}
<OsReleaseContext.Provider value={osRelease}>
<SystemTypeContext.Provider value={systemType}>
{criticalError &&
<CriticalError exception={criticalError} isConnected={state.network.connected} reportLinkURL={bzReportURL} />}
<Page
data-debug={conf.Anaconda.debug}
>
<PageGroup stickyOnBreakpoint={{ default: "top" }}>
<AnacondaHeader
title={title}
storageData={state.storage}
localizationData={state.localization}
dispatch={dispatch}
conf={conf}
osRelease={osRelease}
reportLinkURL={bzReportURL}
isConnected={state.network.connected}
onCritFail={onCritFail}
/>
</WithDialogs>
</AddressContext.Provider>
</Page>
</SystemTypeContext.Provider>
</PageGroup>
<AddressContext.Provider value={address}>
<WithDialogs>
<AnacondaWizard
onCritFail={onCritFail}
title={title}
storageData={state.storage}
localizationData={state.localization}
dispatch={dispatch}
conf={conf}
/>
</WithDialogs>
</AddressContext.Provider>
</Page>
</SystemTypeContext.Provider>
</OsReleaseContext.Provider>
);

return (
Expand Down
5 changes: 3 additions & 2 deletions ui/webui/src/components/installation/InstallationProgress.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions ui/webui/src/components/review/ReviewConfiguration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with This program; If not, see <http://www.gnu.org/licenses/>.
*/
import cockpit from "cockpit";
import React, { useEffect, useState } from "react";
import React, { useContext, useEffect, useState } from "react";

import {
Button,
Expand All @@ -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";

Expand Down Expand Up @@ -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 () => {
Expand Down
1 change: 0 additions & 1 deletion ui/webui/src/components/storage/InstallationMethod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const InstallationMethod = ({
idPrefix,
isFormDisabled,
onCritFail,
osRelease,
setIsFormValid,
setIsFormDisabled,
setStorageScenarioId,
Expand Down

0 comments on commit 0eb6b06

Please sign in to comment.