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): handle the 'no patterns' scenario #1472

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jul 17 09:52:36 UTC 2024 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Handle the case where there are not user selectable patterns
(gh#openSUSE/agama#1472).

-------------------------------------------------------------------
Fri Jul 12 10:41:28 UTC 2024 - David Diaz <dgonzalez@suse.com>

Expand Down
44 changes: 29 additions & 15 deletions web/src/components/software/SoftwarePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,32 @@ const SelectedPatternsList = ({ patterns }) => {
);
};

const SelectedPatterns = ({ patterns }) => (
<CardField
label={_("Selected patterns")}
actions={
<ButtonLink to="patterns/select" isPrimary>
{_("Change selection")}
</ButtonLink>
}
>
<CardBody>
<SelectedPatternsList patterns={patterns} />
</CardBody>
</CardField>
);

const NoPatterns = () => (
<CardField label={_("Selected patterns")}>
<CardBody>
<p>
{_(
"This product does not allow to select software patterns during installation. However, you can add additional software once the installation is finished.",
)}
</p>
</CardBody>
</CardField>
);
// FIXME: move build patterns to utils

/**
Expand Down Expand Up @@ -132,7 +158,7 @@ function SoftwarePage() {
}, [client.software, patterns]);

useEffect(() => {
if (patterns.length !== 0) return;
if (!isLoading) return;

const loadPatterns = async () => {
const patterns = await cancellablePromise(client.software.getPatterns());
Expand All @@ -143,7 +169,7 @@ function SoftwarePage() {
};

loadPatterns();
}, [client.software, patterns, cancellablePromise]);
}, [client.software, patterns, cancellablePromise, isLoading]);

if (status === BUSY || isLoading) {
<SectionSkeleton numRows={5} />;
Expand All @@ -161,20 +187,8 @@ function SoftwarePage() {
<IssuesHint issues={issues} />
</GridItem>
<GridItem sm={12} xl={6}>
<CardField
label={_("Selected patterns")}
actions={
<ButtonLink to="patterns/select" isPrimary={patterns.length === 0}>
{_("Change selection")}
</ButtonLink>
}
>
<CardBody>
<SelectedPatternsList patterns={patterns} />
</CardBody>
</CardField>
{patterns.length === 0 ? <NoPatterns /> : <SelectedPatterns patterns={patterns} />}
</GridItem>

<GridItem sm={12} xl={6}>
<CardField>
<CardBody>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/software/UsedSize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function UsedSize({ size }) {

return (
<EmptyState title={message} icon="info" color="success-color-100">
<p>{_("This space includes the base system and the selected software patterns.")}</p>
<p>{_("This space includes the base system and the selected software patterns, if any.")}</p>
</EmptyState>
);
}
Loading