2021-05-14 08:15:15 +00:00
|
|
|
|
import {
|
2022-01-28 12:34:20 +00:00
|
|
|
|
Card,
|
2021-05-14 08:15:15 +00:00
|
|
|
|
TableBody,
|
|
|
|
|
TableCell,
|
|
|
|
|
TableFooter,
|
|
|
|
|
TableRow,
|
|
|
|
|
Typography
|
|
|
|
|
} from "@material-ui/core";
|
2022-05-13 11:04:16 +00:00
|
|
|
|
import { appDetailsUrl, appUrl } from "@saleor/apps/urls";
|
|
|
|
|
import { Button } from "@saleor/components/Button";
|
2020-07-22 10:54:15 +00:00
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
2022-05-13 11:04:16 +00:00
|
|
|
|
import { IconButton } from "@saleor/components/IconButton";
|
|
|
|
|
import { TableButtonWrapper } from "@saleor/components/TableButtonWrapper/TableButtonWrapper";
|
2022-05-31 12:53:16 +00:00
|
|
|
|
import { TablePaginationWithContext } from "@saleor/components/TablePagination";
|
2022-05-06 08:59:55 +00:00
|
|
|
|
import TableRowLink from "@saleor/components/TableRowLink";
|
2022-03-09 08:56:55 +00:00
|
|
|
|
import { AppsListQuery } from "@saleor/graphql";
|
2022-05-13 11:04:16 +00:00
|
|
|
|
import { DeleteIcon, ResponsiveTable } from "@saleor/macaw-ui";
|
|
|
|
|
import { renderCollection } from "@saleor/misc";
|
2020-07-22 10:54:15 +00:00
|
|
|
|
import { ListProps } from "@saleor/types";
|
2022-04-27 10:41:03 +00:00
|
|
|
|
import clsx from "clsx";
|
2020-07-22 10:54:15 +00:00
|
|
|
|
import React from "react";
|
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
|
|
|
|
|
import { useStyles } from "../../styles";
|
|
|
|
|
import AppsSkeleton from "../AppsSkeleton";
|
|
|
|
|
import DeactivatedText from "../DeactivatedText";
|
|
|
|
|
|
|
|
|
|
export interface InstalledAppsProps extends ListProps {
|
2022-03-09 08:56:55 +00:00
|
|
|
|
appsList: AppsListQuery["apps"]["edges"];
|
2020-07-22 10:54:15 +00:00
|
|
|
|
onRemove: (id: string) => void;
|
|
|
|
|
}
|
|
|
|
|
const numberOfColumns = 2;
|
|
|
|
|
|
|
|
|
|
const InstalledApps: React.FC<InstalledAppsProps> = ({
|
|
|
|
|
appsList,
|
|
|
|
|
onRemove,
|
|
|
|
|
settings,
|
|
|
|
|
disabled,
|
|
|
|
|
onUpdateListSettings,
|
|
|
|
|
...props
|
|
|
|
|
}) => {
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-28 12:34:20 +00:00
|
|
|
|
<Card className={classes.apps}>
|
|
|
|
|
<CardTitle
|
|
|
|
|
title={intl.formatMessage({
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id: "ZeD2TK",
|
2022-01-28 12:34:20 +00:00
|
|
|
|
defaultMessage: "Third-party Apps",
|
|
|
|
|
description: "section header"
|
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
<ResponsiveTable>
|
2020-07-22 10:54:15 +00:00
|
|
|
|
<TableFooter>
|
|
|
|
|
<TableRow>
|
2022-05-31 12:53:16 +00:00
|
|
|
|
<TablePaginationWithContext
|
2020-07-22 10:54:15 +00:00
|
|
|
|
colSpan={numberOfColumns}
|
|
|
|
|
settings={settings}
|
|
|
|
|
onUpdateListSettings={onUpdateListSettings}
|
|
|
|
|
/>
|
|
|
|
|
</TableRow>
|
|
|
|
|
</TableFooter>
|
|
|
|
|
<TableBody>
|
|
|
|
|
{renderCollection(
|
|
|
|
|
appsList,
|
|
|
|
|
(app, index) =>
|
|
|
|
|
app ? (
|
2022-05-06 08:59:55 +00:00
|
|
|
|
<TableRowLink
|
2020-07-22 10:54:15 +00:00
|
|
|
|
key={app.node.id}
|
|
|
|
|
className={classes.tableRow}
|
2022-05-06 08:59:55 +00:00
|
|
|
|
href={appUrl(app.node.id)}
|
2020-07-22 10:54:15 +00:00
|
|
|
|
>
|
|
|
|
|
<TableCell className={classes.colName}>
|
|
|
|
|
<span data-tc="name" className={classes.appName}>
|
|
|
|
|
{app.node.name}
|
|
|
|
|
</span>
|
|
|
|
|
{!app.node.isActive && (
|
|
|
|
|
<div className={classes.statusWrapper}>
|
|
|
|
|
<DeactivatedText />
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</TableCell>
|
|
|
|
|
<TableCell className={classes.colAction}>
|
2022-04-27 10:41:03 +00:00
|
|
|
|
{app.node.appUrl && (
|
|
|
|
|
<Typography
|
|
|
|
|
className={clsx(classes.text, classes.appUrl)}
|
|
|
|
|
variant="body2"
|
|
|
|
|
>
|
|
|
|
|
{app.node.appUrl}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
2022-05-13 11:04:16 +00:00
|
|
|
|
<TableButtonWrapper>
|
|
|
|
|
<Button href={appDetailsUrl(app.node.id)}>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="TBaMo2"
|
|
|
|
|
defaultMessage="About"
|
|
|
|
|
description="about app"
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
</TableButtonWrapper>
|
|
|
|
|
<TableButtonWrapper>
|
|
|
|
|
<IconButton
|
|
|
|
|
variant="secondary"
|
|
|
|
|
color="primary"
|
|
|
|
|
onClick={() => onRemove(app.node.id)}
|
|
|
|
|
>
|
|
|
|
|
<DeleteIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</TableButtonWrapper>
|
2020-07-22 10:54:15 +00:00
|
|
|
|
</TableCell>
|
2022-05-06 08:59:55 +00:00
|
|
|
|
</TableRowLink>
|
2020-07-22 10:54:15 +00:00
|
|
|
|
) : (
|
|
|
|
|
<AppsSkeleton key={index} />
|
|
|
|
|
),
|
|
|
|
|
() => (
|
|
|
|
|
<TableRow className={classes.tableRow}>
|
|
|
|
|
<TableCell className={classes.colName}>
|
|
|
|
|
<Typography className={classes.text} variant="body2">
|
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id="9tgY4G"
|
2020-07-22 10:54:15 +00:00
|
|
|
|
defaultMessage="You don’t have any installed apps in your dashboard"
|
|
|
|
|
description="apps content"
|
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
</TableCell>
|
|
|
|
|
</TableRow>
|
|
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
</TableBody>
|
2022-01-28 12:34:20 +00:00
|
|
|
|
</ResponsiveTable>
|
|
|
|
|
</Card>
|
2020-07-22 10:54:15 +00:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
InstalledApps.displayName = "InstalledApps";
|
|
|
|
|
export default InstalledApps;
|