mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
grey out Settings menu when not an admin
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user