Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
boriskovar-m2ms and matej-vavrek authored Dec 11, 2024
1 parent 8eb7e93 commit 771d3b0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docker-compose.dev.vector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 11 additions & 8 deletions js/components/target/redux/dispatchActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
});
}
Expand All @@ -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));
Expand Down Expand Up @@ -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' } } });
Expand Down
9 changes: 5 additions & 4 deletions js/components/target/withUpdatingTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 771d3b0

Please sign in to comment.