2020-03-28 12:25:55 -08:00
|
|
|
import React, { forwardRef } from 'react'
|
2020-09-30 16:36:51 -08:00
|
|
|
import { AppBar as RAAppBar, UserMenu, useTranslate } from 'react-admin'
|
|
|
|
|
import { makeStyles, MenuItem, ListItemIcon } from '@material-ui/core'
|
2020-03-28 12:25:55 -08:00
|
|
|
import InfoIcon from '@material-ui/icons/Info'
|
2020-09-30 16:36:51 -08:00
|
|
|
import AboutDialog from './AboutDialog'
|
2020-02-05 19:08:04 -09:00
|
|
|
|
2020-03-31 06:49:47 -08:00
|
|
|
const useStyles = makeStyles((theme) => ({
|
2020-09-30 16:36:51 -08:00
|
|
|
root: {
|
2020-03-31 06:49:47 -08:00
|
|
|
color: theme.palette.text.secondary,
|
|
|
|
|
},
|
2020-09-30 16:36:51 -08:00
|
|
|
active: {
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
},
|
|
|
|
|
icon: { minWidth: theme.spacing(5) },
|
2020-03-31 06:49:47 -08:00
|
|
|
}))
|
|
|
|
|
|
2020-09-30 16:36:51 -08:00
|
|
|
const AboutMenuItem = forwardRef(({ onClick, ...rest }, ref) => {
|
|
|
|
|
const classes = useStyles(rest)
|
2020-03-31 07:17:11 -08:00
|
|
|
const translate = useTranslate()
|
2020-09-30 16:36:51 -08:00
|
|
|
const [open, setOpen] = React.useState(false)
|
|
|
|
|
|
|
|
|
|
const handleOpen = () => {
|
|
|
|
|
setOpen(true)
|
|
|
|
|
}
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
onClick && onClick()
|
|
|
|
|
setOpen(false)
|
|
|
|
|
}
|
|
|
|
|
const label = translate('menu.about')
|
2020-03-31 06:49:47 -08:00
|
|
|
return (
|
2020-09-30 16:36:51 -08:00
|
|
|
<>
|
|
|
|
|
<MenuItem
|
|
|
|
|
ref={ref}
|
|
|
|
|
onClick={handleOpen}
|
|
|
|
|
className={classes.root}
|
|
|
|
|
activeClassName={classes.active}
|
|
|
|
|
>
|
|
|
|
|
<ListItemIcon className={classes.icon}>
|
|
|
|
|
<InfoIcon titleAccess={label} />
|
|
|
|
|
</ListItemIcon>
|
|
|
|
|
{label}
|
|
|
|
|
</MenuItem>
|
|
|
|
|
<AboutDialog onClose={handleClose} open={open} />
|
|
|
|
|
</>
|
2020-03-31 06:49:47 -08:00
|
|
|
)
|
|
|
|
|
})
|
2020-02-05 19:08:04 -09:00
|
|
|
|
|
|
|
|
const CustomUserMenu = (props) => (
|
|
|
|
|
<UserMenu {...props}>
|
2020-09-30 16:36:51 -08:00
|
|
|
<AboutMenuItem />
|
2020-02-05 19:08:04 -09:00
|
|
|
</UserMenu>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const AppBar = (props) => <RAAppBar {...props} userMenu={<CustomUserMenu />} />
|
|
|
|
|
|
|
|
|
|
export default AppBar
|