2020-07-22 10:54:15 +00:00
|
|
|
|
import saleorDarkLogoSmall from "@assets/images/logo-dark-small.svg";
|
|
|
|
|
import plusIcon from "@assets/images/plus-icon.svg";
|
2023-01-16 09:45:12 +00:00
|
|
|
|
import { Button } from "@dashboard/components/Button";
|
|
|
|
|
import CardSpacer from "@dashboard/components/CardSpacer";
|
|
|
|
|
import CardTitle from "@dashboard/components/CardTitle";
|
|
|
|
|
import Container from "@dashboard/components/Container";
|
|
|
|
|
import Hr from "@dashboard/components/Hr";
|
|
|
|
|
import Skeleton from "@dashboard/components/Skeleton";
|
|
|
|
|
import { AppFetchMutation, AppInstallMutation } from "@dashboard/graphql";
|
|
|
|
|
import { SubmitPromise } from "@dashboard/hooks/useForm";
|
|
|
|
|
import { buttonMessages } from "@dashboard/intl";
|
2022-01-28 12:34:20 +00:00
|
|
|
|
import { Card, CardContent, Grid, Typography } from "@material-ui/core";
|
2022-12-02 10:45:19 +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";
|
|
|
|
|
|
|
|
|
|
export interface AppInstallPageProps {
|
2022-12-29 12:51:54 +00:00
|
|
|
|
data: NonNullable<AppFetchMutation["appFetchManifest"]>["manifest"];
|
2020-07-22 10:54:15 +00:00
|
|
|
|
loading: boolean;
|
|
|
|
|
navigateToAppsList: () => void;
|
2022-12-29 12:51:54 +00:00
|
|
|
|
onSubmit: () => SubmitPromise<
|
|
|
|
|
NonNullable<AppInstallMutation["appInstall"]>["errors"]
|
|
|
|
|
>;
|
2020-07-22 10:54:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const AppInstallPage: React.FC<AppInstallPageProps> = ({
|
|
|
|
|
data,
|
|
|
|
|
loading,
|
|
|
|
|
navigateToAppsList,
|
2022-06-21 09:36:55 +00:00
|
|
|
|
onSubmit,
|
2020-07-22 10:54:15 +00:00
|
|
|
|
}) => {
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
const classes = useStyles({});
|
|
|
|
|
|
|
|
|
|
const name = data?.name || "";
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container>
|
|
|
|
|
<CardSpacer />
|
|
|
|
|
<Card>
|
|
|
|
|
<CardTitle
|
|
|
|
|
title={
|
|
|
|
|
loading ? (
|
|
|
|
|
<Skeleton />
|
|
|
|
|
) : (
|
|
|
|
|
intl.formatMessage(
|
|
|
|
|
{
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id: "Id7C0X",
|
2020-07-22 10:54:15 +00:00
|
|
|
|
defaultMessage: `You are about to install {name}`,
|
2022-06-21 09:36:55 +00:00
|
|
|
|
description: "section header",
|
2020-07-22 10:54:15 +00:00
|
|
|
|
},
|
2022-06-21 09:36:55 +00:00
|
|
|
|
{ name },
|
2020-07-22 10:54:15 +00:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<CardContent className={classes.installCard}>
|
|
|
|
|
{loading ? (
|
|
|
|
|
<Skeleton />
|
|
|
|
|
) : (
|
|
|
|
|
<div className={classes.installAppContainer}>
|
|
|
|
|
<div
|
2022-12-02 10:45:19 +00:00
|
|
|
|
className={clsx(classes.installIcon, classes.installSaleorIcon)}
|
2020-07-22 10:54:15 +00:00
|
|
|
|
>
|
|
|
|
|
<img src={saleorDarkLogoSmall} alt="" />
|
|
|
|
|
</div>
|
|
|
|
|
<img src={plusIcon} alt="" />
|
|
|
|
|
<div className={classes.installIcon}>
|
|
|
|
|
<h2>{name?.charAt(0).toUpperCase()}</h2>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<CardSpacer />
|
|
|
|
|
<Card>
|
|
|
|
|
<CardTitle
|
|
|
|
|
title={intl.formatMessage({
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id: "VsGcdP",
|
2020-07-22 10:54:15 +00:00
|
|
|
|
defaultMessage: "App permissions",
|
2022-06-21 09:36:55 +00:00
|
|
|
|
description: "section header",
|
2020-07-22 10:54:15 +00:00
|
|
|
|
})}
|
|
|
|
|
/>
|
|
|
|
|
<CardContent>
|
|
|
|
|
{loading ? (
|
|
|
|
|
<Skeleton />
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<Typography className={classes.installPermissionTitle}>
|
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id="BL/Lbk"
|
2020-07-22 10:54:15 +00:00
|
|
|
|
defaultMessage="Installing this app will give it following permissions:"
|
|
|
|
|
description="install app permissions"
|
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
{!!data?.permissions?.length && (
|
|
|
|
|
<ul className={classes.permissionsContainer}>
|
|
|
|
|
{data?.permissions?.map(perm => (
|
|
|
|
|
<li key={perm.code}>{perm.name}</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
)}
|
|
|
|
|
<Hr className={classes.installSpacer} />
|
|
|
|
|
|
|
|
|
|
<Typography
|
|
|
|
|
variant="body2"
|
|
|
|
|
className={classes.installPrivacyText}
|
|
|
|
|
>
|
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id="t1UYU6"
|
2020-07-22 10:54:15 +00:00
|
|
|
|
defaultMessage="Uninstalling the app will remove all your customer’s personal data stored by {name}. "
|
|
|
|
|
description="install app privacy"
|
|
|
|
|
values={{ name }}
|
|
|
|
|
/>
|
2022-10-10 11:22:16 +00:00
|
|
|
|
{!!data?.dataPrivacyUrl && (
|
|
|
|
|
<a
|
|
|
|
|
href={data?.dataPrivacyUrl}
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="k5lHFp"
|
|
|
|
|
defaultMessage="Learn more about data privacy"
|
|
|
|
|
description="app data privacy link"
|
|
|
|
|
/>
|
|
|
|
|
</a>
|
|
|
|
|
)}
|
2020-07-22 10:54:15 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<CardSpacer />
|
|
|
|
|
<Grid container justify="space-between">
|
|
|
|
|
<Grid xs={6} item>
|
2022-01-28 12:34:20 +00:00
|
|
|
|
<Button variant="secondary" onClick={navigateToAppsList}>
|
|
|
|
|
<FormattedMessage {...buttonMessages.cancel} />
|
2020-07-22 10:54:15 +00:00
|
|
|
|
</Button>
|
|
|
|
|
</Grid>
|
|
|
|
|
<Grid xs={6} item className={classes.alignRight}>
|
2022-01-28 12:34:20 +00:00
|
|
|
|
<Button variant="primary" onClick={onSubmit}>
|
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
|
id="PkCmGU"
|
2022-01-28 12:34:20 +00:00
|
|
|
|
defaultMessage="Install App"
|
|
|
|
|
description="install button"
|
|
|
|
|
/>
|
2020-07-22 10:54:15 +00:00
|
|
|
|
</Button>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppInstallPage.displayName = "AppInstallPage";
|
|
|
|
|
export default AppInstallPage;
|