Skip to content

Commit

Permalink
Do not nest the components
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jan 20, 2025
1 parent f2b7fcb commit c050f35
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions web/src/components/software/SoftwarePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,33 @@ const errorMsg = _(
The system cannot be installed without them.",
);

// error message, allow reloading the repositories again
const ReloadSection = ({
loading,
action,
}: {
loading: boolean;
action: () => void;
}): React.ReactNode => (
// TRANSLATORS: title for an error message box, at least one repository could not be loaded
<Alert variant="danger" isInline title={_("Repository load failed")}>
{loading ? (
<>
{/* TRANSLATORS: progress message */}
<Spinner size="md" /> {_("Loading the installation repositories...")}
</>
) : (
<>
{errorMsg}{" "}
<Button variant="link" isInline onClick={action}>
{/* TRANSLATORS: link for retrying failed repository load */}
{_("Try again")}
</Button>
</>
)}
</Alert>
);

/**
* Software page component
*/
Expand All @@ -124,25 +151,6 @@ function SoftwarePage(): React.ReactNode {
probe();
};

const ReloadSection = (): React.ReactNode => (
// TRANSLATORS: title for an error message box, at least one repository could not be loaded
<Alert variant="danger" isInline title={_("Repository load failed")}>
{loading ? (
<>
<Spinner size="md" /> {_("Loading the installation repositories...")}
</>
) : (
<>
{errorMsg}{" "}
<Button variant="link" isInline onClick={startProbing}>
{/* TRANSLATORS: link for retrying failed repository load */}
{_("Try again")}
</Button>
</>
)}
</Alert>
);

const showReposAlert = repos.some((r) => !r.loaded);

return (
Expand All @@ -158,7 +166,7 @@ function SoftwarePage(): React.ReactNode {
</GridItem>
{showReposAlert && (
<GridItem sm={12}>
<ReloadSection />
<ReloadSection loading={loading} action={startProbing} />
</GridItem>
)}
<GridItem sm={12} xl={selectedPatternsXlSize}>
Expand Down

0 comments on commit c050f35

Please sign in to comment.