Skip to content

Commit 771d3b0

Browse files
boriskovar-m2msmatej-vavrek
andauthoredDec 11, 2024··
#1604 (#467)
* removed SGC column from target list * #1540 added preferred alias functionality * #1540 added edit column to target list and use target settings modal * #1540 updated "Open" label and read only version of display name * Squashed commit of the following: commit c5bba58 Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Tue Dec 10 08:13:00 2024 +0100 #1603 - fixes * Squashed commit of the following: commit 9d9bf8c Author: Boris Kovar <boris.kovar@m2ms.sk> Date: Wed Dec 11 15:20:54 2024 +0100 fixed frontend part of the ticket. Now properly resolves target based on the target name and target access string --------- Co-authored-by: matej <matej.vavrek@m2ms.sk>
1 parent 8eb7e93 commit 771d3b0

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed
 

‎docker-compose.dev.vector.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ services:
104104
LEGACY_URL: 'https://fragalysis.diamond.ac.uk'
105105
DEPLOYMENT_MODE: 'development'
106106
DISABLE_RESTRICT_PROPOSALS_TO_MEMBERSHIP: 'True'
107-
PUBLIC_TAS: 'lb18145-1'
107+
PUBLIC_TAS: 'lb18145-1,lb32633-1'
108108
# INFECTIONS: 'structure-download'
109109
depends_on:
110110
database:

‎js/components/target/redux/dispatchActions.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export const loadProjectsList = () => async (dispatch, getState) => {
5858
return resp.data.results;
5959
};
6060

61-
export const updateTarget = ({ target, setIsLoading, targetIdList, projectId }) => (dispatch, getState) => {
61+
export const updateTarget = ({ targetName, projectName, setIsLoading, targetIdList, projectId }) => (
62+
dispatch,
63+
getState
64+
) => {
6265
const state = getState();
6366
const isActionRestoring = false; //state.trackingReducers.isActionRestoring;
6467
const currentSessionProject = state.projectReducers.currentProject;
@@ -68,11 +71,13 @@ export const updateTarget = ({ target, setIsLoading, targetIdList, projectId })
6871
// Get from the REST API
6972
let targetUnrecognisedFlag = true;
7073
// if (target !== undefined) {
71-
if (target) {
74+
let target = null;
75+
if (targetName) {
7276
if (targetIdList && targetIdList.length > 0) {
73-
targetIdList.forEach(targetId => {
74-
if (target === targetId.title) {
77+
targetIdList.forEach(t => {
78+
if (targetName === t.title && t.project.target_access_string === projectName) {
7579
targetUnrecognisedFlag = false;
80+
target = t;
7681
}
7782
});
7883
}
@@ -86,7 +91,7 @@ export const updateTarget = ({ target, setIsLoading, targetIdList, projectId })
8691
setIsLoading(true);
8792
let url = undefined;
8893
if (target) {
89-
url = `${base_url}/api/targets/?title=${target}`;
94+
url = `${base_url}/api/targets/?id=${target.id}`;
9095
return api({ url })
9196
.then(response => {
9297
return dispatch(setTargetOn(response.data['results'][0].id));
@@ -163,9 +168,7 @@ export const getTargetProjectCombinations = (targets, projects) => {
163168
updatedTarget.project = project;
164169
result.push({ updatedTarget });
165170
} else {
166-
console.log(
167-
`User don't have access to project ${projectId} which is associated with target ${target.title}`
168-
);
171+
console.log(`User don't have access to project ${projectId} which is associated with target ${target.title}`);
169172
}
170173
} else {
171174
result.push({ updatedTarget: { ...target, project: { target_access_string: 'Legacy' } } });

‎js/components/target/withUpdatingTarget.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect, useSelector } from 'react-redux';
33
import HandleUnrecognisedTarget from './handleUnrecognisedTarget';
44
import { updateTarget, setTargetUUIDs, resetTargetAndSelection } from './redux/dispatchActions';
55
import { useRouteMatch } from 'react-router-dom';
6-
import { extractTargetFromURLParam } from '../preview/utils';
6+
import { extractProjectFromURLParam, extractTargetFromURLParam } from '../preview/utils';
77
import { LoadingContext } from '../loading';
88

99
export const withUpdatingTarget = WrappedContainer => {
@@ -12,7 +12,8 @@ export const withUpdatingTarget = WrappedContainer => {
1212
let match = useRouteMatch();
1313

1414
// const target = match && match.params && match.params.target;
15-
let target = match && match.params && extractTargetFromURLParam(match.params[0]);
15+
let targetName = match && match.params && extractTargetFromURLParam(match.params[0]);
16+
const projectName = match && match.params && extractProjectFromURLParam(match.params[0]);
1617
const uuid = match && match.params && match.params.uuid;
1718
const snapshotUuid = match && match.params && match.params.snapshotUuid;
1819
const snapshotId = match && match.params && match.params.snapshotId;
@@ -30,12 +31,12 @@ export const withUpdatingTarget = WrappedContainer => {
3031
}, [setTargetUUIDs, snapshotUuid, uuid]);
3132

3233
useEffect(() => {
33-
updateTarget({ target, setIsLoading, targetIdList, projectId }).catch(error => {
34+
updateTarget({ targetName, projectName, setIsLoading, targetIdList, projectId }).catch(error => {
3435
setState(() => {
3536
throw error;
3637
});
3738
});
38-
}, [setIsLoading, target, updateTarget, targetIdList, projectId, snapshotId /*, isActionRestoring*/]);
39+
}, [setIsLoading, targetName, updateTarget, targetIdList, projectId, snapshotId, projectName]);
3940

4041
if (isLoading === true) {
4142
return null;

0 commit comments

Comments
 (0)
Please sign in to comment.