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
|
|
|
CircularProgress as Progress,
|
|
|
|
TableBody,
|
|
|
|
TableCell,
|
|
|
|
TableRow,
|
|
|
|
Tooltip,
|
|
|
|
Typography
|
|
|
|
} from "@material-ui/core";
|
2020-07-22 10:54:15 +00:00
|
|
|
import ErrorIcon from "@material-ui/icons/Error";
|
2022-05-13 11:04:16 +00:00
|
|
|
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-03-09 08:56:55 +00:00
|
|
|
import { AppsInstallationsQuery, JobStatusEnum } 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 classNames from "classnames";
|
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import { useStyles } from "../../styles";
|
|
|
|
|
|
|
|
export interface AppsInProgressProps {
|
2022-03-09 08:56:55 +00:00
|
|
|
appsList: AppsInstallationsQuery["appsInstallations"];
|
2020-07-22 10:54:15 +00:00
|
|
|
disabled: boolean;
|
|
|
|
onAppInstallRetry: (id: string) => void;
|
|
|
|
onRemove: (id: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const AppsInProgress: React.FC<AppsInProgressProps> = ({
|
|
|
|
appsList,
|
|
|
|
disabled,
|
|
|
|
onAppInstallRetry,
|
|
|
|
onRemove,
|
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
2022-01-28 12:34:20 +00:00
|
|
|
<Card>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage({
|
2022-05-05 07:54:28 +00:00
|
|
|
id: "nIrjSR",
|
2022-01-28 12:34:20 +00:00
|
|
|
defaultMessage: "Ongoing Installations",
|
|
|
|
description: "section header"
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<ResponsiveTable>
|
|
|
|
<TableBody>
|
|
|
|
{renderCollection(appsList, ({ status, appName, id, message }) => (
|
|
|
|
<TableRow key={id} className={classes.tableRow}>
|
|
|
|
<TableCell className={classes.colName}>
|
|
|
|
<span data-tc="name">{appName}</span>
|
2020-07-22 10:54:15 +00:00
|
|
|
</TableCell>
|
2022-01-28 12:34:20 +00:00
|
|
|
{status === JobStatusEnum.PENDING && (
|
|
|
|
<TableCell
|
|
|
|
className={classNames(
|
|
|
|
classes.colAction,
|
|
|
|
classes.colInstallAction
|
|
|
|
)}
|
2020-07-22 10:54:15 +00:00
|
|
|
>
|
2022-01-28 12:34:20 +00:00
|
|
|
<Typography variant="body2" className={classes.text}>
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
id="1qRwgQ"
|
2022-01-28 12:34:20 +00:00
|
|
|
defaultMessage="Installing app..."
|
|
|
|
description="app installation"
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
<div className={classes.colSpinner}>
|
|
|
|
<Progress size={20} />
|
|
|
|
</div>
|
|
|
|
</TableCell>
|
|
|
|
)}
|
|
|
|
{status === JobStatusEnum.FAILED && (
|
|
|
|
<TableCell
|
|
|
|
className={classNames(
|
|
|
|
classes.colAction,
|
|
|
|
classes.colInstallAction
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<Typography variant="body2" className={classes.error}>
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
id="JufWFT"
|
2022-01-28 12:34:20 +00:00
|
|
|
defaultMessage="There was a problem during installation"
|
|
|
|
description="app installation error"
|
|
|
|
/>
|
|
|
|
<Tooltip
|
|
|
|
title={<Typography variant="body2">{message}</Typography>}
|
|
|
|
classes={{
|
|
|
|
tooltip: classes.customTooltip
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<ErrorIcon />
|
|
|
|
</Tooltip>
|
|
|
|
</Typography>
|
2022-05-13 11:04:16 +00:00
|
|
|
<TableButtonWrapper>
|
|
|
|
<Button onClick={() => onAppInstallRetry(id)}>
|
|
|
|
<FormattedMessage
|
|
|
|
id="+c/f61"
|
|
|
|
defaultMessage="Retry"
|
|
|
|
description="retry installation"
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
</TableButtonWrapper>
|
|
|
|
<TableButtonWrapper>
|
|
|
|
<IconButton
|
|
|
|
variant="secondary"
|
|
|
|
color="primary"
|
|
|
|
onClick={() => onRemove(id)}
|
|
|
|
>
|
|
|
|
<DeleteIcon />
|
|
|
|
</IconButton>
|
|
|
|
</TableButtonWrapper>
|
2022-01-28 12:34:20 +00:00
|
|
|
</TableCell>
|
|
|
|
)}
|
|
|
|
</TableRow>
|
|
|
|
))}
|
|
|
|
</TableBody>
|
|
|
|
</ResponsiveTable>
|
|
|
|
</Card>
|
2020-07-22 10:54:15 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AppsInProgress.displayName = "AppsInProgress";
|
|
|
|
export default AppsInProgress;
|