diff --git a/docker-compose.dev.vector.yml b/docker-compose.dev.vector.yml index f776976b7..2c20f68d2 100644 --- a/docker-compose.dev.vector.yml +++ b/docker-compose.dev.vector.yml @@ -104,7 +104,7 @@ services: LEGACY_URL: 'https://fragalysis.diamond.ac.uk' DEPLOYMENT_MODE: 'development' DISABLE_RESTRICT_PROPOSALS_TO_MEMBERSHIP: 'True' - PUBLIC_TAS: 'lb18145-1' + PUBLIC_TAS: 'lb18145-1,lb32633-1' # INFECTIONS: 'structure-download' depends_on: database: diff --git a/js/components/target/redux/dispatchActions.js b/js/components/target/redux/dispatchActions.js index ae3fc101f..33c814845 100644 --- a/js/components/target/redux/dispatchActions.js +++ b/js/components/target/redux/dispatchActions.js @@ -58,7 +58,10 @@ export const loadProjectsList = () => async (dispatch, getState) => { return resp.data.results; }; -export const updateTarget = ({ target, setIsLoading, targetIdList, projectId }) => (dispatch, getState) => { +export const updateTarget = ({ targetName, projectName, setIsLoading, targetIdList, projectId }) => ( + dispatch, + getState +) => { const state = getState(); const isActionRestoring = false; //state.trackingReducers.isActionRestoring; const currentSessionProject = state.projectReducers.currentProject; @@ -68,11 +71,13 @@ export const updateTarget = ({ target, setIsLoading, targetIdList, projectId }) // Get from the REST API let targetUnrecognisedFlag = true; // if (target !== undefined) { - if (target) { + let target = null; + if (targetName) { if (targetIdList && targetIdList.length > 0) { - targetIdList.forEach(targetId => { - if (target === targetId.title) { + targetIdList.forEach(t => { + if (targetName === t.title && t.project.target_access_string === projectName) { targetUnrecognisedFlag = false; + target = t; } }); } @@ -86,7 +91,7 @@ export const updateTarget = ({ target, setIsLoading, targetIdList, projectId }) setIsLoading(true); let url = undefined; if (target) { - url = `${base_url}/api/targets/?title=${target}`; + url = `${base_url}/api/targets/?id=${target.id}`; return api({ url }) .then(response => { return dispatch(setTargetOn(response.data['results'][0].id)); @@ -163,9 +168,7 @@ export const getTargetProjectCombinations = (targets, projects) => { updatedTarget.project = project; result.push({ updatedTarget }); } else { - console.log( - `User don't have access to project ${projectId} which is associated with target ${target.title}` - ); + console.log(`User don't have access to project ${projectId} which is associated with target ${target.title}`); } } else { result.push({ updatedTarget: { ...target, project: { target_access_string: 'Legacy' } } }); diff --git a/js/components/target/withUpdatingTarget.js b/js/components/target/withUpdatingTarget.js index 68fa34ad1..a9b66b743 100644 --- a/js/components/target/withUpdatingTarget.js +++ b/js/components/target/withUpdatingTarget.js @@ -3,7 +3,7 @@ import { connect, useSelector } from 'react-redux'; import HandleUnrecognisedTarget from './handleUnrecognisedTarget'; import { updateTarget, setTargetUUIDs, resetTargetAndSelection } from './redux/dispatchActions'; import { useRouteMatch } from 'react-router-dom'; -import { extractTargetFromURLParam } from '../preview/utils'; +import { extractProjectFromURLParam, extractTargetFromURLParam } from '../preview/utils'; import { LoadingContext } from '../loading'; export const withUpdatingTarget = WrappedContainer => { @@ -12,7 +12,8 @@ export const withUpdatingTarget = WrappedContainer => { let match = useRouteMatch(); // const target = match && match.params && match.params.target; - let target = match && match.params && extractTargetFromURLParam(match.params[0]); + let targetName = match && match.params && extractTargetFromURLParam(match.params[0]); + const projectName = match && match.params && extractProjectFromURLParam(match.params[0]); const uuid = match && match.params && match.params.uuid; const snapshotUuid = match && match.params && match.params.snapshotUuid; const snapshotId = match && match.params && match.params.snapshotId; @@ -30,12 +31,12 @@ export const withUpdatingTarget = WrappedContainer => { }, [setTargetUUIDs, snapshotUuid, uuid]); useEffect(() => { - updateTarget({ target, setIsLoading, targetIdList, projectId }).catch(error => { + updateTarget({ targetName, projectName, setIsLoading, targetIdList, projectId }).catch(error => { setState(() => { throw error; }); }); - }, [setIsLoading, target, updateTarget, targetIdList, projectId, snapshotId /*, isActionRestoring*/]); + }, [setIsLoading, targetName, updateTarget, targetIdList, projectId, snapshotId, projectName]); if (isLoading === true) { return null;