Skip to content

Commit

Permalink
webui: add offline version to BZ report dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rvykydal committed Aug 25, 2023
1 parent a5b357b commit d613150
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ui/webui/src/components/AnacondaHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { HeaderKebab } from "./HeaderKebab.jsx";

const _ = cockpit.gettext;

export const AnacondaHeader = ({ beta, title, reportLinkURL }) => {
export const AnacondaHeader = ({ beta, title, reportLinkURL, isConnected }) => {
const prerelease = _("Pre-release");
const betanag = beta
? (
Expand Down Expand Up @@ -68,7 +68,7 @@ export const AnacondaHeader = ({ beta, title, reportLinkURL }) => {
<Text component="h1">{title}</Text>
</TextContent>
{betanag}
<HeaderKebab reportLinkURL={reportLinkURL} />
<HeaderKebab reportLinkURL={reportLinkURL} isConnected={isConnected} />
</Flex>
</PageSection>
);
Expand Down
17 changes: 11 additions & 6 deletions ui/webui/src/components/Error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
TextVariants,
Text,
} from "@patternfly/react-core";
import { ExternalLinkAltIcon } from "@patternfly/react-icons";
import { ExternalLinkAltIcon, DisconnectedIcon } from "@patternfly/react-icons";

import { exitGui } from "../helpers/exit.js";

Expand Down Expand Up @@ -62,7 +62,8 @@ export const BZReportModal = ({
logFile,
detailsLabel,
detailsContent,
buttons
buttons,
isConnected
}) => {
const [logContent, setLogContent] = useState();
const [preparingReport, setPreparingReport] = useState(false);
Expand Down Expand Up @@ -96,7 +97,7 @@ export const BZReportModal = ({
<Button
variant="primary"
isLoading={preparingReport}
isDisabled={logContent === undefined || preparingReport}
isDisabled={logContent === undefined || preparingReport || !isConnected}
icon={<ExternalLinkAltIcon />}
onClick={() => openBZIssue(reportLinkURL)}
component="a">
Expand Down Expand Up @@ -127,7 +128,9 @@ export const BZReportModal = ({
/>
<FormHelperText isHidden={false}>
<HelperText>
<HelperTextItem>{_("Reporting an issue will send information over the network. Plese review and edit the attached log to remove any sensitive information.")}</HelperTextItem>
{isConnected
? <HelperTextItem> {_("Reporting an issue will send information over the network. Please review and edit the attached log to remove any sensitive information.")} </HelperTextItem>
: <HelperTextItem icon={<DisconnectedIcon />}> {_("Network not available. Configure the network in the top bar menu to report the issue.")} </HelperTextItem>}
</HelperText>
</FormHelperText>
</FormGroup>
Expand Down Expand Up @@ -168,7 +171,7 @@ const quitButton = (isBootIso) => {
);
};

export const CriticalError = ({ exception, isBootIso, reportLinkURL }) => {
export const CriticalError = ({ exception, isBootIso, isConnected, reportLinkURL }) => {
const context = exception.contextData?.context;
const description = context
? cockpit.format(_("The installer cannot continue due to a critical error: $0"), _(context))
Expand All @@ -186,6 +189,7 @@ export const CriticalError = ({ exception, isBootIso, reportLinkURL }) => {
detailsLabel={_("Error details")}
detailsContent={exceptionInfo(exception, idPrefix)}
buttons={[quitButton(isBootIso)]}
isConnected={isConnected}
/>

);
Expand All @@ -208,7 +212,7 @@ const cancelButton = (onClose) => {
);
};

export const UserIssue = ({ reportLinkURL, setIsReportIssueOpen }) => {
export const UserIssue = ({ reportLinkURL, setIsReportIssueOpen, isConnected }) => {
return (
<BZReportModal
description={_("The following log will be sent to the issue tracking system where you may provide additional details.")}
Expand All @@ -218,6 +222,7 @@ export const UserIssue = ({ reportLinkURL, setIsReportIssueOpen }) => {
titleIconVariant={null}
logFile="/tmp/webui.log"
buttons={[cancelButton(() => setIsReportIssueOpen(false))]}
isConnected={isConnected}
/>
);
};
Expand Down
3 changes: 2 additions & 1 deletion ui/webui/src/components/HeaderKebab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const AnacondaAboutModal = ({ isModalOpen, setIsAboutModalOpen }) => {
);
};

export const HeaderKebab = ({ reportLinkURL }) => {
export const HeaderKebab = ({ reportLinkURL, isConnected }) => {
const [isOpen, setIsOpen] = useState(false);
const [isAboutModalOpen, setIsAboutModalOpen] = useState(false);
const [isReportIssueOpen, setIsReportIssueOpen] = useState(false);
Expand Down Expand Up @@ -167,6 +167,7 @@ export const HeaderKebab = ({ reportLinkURL }) => {
<UserIssue
reportLinkURL={reportLinkURL}
setIsReportIssueOpen={setIsReportIssueOpen}
isConnected={isConnected}
/>}
</>
);
Expand Down
9 changes: 7 additions & 2 deletions ui/webui/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const Application = () => {
const page = (
<>
{criticalError &&
<CriticalError exception={criticalError} isBootIso={isBootIso} reportLinkURL={bzReportURL} />}
<CriticalError exception={criticalError} isBootIso={isBootIso} isConnected={state.network.connected} reportLinkURL={bzReportURL} />}
<Page
data-debug={conf.Anaconda.debug}
>
Expand Down Expand Up @@ -160,7 +160,12 @@ export const Application = () => {
})}
</AlertGroup>}
<PageGroup stickyOnBreakpoint={{ default: "top" }}>
<AnacondaHeader beta={beta} title={title} reportLinkURL={bzReportURL} />
<AnacondaHeader
beta={beta}
title={title}
reportLinkURL={bzReportURL}
isConnected={state.network.connected}
/>
</PageGroup>
<AddressContext.Provider value={address}>
<WithDialogs>
Expand Down

0 comments on commit d613150

Please sign in to comment.