2022-01-28 12:34:20 +00:00
|
|
|
import { Typography } from "@material-ui/core";
|
2022-05-06 08:59:55 +00:00
|
|
|
import { appsListPath } from "@saleor/apps/urls";
|
|
|
|
import { Backlink } from "@saleor/components/Backlink";
|
|
|
|
import { Button } from "@saleor/components/Button";
|
2020-07-22 10:54:15 +00:00
|
|
|
import CardSpacer from "@saleor/components/CardSpacer";
|
|
|
|
import Container from "@saleor/components/Container";
|
|
|
|
import Grid from "@saleor/components/Grid";
|
|
|
|
import Hr from "@saleor/components/Hr";
|
2022-03-09 08:56:55 +00:00
|
|
|
import { AppQuery } from "@saleor/graphql";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
2022-12-02 10:45:19 +00:00
|
|
|
import clsx from "clsx";
|
2021-06-21 10:55:47 +00:00
|
|
|
import React from "react";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
2021-08-20 13:58:53 +00:00
|
|
|
import { AppFrame } from "../AppFrame";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { useStyles } from "./styles";
|
|
|
|
import useSettingsBreadcrumbs from "./useSettingsBreadcrumbs";
|
|
|
|
|
2022-02-02 15:30:34 +00:00
|
|
|
export interface AppPageProps {
|
2022-03-09 08:56:55 +00:00
|
|
|
data: AppQuery["app"];
|
2022-02-02 15:30:34 +00:00
|
|
|
url: string;
|
2020-07-22 10:54:15 +00:00
|
|
|
onError: () => void;
|
2022-05-06 08:59:55 +00:00
|
|
|
aboutHref: string;
|
2022-07-12 10:30:53 +00:00
|
|
|
refetch?: () => void;
|
2020-07-22 10:54:15 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 15:30:34 +00:00
|
|
|
export const AppPage: React.FC<AppPageProps> = ({
|
2020-07-22 10:54:15 +00:00
|
|
|
data,
|
2022-02-02 15:30:34 +00:00
|
|
|
url,
|
2022-05-06 08:59:55 +00:00
|
|
|
aboutHref,
|
2022-06-21 09:36:55 +00:00
|
|
|
onError,
|
2022-07-12 10:30:53 +00:00
|
|
|
refetch,
|
2020-07-22 10:54:15 +00:00
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const classes = useStyles({});
|
|
|
|
const [breadcrumbs, onBreadcrumbClick] = useSettingsBreadcrumbs();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
2022-05-06 08:59:55 +00:00
|
|
|
<Backlink href={appsListPath}>
|
2020-07-22 10:54:15 +00:00
|
|
|
{intl.formatMessage(sectionNames.apps)}
|
2021-07-21 08:59:52 +00:00
|
|
|
</Backlink>
|
2020-07-22 10:54:15 +00:00
|
|
|
<Grid variant="uniform">
|
|
|
|
<div className={classes.breadcrumbContainer}>
|
|
|
|
<div className={classes.breadcrumbs}>
|
|
|
|
<Typography
|
2022-12-02 10:45:19 +00:00
|
|
|
className={clsx(classes.breadcrumb, classes.breadcrumbDisabled)}
|
2020-07-22 10:54:15 +00:00
|
|
|
variant="h5"
|
|
|
|
>
|
|
|
|
{data?.name}
|
|
|
|
</Typography>
|
|
|
|
{breadcrumbs.map(b => (
|
|
|
|
<Typography
|
|
|
|
className={classes.breadcrumb}
|
|
|
|
variant="h5"
|
|
|
|
onClick={() => onBreadcrumbClick(b.value)}
|
|
|
|
key={b.label}
|
|
|
|
>
|
|
|
|
{b.label}
|
|
|
|
</Typography>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className={classes.appSettingsHeader}>
|
2022-05-06 08:59:55 +00:00
|
|
|
<Button href={aboutHref} variant="primary">
|
2022-05-05 07:54:28 +00:00
|
|
|
<FormattedMessage
|
|
|
|
id="UCHtG6"
|
|
|
|
defaultMessage="About"
|
|
|
|
description="button"
|
|
|
|
/>
|
2020-07-22 10:54:15 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Grid>
|
|
|
|
<CardSpacer />
|
|
|
|
|
|
|
|
<Hr />
|
|
|
|
|
|
|
|
<CardSpacer />
|
2021-08-20 13:58:53 +00:00
|
|
|
<div className={classes.iframeContainer}>
|
2022-02-02 15:30:34 +00:00
|
|
|
{url && (
|
2022-04-25 16:06:45 +00:00
|
|
|
<AppFrame
|
|
|
|
src={url}
|
|
|
|
appToken={data.accessToken}
|
|
|
|
onError={onError}
|
|
|
|
appId={data.id}
|
2022-07-12 10:30:53 +00:00
|
|
|
refetch={refetch}
|
2022-04-25 16:06:45 +00:00
|
|
|
/>
|
2021-08-20 13:58:53 +00:00
|
|
|
)}
|
|
|
|
</div>
|
2020-07-22 10:54:15 +00:00
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-02-02 15:30:34 +00:00
|
|
|
AppPage.displayName = "AppPage";
|
|
|
|
export default AppPage;
|