2021-05-14 08:15:15 +00:00
|
|
|
import { Button, 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";
|
|
|
|
import { sectionNames } from "@saleor/intl";
|
2021-07-21 08:59:52 +00:00
|
|
|
import { Backlink } from "@saleor/macaw-ui";
|
|
|
|
import { useTheme } 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";
|
|
|
|
|
|
|
|
import { App_app } from "../../types/App";
|
|
|
|
import { useStyles } from "./styles";
|
2021-06-21 10:55:47 +00:00
|
|
|
import useAppConfigLoader from "./useAppConfigLoader";
|
2020-07-22 10:54:15 +00:00
|
|
|
import useSettingsBreadcrumbs from "./useSettingsBreadcrumbs";
|
|
|
|
|
|
|
|
export interface AppDetailsSettingsPageProps {
|
|
|
|
backendHost: string;
|
|
|
|
data: App_app;
|
|
|
|
navigateToDashboard: () => void;
|
|
|
|
onBack: () => void;
|
|
|
|
onError: () => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const AppDetailsSettingsPage: React.FC<AppDetailsSettingsPageProps> = ({
|
|
|
|
backendHost,
|
|
|
|
data,
|
|
|
|
navigateToDashboard,
|
|
|
|
onBack,
|
|
|
|
onError
|
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
const classes = useStyles({});
|
|
|
|
const [breadcrumbs, onBreadcrumbClick] = useSettingsBreadcrumbs();
|
2021-06-21 10:55:47 +00:00
|
|
|
const { sendThemeToExtension } = useTheme();
|
|
|
|
const frameContainer = useAppConfigLoader(data, backendHost, {
|
|
|
|
onError,
|
|
|
|
onLoad: sendThemeToExtension
|
|
|
|
});
|
2020-07-22 10:54:15 +00:00
|
|
|
|
|
|
|
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}>
|
|
|
|
<Button
|
|
|
|
onClick={navigateToDashboard}
|
|
|
|
variant="contained"
|
|
|
|
color="primary"
|
|
|
|
>
|
|
|
|
<FormattedMessage defaultMessage="Dashboard" description="button" />
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
href={data?.homepageUrl}
|
|
|
|
variant="contained"
|
|
|
|
color="primary"
|
|
|
|
data-tc="open-app"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
<FormattedMessage defaultMessage="My App" description="button" />
|
|
|
|
</Button>
|
|
|
|
<Button
|
|
|
|
href={data?.supportUrl}
|
|
|
|
variant="contained"
|
|
|
|
color="primary"
|
|
|
|
data-tc="open-support"
|
|
|
|
target="_blank"
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Support/FAQ"
|
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Grid>
|
|
|
|
<CardSpacer />
|
|
|
|
|
|
|
|
<Hr />
|
|
|
|
|
|
|
|
<CardSpacer />
|
2021-06-21 10:55:47 +00:00
|
|
|
<div ref={frameContainer} className={classes.iframeContainer} />
|
2020-07-22 10:54:15 +00:00
|
|
|
<CardSpacer />
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
AppDetailsSettingsPage.displayName = "AppDetailsSettingsPage";
|
|
|
|
export default AppDetailsSettingsPage;
|