2022-01-28 12:34:20 +00:00
|
|
|
import { Typography } from "@material-ui/core";
|
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-01-28 12:34:20 +00:00
|
|
|
import { Backlink, Button } from "@saleor/macaw-ui";
|
2020-07-22 10:54:15 +00:00
|
|
|
import classNames from "classnames";
|
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;
|
|
|
|
navigateToAbout: () => void;
|
2020-07-22 10:54:15 +00:00
|
|
|
onBack: () => void;
|
|
|
|
onError: () => void;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
navigateToAbout,
|
2020-07-22 10:54:15 +00:00
|
|
|
onBack,
|
|
|
|
onError
|
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const classes = useStyles({});
|
|
|
|
const [breadcrumbs, onBreadcrumbClick] = useSettingsBreadcrumbs();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container>
|
2021-07-21 08:59:52 +00:00
|
|
|
<Backlink onClick={onBack}>
|
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
|
|
|
|
className={classNames(
|
|
|
|
classes.breadcrumb,
|
|
|
|
classes.breadcrumbDisabled
|
|
|
|
)}
|
|
|
|
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-02-02 15:30:34 +00:00
|
|
|
<Button onClick={navigateToAbout} 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>
|
|
|
|
<Button
|
2022-01-28 12:34:20 +00:00
|
|
|
component="a"
|
2020-07-22 10:54:15 +00:00
|
|
|
href={data?.homepageUrl}
|
2022-01-28 12:34:20 +00:00
|
|
|
variant="primary"
|
2020-07-22 10:54:15 +00:00
|
|
|
data-tc="open-app"
|
|
|
|
target="_blank"
|
|
|
|
>
|
2022-02-02 15:30:34 +00:00
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
id="llC1q8"
|
2022-02-02 15:30:34 +00:00
|
|
|
defaultMessage="App home page"
|
|
|
|
description="button"
|
|
|
|
/>
|
2020-07-22 10:54:15 +00:00
|
|
|
</Button>
|
|
|
|
<Button
|
2022-01-28 12:34:20 +00:00
|
|
|
component="a"
|
2020-07-22 10:54:15 +00:00
|
|
|
href={data?.supportUrl}
|
2022-01-28 12:34:20 +00:00
|
|
|
variant="primary"
|
2020-07-22 10:54:15 +00:00
|
|
|
data-tc="open-support"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
2022-05-05 07:54:28 +00:00
|
|
|
id="hdcGSJ"
|
2020-07-22 10:54:15 +00:00
|
|
|
defaultMessage="Support/FAQ"
|
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</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}
|
|
|
|
/>
|
2021-08-20 13:58:53 +00:00
|
|
|
)}
|
|
|
|
</div>
|
2020-07-22 10:54:15 +00:00
|
|
|
<CardSpacer />
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-02-02 15:30:34 +00:00
|
|
|
AppPage.displayName = "AppPage";
|
|
|
|
export default AppPage;
|