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

Merge branch 'issue_240-icatplus-speed_up_instruments' into 'milestone-logbook-search-settings'

ICATplus Issue 240 Resolve "Retrieval of instruments is very long"

See merge request !516
parents eeb30a7a 25ec5dd9
Pipeline #48170 passed with stage
in 5 minutes and 19 seconds
......@@ -37,6 +37,7 @@ import {
CLOSED_DATA_PATH,
MY_DATA_PATH,
OPEN_DATA_PATH,
BEAMLINE_PATH,
} from './constants/routePaths';
function App() {
......@@ -133,7 +134,11 @@ function App() {
<Route exact path="/public/:prefix/:suffix" component={DOIPage} />
<Route exact path={CLOSED_DATA_PATH} component={ClosedDataPage} />
<Route exact path="/beamline/:name" component={BeamlineDataPage} />
<Route
exact
path={`${BEAMLINE_PATH}:name`}
component={BeamlineDataPage}
/>
{isSampleTrackingEnabled && (
<Route exact path="/parcels" component={MyParcelsPage} />
......
......@@ -29,6 +29,7 @@ export function doSignIn(plugin, username, password) {
name,
fullName,
isAdministrator,
isInstrumentScientist,
lifeTimeMinutes,
} = data;
dispatch({
......@@ -37,6 +38,7 @@ export function doSignIn(plugin, username, password) {
name,
fullName,
isAdministrator,
isInstrumentScientist,
lifeTimeMinutes,
});
})
......@@ -65,6 +67,7 @@ export function doSilentRefreshFromSSO() {
name,
fullName,
isAdministrator,
isInstrumentScientist,
lifeTimeMinutes,
} = data;
dispatch({
......@@ -73,6 +76,7 @@ export function doSilentRefreshFromSSO() {
name,
fullName,
isAdministrator,
isInstrumentScientist,
lifeTimeMinutes,
});
})
......
......@@ -5,16 +5,16 @@ import styles from './Menu.module.css';
import { useSelector } from 'react-redux';
import { useResource } from 'rest-hooks';
import InstrumentResource from '../../resources/instrument';
import { BEAMLINE_PATH } from '../../constants/routePaths';
function BeamlinesMenu() {
const { isAdministrator } = useSelector((state) => state.user);
const instruments = useResource(
InstrumentResource.listShape(),
isAdministrator ? {} : { filter: 'instrumentscientist' }
const { isAdministrator, isInstrumentScientist } = useSelector(
(state) => state.user
);
if (instruments.length === 0) {
const instruments = useResource(InstrumentResource.listShape(), {});
if (!isAdministrator && !isInstrumentScientist) {
return null;
}
......@@ -39,7 +39,7 @@ function BeamlinesMenu() {
<MenuItem divider />
{sortedInstruments.map(({ id, name }) => (
<LinkContainer key={id} to={`/beamline/${name.toLowerCase()}`}>
<LinkContainer key={id} to={`${BEAMLINE_PATH}${name.toLowerCase()}`}>
<MenuItem key={id} eventKey={id}>
{name}
</MenuItem>
......
export const MY_DATA_PATH = '/investigations';
export const CLOSED_DATA_PATH = '/closed';
export const OPEN_DATA_PATH = '/public';
export const BEAMLINE_PATH = '/beamline/';
......@@ -5,6 +5,7 @@ import { setBreadCrumbs } from '../../actions/breadcrumbs';
import { useParams } from 'react-router';
import LoadingBoundary from '../../components/LoadingBoundary';
import BeamlineDataTable from './BeamlineDataTable';
import { BEAMLINE_PATH } from '../../constants/routePaths';
function BeamlineDataPage() {
const { name } = useParams();
......@@ -13,7 +14,11 @@ function BeamlineDataPage() {
const dispatch = useDispatch();
useEffect(() => {
dispatch(setBreadCrumbs([{ name: `${beamline} Data` }]));
dispatch(
setBreadCrumbs([
{ name: `${beamline} Data`, link: `${BEAMLINE_PATH}${beamline}` },
])
);
}, [beamline, dispatch]);
return (
......
......@@ -16,6 +16,7 @@ const initialState = {
name: null,
isAnonymous: false,
isAdministrator: false,
isInstrumentScientist: false,
isAuthenticating: false,
isSessionExpired: false,
error: null,
......@@ -47,6 +48,7 @@ const user = (state = initialState, action) => {
ICAT.authentication.anonymous.enabled &&
state.username === ICAT.authentication.anonymous.username,
isAdministrator: action.isAdministrator,
isInstrumentScientist: action.isInstrumentScientist,
};
break;
}
......
Supports Markdown
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