Skip to content

Commit

Permalink
fix(web): handle the 'no patterns' scenario (agama-project#1472)
Browse files Browse the repository at this point in the history
- Avoid a infinite loop when no patterns are available.
- Do not allow to change patterns if they are not available.
  • Loading branch information
imobachgs authored Jul 17, 2024
2 parents 53eb89e + 9da5e62 commit 776cf9f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
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 <[email protected]>

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

-------------------------------------------------------------------
Fri Jul 12 10:41:28 UTC 2024 - David Diaz <[email protected]>

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>
);
}

0 comments on commit 776cf9f

Please sign in to comment.