2022-01-28 12:34:20 +00:00
|
|
|
import CardSpacer from "@saleor/components/CardSpacer";
|
2020-07-22 10:54:15 +00:00
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import PageHeader from "@saleor/components/PageHeader";
|
2022-03-09 08:56:55 +00:00
|
|
|
import { AppsInstallationsQuery, AppsListQuery } from "@saleor/graphql";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
|
|
|
import { ListProps } from "@saleor/types";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import AppsInProgress from "../AppsInProgress/AppsInProgress";
|
|
|
|
import CustomApps from "../CustomApps/CustomApps";
|
|
|
|
import InstalledApps from "../InstalledApps/InstalledApps";
|
|
|
|
|
|
|
|
export interface AppsListPageProps extends ListProps {
|
2022-03-09 08:56:55 +00:00
|
|
|
installedAppsList: AppsListQuery["apps"]["edges"];
|
|
|
|
customAppsList: AppsListQuery["apps"]["edges"];
|
|
|
|
appsInProgressList?: AppsInstallationsQuery;
|
2022-05-06 08:59:55 +00:00
|
|
|
getCustomAppHref: (id: string) => string;
|
2020-07-22 10:54:15 +00:00
|
|
|
onInstalledAppRemove: (id: string) => void;
|
|
|
|
onCustomAppRemove: (id: string) => void;
|
|
|
|
onAppInProgressRemove: (id: string) => void;
|
|
|
|
onAppInstallRetry: (id: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const AppsListPage: React.FC<AppsListPageProps> = ({
|
|
|
|
appsInProgressList,
|
|
|
|
customAppsList,
|
|
|
|
installedAppsList,
|
2022-05-06 08:59:55 +00:00
|
|
|
getCustomAppHref,
|
2020-07-22 10:54:15 +00:00
|
|
|
onInstalledAppRemove,
|
|
|
|
onCustomAppRemove,
|
|
|
|
onAppInProgressRemove,
|
|
|
|
onAppInstallRetry,
|
|
|
|
...listProps
|
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
const appsInProgress = appsInProgressList?.appsInstallations;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
|
|
|
<PageHeader title={intl.formatMessage(sectionNames.apps)} />
|
|
|
|
<InstalledApps
|
|
|
|
appsList={installedAppsList}
|
|
|
|
onRemove={onInstalledAppRemove}
|
|
|
|
{...listProps}
|
|
|
|
/>
|
2022-01-28 12:34:20 +00:00
|
|
|
<CardSpacer />
|
2020-07-22 10:54:15 +00:00
|
|
|
<CustomApps
|
|
|
|
appsList={customAppsList}
|
2022-05-06 08:59:55 +00:00
|
|
|
getCustomAppHref={getCustomAppHref}
|
2020-07-22 10:54:15 +00:00
|
|
|
onRemove={onCustomAppRemove}
|
|
|
|
/>
|
2022-05-31 15:18:15 +00:00
|
|
|
{!!appsInProgress?.length && (
|
|
|
|
<>
|
|
|
|
<CardSpacer />
|
|
|
|
<AppsInProgress
|
|
|
|
appsList={appsInProgress}
|
|
|
|
onAppInstallRetry={onAppInstallRetry}
|
|
|
|
onRemove={onAppInProgressRemove}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
)}
|
2020-07-22 10:54:15 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AppsListPage.displayName = "AppsListPage";
|
|
|
|
export default AppsListPage;
|