grey out Settings menu when not an admin

This commit is contained in:
proddy
2020-08-14 12:30:19 +02:00
parent 734e46182c
commit 207c86c9df

View File

@@ -6,8 +6,13 @@ import { List, ListItem, ListItemIcon, ListItemText } from "@material-ui/core";
import SettingsIcon from '@material-ui/icons/Settings';
import SettingsRemoteIcon from "@material-ui/icons/SettingsRemote";
class ProjectMenu extends Component<RouteComponentProps> {
import { withAuthenticatedContext, AuthenticatedContextProps } from '../authentication';
type ProjectProps = AuthenticatedContextProps & RouteComponentProps;
class ProjectMenu extends Component<ProjectProps> {
render() {
const { authenticatedContext } = this.props;
const path = this.props.match.url;
return (
<List>
@@ -17,15 +22,15 @@ class ProjectMenu extends Component<RouteComponentProps> {
</ListItemIcon>
<ListItemText primary="Dashboard" />
</ListItem>
<ListItem to='/ems-esp/settings/' selected={path.startsWith('/ems-esp/settings/')} button component={Link}>
<ListItem to='/ems-esp/settings/' selected={path.startsWith('/ems-esp/settings/')} button component={Link} disabled={!authenticatedContext.me.admin}>
<ListItemIcon>
<SettingsIcon />
</ListItemIcon>
<ListItemText primary="Settings" />
<ListItemText primary="Settings" />
</ListItem>
</List>
);
}
}
export default withRouter(ProjectMenu);
export default withRouter(withAuthenticatedContext(ProjectMenu));