Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): more UI adjustments #1326

Merged
merged 11 commits into from
Jun 13, 2024
4 changes: 2 additions & 2 deletions web/src/SimpleLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { _ } from "~/i18n";
* Simple layout for displaying content that comes before product configuration
* TODO: improve documentation
*/
export default function SimpleLayout({ showOutlet = true, children }) {
export default function SimpleLayout({ showOutlet = true, showInstallerOptions = true, children }) {
return (
<Page>
<Masthead backgroundColor="light200">
Expand All @@ -42,7 +42,7 @@ export default function SimpleLayout({ showOutlet = true, children }) {
<ToolbarContent>
<ToolbarGroup align={{ default: "alignRight" }}>
<ToolbarItem>
<InstallerOptions />
{showInstallerOptions && <InstallerOptions />}
</ToolbarItem>
</ToolbarGroup>
</ToolbarContent>
Expand Down
5 changes: 5 additions & 0 deletions web/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ button.pf-m-link {
}
}

// Do not reserve space for empty nodes.
div:empty {
display: none;
}

fieldset {
padding: var(--fs-base);
border: 0;
Expand Down
25 changes: 25 additions & 0 deletions web/src/assets/styles/patternfly-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,28 @@ table td > .pf-v5-c-empty-state {
color: white;
}
}

// Force sidebar to only use needed width plus an extra padding at the end.
.pf-v5-c-page__sidebar.pf-m-expanded {
--pf-v5-c-page__sidebar--Width: fit-content;

.pf-v5-c-nav__link {
padding-inline-end: calc(var(--pf-v5-global--spacer--xl) * 1.2);
}
}

// Makes the NotificationDrawerHeader "plain"
.pf-v5-c-notification-drawer {
--pf-v5-c-notification-drawer--BackgroundColor: white;
}

.pf-v5-c-notification-drawer__list-item {
--pf-v5-c-notification-drawer__list-item--PaddingBottom: 0;
--pf-v5-c-notification-drawer__list-item--BoxShadow: none;
}

.pf-v5-c-notification-drawer__list-item-description {
padding-inline-start: calc(
1em + var(--pf-v5-c-notification-drawer__list-item-header-icon--MarginRight)
);
}
2 changes: 1 addition & 1 deletion web/src/components/core/CardField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const CardField = ({
</Flex>
</CardTitle>
</CardHeader>
{description && <CardBody><div className={textStyles.color_200}>{description}</div></CardBody>}
{description && <CardBody isFilled={false}><div className={textStyles.color_200}>{description}</div></CardBody>}
{children}
{actions && <CardFooter>{actions}</CardFooter>}
</Card>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/core/IssuesHint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function IssuesHint({ issues }) {
<HintBody>
<Stack hasGutter>
<p>
{_("Please, pay attention to the following tasks:")}
{_("Before starting the installation, you need to address the following problems:")}
</p>
<List>
{issues.map((i, idx) => <ListItem key={idx}>{i.description}</ListItem>)}
Expand Down
4 changes: 0 additions & 4 deletions web/src/components/layout/Icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ import WifiFind from "@icons/wifi_find.svg?component";

import { SiLinux, SiWindows } from "@icons-pack/react-simple-icons";

// Icons from SVG
import Loading from "./three-dots-loader-icon.svg?component";

/**
* @typedef {string|number} IconSize
* @typedef {keyof icons} IconName
Expand Down Expand Up @@ -120,7 +117,6 @@ const icons = {
inventory_2: Inventory,
keyboard: Keyboard,
lan: Lan,
loading: Loading,
list_alt: ListAlt,
lock: Lock,
manage_accounts: ManageAccounts,
Expand Down
25 changes: 14 additions & 11 deletions web/src/components/layout/Loading.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@
*/

import React from "react";
import { EmptyState, EmptyStateIcon, EmptyStateHeader } from "@patternfly/react-core";
import { EmptyState, EmptyStateIcon, EmptyStateHeader, Spinner } from "@patternfly/react-core";

import SimpleLayout from "~/SimpleLayout";
import { Center, Icon } from "~/components/layout";
import { _ } from "~/i18n";

const LoadingIcon = () => <Icon name="loading" size="xxxl" />;
const LoadingIcon = () => <Spinner size="xl" />;

function Loading({ text = _("Loading installation environment, please wait.") }) {
return (
<Center>
<EmptyState variant="xl">
<EmptyStateHeader
titleText={text}
headingLevel="h2"
icon={<EmptyStateIcon icon={LoadingIcon} />}
/>
</EmptyState>
</Center>
<SimpleLayout showOutlet={false} showInstallerOptions={false}>
<Center>
<EmptyState variant="xl">
<EmptyStateHeader
titleText={text}
headingLevel="h1"
icon={<EmptyStateIcon icon={LoadingIcon} />}
/>
</EmptyState>
</Center>
</SimpleLayout>
);
}

Expand Down
13 changes: 0 additions & 13 deletions web/src/components/layout/three-dots-loader-icon.svg

This file was deleted.

15 changes: 9 additions & 6 deletions web/src/components/network/AddressesDataList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import React from "react";
import {
Button,
DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell, DataListAction,
Flex
Flex,
Stack
} from "@patternfly/react-core";

import { FormLabel } from "~/components/core";
Expand Down Expand Up @@ -115,16 +116,18 @@ export default function AddressesDataList({
const newAddressButtonText = addresses.length ? _("Add another address") : _("Add an address");

return (
<>
<Stack hasGutter>
<Flex justifyContent={{ default: "justifyContentSpaceBetween" }}>
<FormLabel isRequired={!allowEmpty}>{_("Addresses")}</FormLabel>
<Button size="sm" variant="secondary" onClick={addAddress}>
{newAddressButtonText}
</Button>
</Flex>
<DataList isCompact gridBreakpoint="none" title={_("Addresses data list")}>
{addresses.map(address => renderAddress(address))}
</DataList>
</>
<Flex>
<Button size="sm" variant="secondary" onClick={addAddress}>
{newAddressButtonText}
</Button>
</Flex>
</Stack>
);
}
15 changes: 9 additions & 6 deletions web/src/components/network/DnsDataList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import React from "react";
import {
Button,
DataList, DataListItem, DataListItemRow, DataListItemCells, DataListCell, DataListAction,
Flex
Flex,
Stack
} from "@patternfly/react-core";

import { FormLabel } from "~/components/core";
Expand Down Expand Up @@ -92,16 +93,18 @@ export default function DnsDataList({ servers: originalServers, updateDnsServers
const newDnsButtonText = servers.length ? _("Add another DNS") : _("Add DNS");

return (
<>
<Stack hasGutter>
<Flex justifyContent={{ default: "justifyContentSpaceBetween" }}>
<FormLabel>{_("DNS")}</FormLabel>
</Flex>
<DataList isCompact title="Addresses data list">
{servers.map(server => renderDns(server))}
</DataList>
<Flex>
<Button size="sm" variant="secondary" onClick={addServer}>
{newDnsButtonText}
</Button>
</Flex>
<DataList isCompact gridBreakpoint="none" title="Addresses data list">
{servers.map(server => renderDns(server))}
</DataList>
</>
</Stack>
);
}
71 changes: 47 additions & 24 deletions web/src/components/overview/OverviewPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,38 @@
import React, { useEffect, useState } from "react";
import {
CardBody,
Grid,
GridItem,
Hint,
HintBody,
List,
ListItem,
Stack
Grid, GridItem,
Hint, HintBody,
NotificationDrawer,
NotificationDrawerBody,
NotificationDrawerList,
NotificationDrawerListItem,
NotificationDrawerListItemBody,
NotificationDrawerListItemHeader,
Stack,
} from "@patternfly/react-core";
import { useProduct } from "~/context/product";
import { useInstallerClient } from "~/context/installer";
import { Link, Navigate } from "react-router-dom";
import { Center } from "~/components/layout";
import { CardField, EmptyState, Page, InstallButton } from "~/components/core";
import L10nSection from "./L10nSection";
import StorageSection from "./StorageSection";
import SoftwareSection from "./SoftwareSection";
import { _ } from "~/i18n";

const SCOPE_HEADERS = {
user: _("Users"),
storage: _("Storage"),
software: _("Software")
};

const ReadyForInstallation = () => (
<EmptyState title={_("Ready for installation")} icon="check_circle" color="success-color-100">
<InstallButton />
</EmptyState>
<Center>
<EmptyState title={_("Ready for installation")} icon="check_circle" color="success-color-100">
<InstallButton />
</EmptyState>
</Center>
);

// FIXME: improve
Expand All @@ -51,23 +62,28 @@ const IssuesList = ({ issues }) => {
const list = [];
Object.entries(scopes).forEach(([scope, issues]) => {
issues.forEach((issue, idx) => {
const variant = issue.severity === "error" ? "warning" : "info";

const link = (
<ListItem key={idx}>
<Link to={`/${scope}`}>{issue.description}</Link>
</ListItem>
<NotificationDrawerListItem key={idx} variant={variant} isHoverable={false}>
<NotificationDrawerListItemHeader title={SCOPE_HEADERS[scope]} variant={variant} headingLevel="h4" />
<NotificationDrawerListItemBody>
<Link to={`/${scope}`}>{issue.description}</Link>
</NotificationDrawerListItemBody>
</NotificationDrawerListItem>
);
list.push(link);
});
});

return (
<EmptyState
title={_("Before installing the system, you need to pay attention to the following tasks:")}
icon="error"
color="danger-color-100"
>
<List isPlain>{list}</List>
</EmptyState>
<NotificationDrawer>
<NotificationDrawerBody>
<NotificationDrawerList>
{list}
</NotificationDrawerList>
</NotificationDrawerBody>
</NotificationDrawer>
);
};

Expand All @@ -84,6 +100,15 @@ export default function OverviewPage() {
return <Navigate to="/products" />;
}

const resultSectionProps =
issues.isEmpty
? {}
: {

label: _("Installation"),
description: _("Before installing, please check the following problems.")
};

return (
<>
<Page.MainContent>
Expand Down Expand Up @@ -114,11 +139,9 @@ export default function OverviewPage() {
</CardField>
</GridItem>
<GridItem sm={12} xl={6}>
<CardField>
<CardField {...resultSectionProps}>
<CardBody>
<Stack hasGutter>
{issues.isEmpty ? <ReadyForInstallation /> : <IssuesList issues={issues} />}
</Stack>
{issues.isEmpty ? <ReadyForInstallation /> : <IssuesList issues={issues} />}
</CardBody>
</CardField>
</GridItem>
Expand Down
Loading