saleor-dashboard/src/apps/components/CustomApps/CustomApps.tsx

117 lines
3.7 KiB
TypeScript
Raw Normal View History

Apps (#599) * create Apps view * create more app components, generate types and messages * apps refactor, update snapshots * show error message in tooltip when app installation fail * update apps components and view, add apps list to storybook * update defaultMessages * create app details view * update AppListPage with Skeleton component * create app activate/deactivate dialogs, create app details stories * add AppHeader to AppDetailsPage * update defaultMessages * update AppDetails view and components after review * create custom app details view * refactor webhooks * update webhooks fixtures * update WebhookDetailsPage story * update strings * create CustomAppCreate view and components * update AppListPage story * create AppInstall view and page * handle errors in AppInstall view * update defaultMessages * add AppInstallPage to storybook * add status prop to MessageManager * update defaultMessages * remove service account section * remove service account routes * remove as operator from notify status * add notifications for app installations * update styles for deactivated app * update app installations with local storage * update defaultMessages * AppInstall update * dd delete button to ongoin installations table * fix active installations condition * fix error messages in AppsList * update defaultMessages * add iframe to AppDetailsPage * create AppDetailsSettingsPage * install macaw-ui * apps styles clean up * update schema, fixtures * few apps updates * WebhookCreate - fix onBack button name * WebhookCreatePage story update * rename apps table from external to thirdparty * update defaultMessages * fix test, update snapshots * AppDetailsSettings - add token to headers * fix first number in local apps query * app details settings - use shop domain host * add onSettingsRowClick to InstalledApps * resolve conflicts * update changelog and messages * add noopener noreferrer do app privacy link * update snapshots * update snapshots * updates after review * update defaultMessages * CustomAppDetails - add missing notify status
2020-07-22 10:54:15 +00:00
import Button from "@material-ui/core/Button";
import CardHeader from "@material-ui/core/CardHeader";
import IconButton from "@material-ui/core/IconButton";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableRow from "@material-ui/core/TableRow";
import Typography from "@material-ui/core/Typography";
import DeleteIcon from "@material-ui/icons/Delete";
import { commonMessages } from "@saleor/intl";
import { renderCollection, stopPropagation } from "@saleor/misc";
import React from "react";
import { FormattedMessage } from "react-intl";
import { useStyles } from "../../styles";
import { AppsList_apps_edges } from "../../types/AppsList";
import AppsSkeleton from "../AppsSkeleton";
import CardContainer from "../CardContainer";
import DeactivatedText from "../DeactivatedText";
export interface CustomAppsProps {
appsList: AppsList_apps_edges[];
navigateToCustomApp: (id: string) => () => void;
navigateToCustomAppCreate?: () => void;
onRemove: (id: string) => void;
}
const CustomApps: React.FC<CustomAppsProps> = ({
appsList,
navigateToCustomAppCreate,
onRemove,
navigateToCustomApp
}) => {
const classes = useStyles({});
return (
<CardContainer
header={
<>
<CardHeader
className={classes.title}
action={
!!navigateToCustomAppCreate && (
<Button color="primary" onClick={navigateToCustomAppCreate}>
<FormattedMessage
defaultMessage="Create App"
description="create app button"
/>
</Button>
)
}
title={
<Typography
className={classes.title}
variant="h5"
component="span"
>
<FormattedMessage {...commonMessages.customApps} />
</Typography>
}
/>
<hr className={classes.hr} />
</>
}
>
<TableBody>
{renderCollection(
appsList,
(app, index) =>
app ? (
<TableRow
key={app.node.id}
className={classes.tableRow}
onClick={navigateToCustomApp(app.node.id)}
>
<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}>
<IconButton
color="primary"
onClick={stopPropagation(() => onRemove(app.node.id))}
>
<DeleteIcon />
</IconButton>
</TableCell>
</TableRow>
) : (
<AppsSkeleton key={index} />
),
() => (
<TableRow className={classes.tableRow}>
<TableCell className={classes.colName}>
<Typography className={classes.text} variant="body2">
<FormattedMessage
defaultMessage="Your custom created apps will be shown here."
description="custom apps content"
/>
</Typography>
</TableCell>
</TableRow>
)
)}
</TableBody>
</CardContainer>
);
};
CustomApps.displayName = "CustomApps";
export default CustomApps;