Skip to content

Commit

Permalink
Merge pull request #4924 from KKoukiou/webui-critical-error-fix
Browse files Browse the repository at this point in the history
webui: allow critical errors also in the first load of the application
  • Loading branch information
KKoukiou authored Jul 18, 2023
2 parents 050e696 + 829dc96 commit b0c1d63
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 50 deletions.
103 changes: 53 additions & 50 deletions ui/webui/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const Application = () => {
};

// Postpone rendering anything until we read the dbus address and the default configuration
if (!address || !conf || !beta || !prettyName || !storeInitilized) {
if (!criticalError && (!address || !conf || !beta || !prettyName || !storeInitilized)) {
console.debug("Loading initial data...");
return null;
}
Expand All @@ -116,59 +116,62 @@ export const Application = () => {
const title = cockpit.format("$0 installation", prettyName);

const page = (
<Page
data-debug={conf.Anaconda.debug}
additionalGroupedContent={
<AnacondaHeader beta={beta} title={title} />
}
groupProps={{
sticky: "top"
}}
>
{Object.keys(notifications).length > 0 &&
<AlertGroup isToast isLiveRegion>
{Object.keys(notifications).map(idx => {
const notification = notifications[idx];
const newNotifications = { ...notifications };
delete newNotifications[notification.index];

return (
<Alert
variant={AlertVariant[notification.variant]}
title={notification.title}
actionClose={
<AlertActionCloseButton
title={notifications.title}
onClose={() => setNotifications(newNotifications)}
/>
}
key={notification.index}>
{notification.message}
</Alert>
);
})}
</AlertGroup>}
<AddressContext.Provider value={address}>
<WithDialogs>
<AnacondaWizard
isBootIso={isBootIso}
onAddErrorNotification={onAddErrorNotification}
toggleContextHelp={toggleContextHelp}
hideContextHelp={() => setIsHelpExpanded(false)}
title={title}
storageData={state.storage}
localizationData={state.localization}
dispatch={dispatch}
conf={conf}
/>
</WithDialogs>
</AddressContext.Provider>
</Page>
criticalError
? <CriticalError exception={criticalError} isBootIso={isBootIso} />
: (
<Page
data-debug={conf.Anaconda.debug}
additionalGroupedContent={
<AnacondaHeader beta={beta} title={title} />
}
groupProps={{
sticky: "top"
}}
>
{Object.keys(notifications).length > 0 &&
<AlertGroup isToast isLiveRegion>
{Object.keys(notifications).map(idx => {
const notification = notifications[idx];
const newNotifications = { ...notifications };
delete newNotifications[notification.index];

return (
<Alert
variant={AlertVariant[notification.variant]}
title={notification.title}
actionClose={
<AlertActionCloseButton
title={notifications.title}
onClose={() => setNotifications(newNotifications)}
/>
}
key={notification.index}>
{notification.message}
</Alert>
);
})}
</AlertGroup>}
<AddressContext.Provider value={address}>
<WithDialogs>
<AnacondaWizard
isBootIso={isBootIso}
onAddErrorNotification={onAddErrorNotification}
toggleContextHelp={toggleContextHelp}
hideContextHelp={() => setIsHelpExpanded(false)}
title={title}
storageData={state.storage}
localizationData={state.localization}
dispatch={dispatch}
conf={conf}
/>
</WithDialogs>
</AddressContext.Provider>
</Page>
)
);

return (
<WithDialogs>
{criticalError && <CriticalError exception={criticalError} isBootIso={isBootIso} />}
<LanguageContext.Provider value={{ language, setLanguage }}>
<HelpDrawer
isExpanded={isHelpExpanded}
Expand Down
4 changes: 4 additions & 0 deletions ui/webui/test/check-basic
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class TestQuit(anacondalib.VirtInstallMachineCase):
m.execute("cp /run/anaconda/bus.address /tmp/; echo trash > /run/anaconda/bus.address")
b.wait_visible("#critical-error-modal")

# Errors should persist across page reloads (same as having the error prior the first page load)
b.reload()
b.wait_visible("#critical-error-modal")

# Exit installer
b.click("#critical-error-modal .pf-c-button.pf-m-secondary")
m.wait_poweroff()
Expand Down

0 comments on commit b0c1d63

Please sign in to comment.