Skip to content

Commit

Permalink
Application list may install appstream if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
leomoty committed Sep 4, 2023
1 parent f8e8a18 commit 0638493
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions pkg/apps/application-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex/ind
import { Page, PageSection, PageSectionVariants } from "@patternfly/react-core/dist/esm/components/Page/index.js";
import { RebootingIcon } from "@patternfly/react-icons";

import { check_missing_packages } from "packagekit.js";
import * as PackageKit from "./packagekit.js";
import { read_os_release } from "os-release.js";
import { icon_url, show_error, launch, ProgressBar, CancelButton } from "./utils.jsx";
import { ActionButton } from "./application.jsx";
import { EmptyStatePanel } from "cockpit-components-empty-state.jsx";
import { install_dialog } from "cockpit-components-install-dialog.jsx";
import { useInit } from "../lib/hooks.js";

const _ = cockpit.gettext;

Expand Down Expand Up @@ -93,6 +96,7 @@ const ApplicationRow = ({ comp, progress, progress_title, action }) => {

export const ApplicationList = ({ metainfo_db, appProgress, appProgressTitle, action }) => {
const [progress, setProgress] = useState(false);
const [dataPackagesInstalled, setDataPackagesInstalled] = useState(null);
const comps = [];
for (const id in metainfo_db.components)
comps.push(metainfo_db.components[id]);
Expand All @@ -109,14 +113,23 @@ export const ApplicationList = ({ metainfo_db, appProgress, appProgressTitle, ac
}
}

useInit(() => check_missing_packages(['appstream'])
.then(data => setDataPackagesInstalled(data.missing_names.length === 0 && data.unavailable_names.length === 0)));

function refresh() {
read_os_release().then(os_release =>
PackageKit.refresh(metainfo_db.origin_files,
get_config('appstream_config_packages', os_release.ID, []),
get_config('appstream_data_packages', os_release.ID, []),
setProgress))
.finally(() => setProgress(false))
.catch(show_error);
if (dataPackagesInstalled) {
read_os_release().then(os_release =>
PackageKit.refresh(metainfo_db.origin_files,
get_config('appstream_config_packages', os_release.ID, []),
get_config('appstream_data_packages', os_release.ID, []),
setProgress))
.finally(() => setProgress(false))
.catch(show_error);
} else {
install_dialog('appstream')
.then(() => setDataPackagesInstalled(true))
.catch(() => null); // ignore cancel
}
}

let refresh_progress, refresh_button, tbody;
Expand Down Expand Up @@ -159,6 +172,9 @@ export const ApplicationList = ({ metainfo_db, appProgress, appProgressTitle, ac
{comps.length == 0
? <EmptyStatePanel title={ _("No applications installed or available.") } />
: <PageSection>
{dataPackagesInstalled == false && <Alert variant="warning"
isInline
title={_("Appstream data package is missing, only installed applications are shown.")} />}
<Card>
<DataList aria-label={_("Applications list")}>
{ tbody }
Expand Down

0 comments on commit 0638493

Please sign in to comment.