Commit 39400fdc authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch '494-bug-manager_menu' into 'master'

Resolve: "User can see manager menu"

Closes #494

See merge request !506
parents d04a0589 6802d35a
Pipeline #46297 passed with stages
in 13 minutes and 39 seconds
import React from 'react';
import { MenuItem, NavDropdown } from 'react-bootstrap';
import { Glyphicon, MenuItem, NavDropdown } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
import styles from './Menu.module.css';
import { useSelector } from 'react-redux';
import { useResource } from 'rest-hooks';
import InstrumentResource from '../../resources/instrument';
function ManagerMenu() {
function BeamlinesMenu() {
const { isAdministrator } = useSelector((state) => state.user);
const instruments = useResource(
......@@ -29,6 +29,15 @@ function ManagerMenu() {
id="basic-nav-dropdown"
className={styles.managerMenu}
>
<LinkContainer to="/usermanagement">
<MenuItem eventKey="usermanagement">
<Glyphicon glyph="user" />
<span style={{ marginLeft: 10 }}>Beamline Permissions</span>
</MenuItem>
</LinkContainer>
<MenuItem divider />
{sortedInstruments.map(({ id, name }) => (
<LinkContainer key={id} to={`/beamline/${name.toLowerCase()}`}>
<MenuItem key={id} eventKey={id}>
......@@ -40,4 +49,4 @@ function ManagerMenu() {
);
}
export default ManagerMenu;
export default BeamlinesMenu;
......@@ -6,6 +6,7 @@ import { useSelector } from 'react-redux';
function ManagerMenu() {
const { isAdministrator } = useSelector((state) => state.user);
if (!isAdministrator) return null;
return (
<NavDropdown
eventKey="manager"
......@@ -13,13 +14,6 @@ function ManagerMenu() {
id="basic-nav-dropdown"
className={styles.managerMenu}
>
<LinkContainer to="/usermanagement">
<MenuItem eventKey="usermanagement">
<Glyphicon glyph="user" />
<span style={{ marginLeft: 10 }}>Beamline Permissions</span>
</MenuItem>
</LinkContainer>
<LinkContainer to="/calendar">
<MenuItem eventKey="calendar">
<Glyphicon glyph="calendar" />
......@@ -29,23 +23,19 @@ function ManagerMenu() {
<MenuItem divider />
{isAdministrator && (
<LinkContainer to="/manager/stats/data">
<MenuItem eventKey="stats">
<Glyphicon glyph="stats" />
<span style={{ marginLeft: 10 }}>Data Statistics</span>
</MenuItem>
</LinkContainer>
)}
<LinkContainer to="/manager/stats/data">
<MenuItem eventKey="stats">
<Glyphicon glyph="stats" />
<span style={{ marginLeft: 10 }}>Data Statistics</span>
</MenuItem>
</LinkContainer>
{isAdministrator && (
<LinkContainer to="/manager/stats/sampletracking">
<MenuItem eventKey="envelope">
<Glyphicon glyph="envelope" />
<span style={{ marginLeft: 10 }}>Sample Tracking Statistics</span>
</MenuItem>
</LinkContainer>
)}
<LinkContainer to="/manager/stats/sampletracking">
<MenuItem eventKey="envelope">
<Glyphicon glyph="envelope" />
<span style={{ marginLeft: 10 }}>Sample Tracking Statistics</span>
</MenuItem>
</LinkContainer>
</NavDropdown>
);
}
......
......@@ -126,7 +126,7 @@ function Menu() {
</NavItem>
}
>
<ManagerMenu />
<BeamlinesMenu />
</LoadingBoundary>
<LoadingBoundary
......@@ -137,7 +137,7 @@ function Menu() {
</NavItem>
}
>
<BeamlinesMenu />
<ManagerMenu />
</LoadingBoundary>
</Nav>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment