2020-05-14 09:30:32 +00:00
|
|
|
import saleorDarkLogoSmall from "@assets/images/logo-dark-small.svg";
|
|
|
|
import saleorDarkLogo from "@assets/images/logo-dark.svg";
|
|
|
|
import menuArrowIcon from "@assets/images/menu-arrow-icon.svg";
|
2019-08-09 11:14:35 +00:00
|
|
|
import Avatar from "@material-ui/core/Avatar";
|
2019-06-19 14:40:52 +00:00
|
|
|
import Chip from "@material-ui/core/Chip";
|
|
|
|
import ClickAwayListener from "@material-ui/core/ClickAwayListener";
|
|
|
|
import Grow from "@material-ui/core/Grow";
|
2019-08-09 11:14:35 +00:00
|
|
|
import Hidden from "@material-ui/core/Hidden";
|
2019-06-19 14:40:52 +00:00
|
|
|
import LinearProgress from "@material-ui/core/LinearProgress";
|
|
|
|
import MenuItem from "@material-ui/core/MenuItem";
|
|
|
|
import Menu from "@material-ui/core/MenuList";
|
|
|
|
import Paper from "@material-ui/core/Paper";
|
|
|
|
import Popper from "@material-ui/core/Popper";
|
2019-10-30 14:34:24 +00:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2019-10-09 15:14:23 +00:00
|
|
|
import { createConfigurationMenu } from "@saleor/configuration";
|
2019-11-14 14:10:52 +00:00
|
|
|
import useAppState from "@saleor/hooks/useAppState";
|
2019-08-09 11:14:35 +00:00
|
|
|
import useLocalStorage from "@saleor/hooks/useLocalStorage";
|
2019-06-19 14:40:52 +00:00
|
|
|
import useNavigator from "@saleor/hooks/useNavigator";
|
|
|
|
import useTheme from "@saleor/hooks/useTheme";
|
|
|
|
import useUser from "@saleor/hooks/useUser";
|
2019-08-09 11:14:35 +00:00
|
|
|
import ArrowDropdown from "@saleor/icons/ArrowDropdown";
|
2019-10-25 12:54:14 +00:00
|
|
|
import { staffMemberDetailsUrl } from "@saleor/staff/urls";
|
2020-05-14 09:30:32 +00:00
|
|
|
import classNames from "classnames";
|
|
|
|
import React from "react";
|
|
|
|
import SVG from "react-inlinesvg";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
import useRouter from "use-react-router";
|
|
|
|
|
2019-06-19 14:40:52 +00:00
|
|
|
import Container from "../Container";
|
2019-11-14 14:10:52 +00:00
|
|
|
import ErrorPage from "../ErrorPage";
|
2019-06-19 14:40:52 +00:00
|
|
|
import AppActionContext from "./AppActionContext";
|
|
|
|
import AppHeaderContext from "./AppHeaderContext";
|
2019-08-09 11:14:35 +00:00
|
|
|
import { appLoaderHeight, drawerWidth, drawerWidthExpanded } from "./consts";
|
2019-06-19 14:40:52 +00:00
|
|
|
import MenuList from "./MenuList";
|
2019-08-29 10:55:56 +00:00
|
|
|
import createMenuStructure from "./menuStructure";
|
2019-06-19 14:40:52 +00:00
|
|
|
import ResponsiveDrawer from "./ResponsiveDrawer";
|
|
|
|
import ThemeSwitch from "./ThemeSwitch";
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
theme => ({
|
2019-06-19 14:40:52 +00:00
|
|
|
appAction: {
|
2019-10-22 11:32:45 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
left: 0,
|
|
|
|
width: "100%"
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
bottom: 0,
|
|
|
|
gridColumn: 2,
|
2019-10-23 15:10:46 +00:00
|
|
|
position: "sticky",
|
2019-09-16 02:14:57 +00:00
|
|
|
zIndex: 10
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
appLoader: {
|
|
|
|
height: appLoaderHeight,
|
2019-10-28 16:16:49 +00:00
|
|
|
marginBottom: theme.spacing(2),
|
2019-06-19 14:40:52 +00:00
|
|
|
zIndex: 1201
|
|
|
|
},
|
2019-10-23 15:10:46 +00:00
|
|
|
appLoaderPlaceholder: {
|
|
|
|
height: appLoaderHeight,
|
2019-10-28 16:16:49 +00:00
|
|
|
marginBottom: theme.spacing(2)
|
2019-10-23 15:10:46 +00:00
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
arrow: {
|
2019-10-28 16:16:49 +00:00
|
|
|
marginLeft: theme.spacing(2),
|
2019-06-19 14:40:52 +00:00
|
|
|
transition: theme.transitions.duration.standard + "ms"
|
|
|
|
},
|
2019-11-12 16:28:21 +00:00
|
|
|
avatar: {
|
|
|
|
"&&": {
|
|
|
|
height: 32,
|
|
|
|
width: 32
|
|
|
|
}
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
content: {
|
2019-08-09 11:14:35 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
paddingLeft: 0
|
|
|
|
},
|
|
|
|
paddingLeft: drawerWidthExpanded,
|
|
|
|
transition: "padding-left 0.5s ease",
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
contentToggle: {
|
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
paddingLeft: 0
|
|
|
|
},
|
|
|
|
paddingLeft: drawerWidth
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
darkThemeSwitch: {
|
2019-11-12 16:28:21 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
marginRight: -theme.spacing(1.5)
|
|
|
|
},
|
2019-10-28 16:16:49 +00:00
|
|
|
marginRight: theme.spacing(2)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
header: {
|
2019-11-12 16:28:21 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
height: 88,
|
|
|
|
marginBottom: 0
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
display: "flex",
|
|
|
|
height: 40,
|
2019-10-28 16:16:49 +00:00
|
|
|
marginBottom: theme.spacing(3)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
2019-08-09 11:14:35 +00:00
|
|
|
isMenuSmall: {
|
|
|
|
"& path": {
|
|
|
|
fill: theme.palette.primary.main
|
|
|
|
},
|
|
|
|
"& span": {
|
|
|
|
margin: "0 8px"
|
|
|
|
},
|
|
|
|
"& svg": {
|
2019-09-26 12:40:32 +00:00
|
|
|
marginTop: 8,
|
2019-08-09 11:14:35 +00:00
|
|
|
transform: "rotate(180deg)"
|
|
|
|
},
|
|
|
|
"&:hover": {
|
|
|
|
background: "#E6F3F3"
|
|
|
|
},
|
|
|
|
background: theme.palette.background.paper,
|
|
|
|
border: `solid 1px #EAEAEA`,
|
|
|
|
borderRadius: "50%",
|
|
|
|
cursor: "pointer",
|
|
|
|
height: 32,
|
|
|
|
position: "absolute",
|
|
|
|
right: -16,
|
|
|
|
top: 65,
|
|
|
|
transition: `background ${theme.transitions.duration.shorter}ms`,
|
|
|
|
width: 32,
|
|
|
|
zIndex: 99
|
|
|
|
},
|
|
|
|
isMenuSmallDark: {
|
|
|
|
"&:hover": {
|
2019-08-29 10:55:56 +00:00
|
|
|
background: `linear-gradient(0deg, rgba(25, 195, 190, 0.1), rgba(25, 195, 190, 0.1)), ${theme.palette.background.paper}`
|
2019-08-09 11:14:35 +00:00
|
|
|
},
|
|
|
|
border: `solid 1px #252728`,
|
|
|
|
transition: `background ${theme.transitions.duration.shorter}ms`
|
|
|
|
},
|
|
|
|
isMenuSmallHide: {
|
|
|
|
"& svg": {
|
2019-09-26 12:40:32 +00:00
|
|
|
marginLeft: "3px",
|
2019-08-09 11:14:35 +00:00
|
|
|
transform: "rotate(0deg)"
|
|
|
|
}
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
logo: {
|
|
|
|
"& svg": {
|
2019-09-26 12:40:32 +00:00
|
|
|
left: "50%",
|
|
|
|
position: "absolute",
|
|
|
|
top: "50%",
|
|
|
|
transform: "translate(-50%,-50%)"
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
2019-08-09 11:14:35 +00:00
|
|
|
background: theme.palette.secondary.main,
|
2019-06-19 14:40:52 +00:00
|
|
|
display: "block",
|
2019-09-26 12:40:32 +00:00
|
|
|
height: 80,
|
|
|
|
position: "relative"
|
2019-08-09 11:14:35 +00:00
|
|
|
},
|
|
|
|
logoDark: {
|
|
|
|
"& path": {
|
|
|
|
fill: theme.palette.common.white
|
|
|
|
},
|
|
|
|
background: theme.palette.primary.main
|
|
|
|
},
|
|
|
|
logoSmall: {
|
|
|
|
"& svg": {
|
2019-09-26 12:40:32 +00:00
|
|
|
margin: 0,
|
2019-09-09 14:02:12 +00:00
|
|
|
padding: 0,
|
|
|
|
width: "80px"
|
2019-08-09 11:14:35 +00:00
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
menu: {
|
2019-08-09 11:14:35 +00:00
|
|
|
background: theme.palette.background.paper,
|
|
|
|
height: "100vh",
|
2019-09-26 12:40:32 +00:00
|
|
|
padding: "25px 20px"
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
menuIcon: {
|
|
|
|
"& span": {
|
|
|
|
"&:nth-child(1)": {
|
|
|
|
top: 15
|
|
|
|
},
|
|
|
|
"&:nth-child(2), &:nth-child(3)": {
|
|
|
|
top: 20
|
|
|
|
},
|
|
|
|
"&:nth-child(4)": {
|
|
|
|
top: 25
|
|
|
|
},
|
|
|
|
background: theme.palette.secondary.light,
|
|
|
|
display: "block",
|
|
|
|
height: 1,
|
|
|
|
left: "20%",
|
|
|
|
opacity: 1,
|
|
|
|
position: "absolute",
|
|
|
|
transform: "rotate(0deg)",
|
|
|
|
transition: ".25s ease-in-out",
|
|
|
|
width: "60%"
|
|
|
|
},
|
2019-08-09 11:14:35 +00:00
|
|
|
[theme.breakpoints.up("md")]: {
|
|
|
|
display: "none"
|
|
|
|
},
|
2019-11-12 16:28:21 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
left: 0
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
background: theme.palette.background.paper,
|
|
|
|
borderRadius: "50%",
|
|
|
|
cursor: "pointer",
|
|
|
|
height: 42,
|
2019-10-28 16:16:49 +00:00
|
|
|
left: theme.spacing(),
|
|
|
|
marginRight: theme.spacing(2),
|
2019-06-19 14:40:52 +00:00
|
|
|
position: "relative",
|
|
|
|
transform: "rotate(0deg)",
|
2019-08-09 11:14:35 +00:00
|
|
|
transition: `${theme.transitions.duration.shorter}ms ease-in-out`,
|
2019-06-19 14:40:52 +00:00
|
|
|
width: 42
|
|
|
|
},
|
|
|
|
menuIconDark: {
|
|
|
|
"& span": {
|
|
|
|
background: theme.palette.common.white
|
|
|
|
}
|
|
|
|
},
|
|
|
|
menuIconOpen: {
|
|
|
|
"& span": {
|
|
|
|
"&:nth-child(1), &:nth-child(4)": {
|
|
|
|
left: "50%",
|
|
|
|
top: 20,
|
|
|
|
width: 0
|
|
|
|
},
|
|
|
|
"&:nth-child(2)": {
|
|
|
|
transform: "rotate(45deg)"
|
|
|
|
},
|
|
|
|
"&:nth-child(3)": {
|
|
|
|
transform: "rotate(-45deg)"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
left: 280,
|
|
|
|
position: "absolute",
|
|
|
|
zIndex: 1999
|
|
|
|
},
|
2019-08-09 11:14:35 +00:00
|
|
|
menuSmall: {
|
|
|
|
background: theme.palette.background.paper,
|
|
|
|
height: "100vh",
|
2019-09-02 10:04:39 +00:00
|
|
|
overflow: "hidden",
|
2019-08-09 11:14:35 +00:00
|
|
|
padding: 25
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
popover: {
|
|
|
|
zIndex: 1
|
|
|
|
},
|
|
|
|
root: {
|
2019-08-09 11:14:35 +00:00
|
|
|
width: `100%`
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
rotate: {
|
|
|
|
transform: "rotate(180deg)"
|
|
|
|
},
|
|
|
|
sideBar: {
|
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
padding: 0
|
|
|
|
},
|
|
|
|
background: theme.palette.background.paper,
|
2019-10-28 16:16:49 +00:00
|
|
|
padding: `0 ${theme.spacing(4)}px`
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
spacer: {
|
|
|
|
flex: 1
|
|
|
|
},
|
|
|
|
userBar: {
|
2019-11-12 16:28:21 +00:00
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
alignItems: "flex-end",
|
|
|
|
flexDirection: "column-reverse",
|
|
|
|
overflow: "hidden"
|
|
|
|
},
|
2019-06-19 14:40:52 +00:00
|
|
|
alignItems: "center",
|
|
|
|
display: "flex"
|
|
|
|
},
|
|
|
|
userChip: {
|
2019-08-09 11:14:35 +00:00
|
|
|
backgroundColor: theme.palette.background.paper,
|
2019-11-12 16:28:21 +00:00
|
|
|
borderRadius: 24,
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
height: 40,
|
|
|
|
padding: theme.spacing(0.5)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
|
|
|
userMenuContainer: {
|
|
|
|
position: "relative"
|
|
|
|
},
|
|
|
|
userMenuItem: {
|
|
|
|
textAlign: "right"
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
flex: 1,
|
|
|
|
flexGrow: 1,
|
|
|
|
marginLeft: 0,
|
2019-10-28 16:16:49 +00:00
|
|
|
paddingBottom: theme.spacing(),
|
2019-10-23 15:10:46 +00:00
|
|
|
[theme.breakpoints.up("sm")]: {
|
2019-10-28 16:16:49 +00:00
|
|
|
paddingBottom: theme.spacing(3)
|
2019-10-23 15:10:46 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
viewContainer: {
|
2019-10-28 16:16:49 +00:00
|
|
|
minHeight: `calc(100vh - ${theme.spacing(2) + appLoaderHeight + 70}px)`
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
2019-10-30 14:34:24 +00:00
|
|
|
}),
|
|
|
|
{
|
|
|
|
name: "AppLayout"
|
|
|
|
}
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
interface AppLayoutProps {
|
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const AppLayout: React.FC<AppLayoutProps> = ({ children }) => {
|
|
|
|
const classes = useStyles({});
|
|
|
|
const { isDark, toggleTheme } = useTheme();
|
|
|
|
const [isMenuSmall, setMenuSmall] = useLocalStorage("isMenuSmall", false);
|
|
|
|
const [isDrawerOpened, setDrawerState] = React.useState(false);
|
|
|
|
const [isMenuOpened, setMenuState] = React.useState(false);
|
|
|
|
const appActionAnchor = React.useRef<HTMLDivElement>();
|
|
|
|
const appHeaderAnchor = React.useRef<HTMLDivElement>();
|
|
|
|
const anchor = React.useRef<HTMLDivElement>();
|
|
|
|
const { logout, user } = useUser();
|
|
|
|
const navigate = useNavigator();
|
|
|
|
const intl = useIntl();
|
|
|
|
const [appState, dispatchAppState] = useAppState();
|
|
|
|
const { location } = useRouter();
|
2019-08-29 10:55:56 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const menuStructure = createMenuStructure(intl);
|
|
|
|
const configurationMenu = createConfigurationMenu(intl);
|
2020-04-23 15:43:08 +00:00
|
|
|
const userPermissions = user?.userPermissions || [];
|
2019-10-09 15:14:23 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const renderConfigure = configurationMenu.some(section =>
|
|
|
|
section.menuItems.some(
|
|
|
|
menuItem =>
|
|
|
|
!!userPermissions.find(
|
|
|
|
userPermission => userPermission.code === menuItem.permission
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const handleLogout = () => {
|
|
|
|
setMenuState(false);
|
|
|
|
logout();
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const handleViewerProfile = () => {
|
|
|
|
setMenuState(false);
|
|
|
|
navigate(staffMemberDetailsUrl(user.id));
|
|
|
|
};
|
2019-10-16 15:18:29 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const handleMenuItemClick = (url: string, event: React.MouseEvent<any>) => {
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
|
|
|
setDrawerState(false);
|
|
|
|
navigate(url);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const handleIsMenuSmall = () => {
|
|
|
|
setMenuSmall(!isMenuSmall);
|
|
|
|
};
|
2019-08-09 11:14:35 +00:00
|
|
|
|
2019-11-14 14:10:52 +00:00
|
|
|
const handleErrorBack = () => {
|
|
|
|
navigate("/");
|
|
|
|
dispatchAppState({
|
|
|
|
payload: {
|
|
|
|
error: null
|
|
|
|
},
|
|
|
|
type: "displayError"
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AppHeaderContext.Provider value={appHeaderAnchor}>
|
|
|
|
<AppActionContext.Provider value={appActionAnchor}>
|
|
|
|
<div className={classes.root}>
|
|
|
|
<div className={classes.sideBar}>
|
|
|
|
<ResponsiveDrawer
|
|
|
|
onClose={() => setDrawerState(false)}
|
|
|
|
open={isDrawerOpened}
|
|
|
|
small={!isMenuSmall}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className={classNames(classes.logo, {
|
|
|
|
[classes.logoSmall]: isMenuSmall,
|
|
|
|
[classes.logoDark]: isDark
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
<SVG src={isMenuSmall ? saleorDarkLogoSmall : saleorDarkLogo} />
|
|
|
|
</div>
|
|
|
|
<Hidden smDown>
|
|
|
|
<div
|
|
|
|
className={classNames(classes.isMenuSmall, {
|
|
|
|
[classes.isMenuSmallHide]: isMenuSmall,
|
|
|
|
[classes.isMenuSmallDark]: isDark
|
|
|
|
})}
|
|
|
|
onClick={handleIsMenuSmall}
|
|
|
|
>
|
|
|
|
<SVG src={menuArrowIcon} />
|
|
|
|
</div>
|
|
|
|
</Hidden>
|
|
|
|
<MenuList
|
|
|
|
className={isMenuSmall ? classes.menuSmall : classes.menu}
|
|
|
|
menuItems={menuStructure}
|
|
|
|
isMenuSmall={!isMenuSmall}
|
|
|
|
location={location.pathname}
|
|
|
|
user={user}
|
|
|
|
renderConfigure={renderConfigure}
|
|
|
|
onMenuItemClick={handleMenuItemClick}
|
|
|
|
/>
|
|
|
|
</ResponsiveDrawer>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className={classNames(classes.content, {
|
|
|
|
[classes.contentToggle]: isMenuSmall
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{appState.loading ? (
|
|
|
|
<LinearProgress className={classes.appLoader} color="primary" />
|
|
|
|
) : (
|
|
|
|
<div className={classes.appLoaderPlaceholder} />
|
|
|
|
)}
|
|
|
|
<div className={classes.viewContainer}>
|
|
|
|
<div>
|
|
|
|
<Container>
|
|
|
|
<div className={classes.header}>
|
2019-10-30 14:34:24 +00:00
|
|
|
<div
|
2019-11-14 14:10:52 +00:00
|
|
|
className={classNames(classes.menuIcon, {
|
|
|
|
[classes.menuIconOpen]: isDrawerOpened,
|
|
|
|
[classes.menuIconDark]: isDark
|
2019-10-30 14:34:24 +00:00
|
|
|
})}
|
2019-11-14 14:10:52 +00:00
|
|
|
onClick={() => setDrawerState(!isDrawerOpened)}
|
2019-06-19 14:40:52 +00:00
|
|
|
>
|
2019-11-14 14:10:52 +00:00
|
|
|
<span />
|
|
|
|
<span />
|
|
|
|
<span />
|
|
|
|
<span />
|
2019-10-30 14:34:24 +00:00
|
|
|
</div>
|
2019-11-14 14:10:52 +00:00
|
|
|
<div ref={appHeaderAnchor} />
|
|
|
|
<div className={classes.spacer} />
|
|
|
|
<div className={classes.userBar}>
|
|
|
|
<ThemeSwitch
|
|
|
|
className={classes.darkThemeSwitch}
|
|
|
|
checked={isDark}
|
|
|
|
onClick={toggleTheme}
|
|
|
|
/>
|
|
|
|
<div className={classes.userMenuContainer} ref={anchor}>
|
|
|
|
<Chip
|
|
|
|
avatar={
|
|
|
|
user.avatar && (
|
|
|
|
<Avatar alt="user" src={user.avatar.url} />
|
|
|
|
)
|
|
|
|
}
|
2019-11-12 16:28:21 +00:00
|
|
|
classes={{
|
|
|
|
avatar: classes.avatar
|
|
|
|
}}
|
2019-11-14 14:10:52 +00:00
|
|
|
className={classes.userChip}
|
|
|
|
label={
|
|
|
|
<>
|
|
|
|
{user.email}
|
|
|
|
<ArrowDropdown
|
|
|
|
className={classNames(classes.arrow, {
|
|
|
|
[classes.rotate]: isMenuOpened
|
|
|
|
})}
|
2019-06-19 14:40:52 +00:00
|
|
|
/>
|
2019-11-14 14:10:52 +00:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
onClick={() => setMenuState(!isMenuOpened)}
|
|
|
|
/>
|
|
|
|
<Popper
|
|
|
|
className={classes.popover}
|
|
|
|
open={isMenuOpened}
|
|
|
|
anchorEl={anchor.current}
|
|
|
|
transition
|
|
|
|
placement="bottom-end"
|
|
|
|
>
|
|
|
|
{({ TransitionProps, placement }) => (
|
|
|
|
<Grow
|
|
|
|
{...TransitionProps}
|
|
|
|
style={{
|
|
|
|
transformOrigin:
|
|
|
|
placement === "bottom"
|
|
|
|
? "right top"
|
|
|
|
: "right bottom"
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Paper>
|
|
|
|
<ClickAwayListener
|
|
|
|
onClickAway={() => setMenuState(false)}
|
|
|
|
mouseEvent="onClick"
|
|
|
|
>
|
|
|
|
<Menu>
|
|
|
|
<MenuItem
|
|
|
|
className={classes.userMenuItem}
|
|
|
|
onClick={handleViewerProfile}
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Account Settings"
|
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</MenuItem>
|
|
|
|
<MenuItem
|
|
|
|
className={classes.userMenuItem}
|
|
|
|
onClick={handleLogout}
|
|
|
|
>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Log out"
|
|
|
|
description="button"
|
|
|
|
/>
|
|
|
|
</MenuItem>
|
|
|
|
</Menu>
|
|
|
|
</ClickAwayListener>
|
|
|
|
</Paper>
|
|
|
|
</Grow>
|
|
|
|
)}
|
|
|
|
</Popper>
|
|
|
|
</div>
|
2019-06-19 14:40:52 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-11-14 14:10:52 +00:00
|
|
|
</Container>
|
2019-10-30 14:34:24 +00:00
|
|
|
</div>
|
2019-11-14 14:10:52 +00:00
|
|
|
<main className={classes.view}>
|
2020-02-20 14:18:22 +00:00
|
|
|
{appState.error
|
|
|
|
? appState.error === "unhandled" && (
|
|
|
|
<ErrorPage onBack={handleErrorBack} />
|
|
|
|
)
|
|
|
|
: children}
|
2019-11-14 14:10:52 +00:00
|
|
|
</main>
|
|
|
|
</div>
|
|
|
|
<div className={classes.appAction} ref={appActionAnchor} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</AppActionContext.Provider>
|
|
|
|
</AppHeaderContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export default AppLayout;
|