mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-01-30 10:39:12 +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 SettingsIcon from '@material-ui/icons/Settings';
|
||||||
import SettingsRemoteIcon from "@material-ui/icons/SettingsRemote";
|
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() {
|
render() {
|
||||||
|
const { authenticatedContext } = this.props;
|
||||||
const path = this.props.match.url;
|
const path = this.props.match.url;
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
@@ -17,15 +22,15 @@ class ProjectMenu extends Component<RouteComponentProps> {
|
|||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary="Dashboard" />
|
<ListItemText primary="Dashboard" />
|
||||||
</ListItem>
|
</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>
|
<ListItemIcon>
|
||||||
<SettingsIcon />
|
<SettingsIcon />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary="Settings" />
|
<ListItemText primary="Settings" />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withRouter(ProjectMenu);
|
export default withRouter(withAuthenticatedContext(ProjectMenu));
|
||||||
|
|||||||
Reference in New Issue
Block a user