diff --git a/docker-compose.dev.vector.yml b/docker-compose.dev.vector.yml
index 9e7f7c8c2..f776976b7 100644
--- a/docker-compose.dev.vector.yml
+++ b/docker-compose.dev.vector.yml
@@ -91,14 +91,11 @@ services:
OIDC_RP_CLIENT_SECRET: ${OIDC_RP_CLIENT_SECRET}
OIDC_RP_CLIENT_ID: 'fragalysis-local'
OIDC_RENEW_ID_TOKEN_EXPIRY_MINUTES: 210
- ISPYB_HOST: ispybdbproxy.diamond.ac.uk
+ # ISPYB_HOST: ispybdbproxy.diamond.ac.uk
ISPYB_PORT: 4306
ISPYB_USER: ${ISPYB_USER}
ISPYB_PASSWORD: ${ISPYB_PASSWORD}
SECURITY_CONNECTOR: ssh_ispyb
- SSH_HOST: ssh.diamond.ac.uk
- SSH_USER: ${SSH_USER}
- SSH_PASSWORD: ${SSH_PASSWORD}
LOGGING_FRAMEWORK_ROOT_LEVEL: DEBUG
AUTHENTICATE_UPLOAD: 'False'
CELERY_TASK_ALWAYS_EAGER: 'True'
diff --git a/js/components/datasets/customDatasetList.js b/js/components/datasets/customDatasetList.js
index 3ddb6076f..8034d4ac5 100644
--- a/js/components/datasets/customDatasetList.js
+++ b/js/components/datasets/customDatasetList.js
@@ -18,9 +18,9 @@ export const CustomDatasetList = memo(({ dataset, hideProjects, isActive }) => {
dispatch(clearDatasetSettings(dataset.id));
}
}
- return () => {
- dispatch(clearDatasetSettings(dataset?.id));
- };
+ // return () => {
+ // dispatch(clearDatasetSettings(dataset?.id));
+ // };
}, [dataset, dispatch, isActive, isLoadingMoleculeList]);
const title = dataset && `${dataset.title} v.${dataset.version}`;
diff --git a/js/components/datasets/datasetMoleculeList.js b/js/components/datasets/datasetMoleculeList.js
index 6a73f21ff..0b303ef13 100644
--- a/js/components/datasets/datasetMoleculeList.js
+++ b/js/components/datasets/datasetMoleculeList.js
@@ -397,8 +397,6 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const searchString = useSelector(state => state.datasetsReducers.searchString);
- const currentActionList = useSelector(state => state.trackingReducers.current_actions_list);
-
const isActiveFilter = !!(filterSettings || {}).active;
const { getNglView } = useContext(NglContext);
@@ -494,12 +492,12 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
const isSelectedTypeOn = (typeList, isLHSReference) => {
if (typeList) {
if (!isLHSReference) {
- return typeList.some(molId => allMolecules.some(mol => mol.id === molId));
+ return typeList.some(molId => allMolecules?.some(mol => mol.id === molId));
} else {
- const molsWithLHSReference = allMolecules.filter(mol => mol.site_observation_code);
+ const molsWithLHSReference = allMolecules?.filter(mol => mol.site_observation_code);
return typeList.some(molId =>
molsWithLHSReference.some(
- mol => mol.site_observation_code === allMoleculesList.find(m => m.id === molId)?.code
+ mol => mol.site_observation_code === allMoleculesList?.find(m => m.id === molId)?.code
)
);
}
@@ -563,7 +561,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
);
} else {
if (molecule.site_observation_code) {
- const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
+ const lhsMol = allMoleculesList?.find(mol => mol.code === molecule.site_observation_code);
if (lhsMol) {
dispatch(removeLHSType[type](stage, lhsMol, colourList[molecule.id % colourList.length], skipTracking));
}
@@ -597,7 +595,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
);
} else {
if (molecule.site_observation_code) {
- const lhsMol = allMoleculesList.find(mol => mol.code === molecule.site_observation_code);
+ const lhsMol = allMoleculesList?.find(mol => mol.code === molecule.site_observation_code);
if (lhsMol) {
if (type === 'protein') {
promises.push(
@@ -1479,7 +1477,7 @@ const DatasetMoleculeList = ({ title, datasetID, url }) => {
// #1249 dataset molecules currently could use side observation molecule for some renders
let idToFind = data.id;
if (data.site_observation_code) {
- const molecule = allMoleculesList.find(mol => mol.code === data.site_observation_code);
+ const molecule = allMoleculesList?.find(mol => mol.code === data.site_observation_code);
if (molecule) {
idToFind = molecule.id;
}
diff --git a/js/components/datasets/inspirationDialog.js b/js/components/datasets/inspirationDialog.js
index 23aa4c7c4..0be5b19f2 100644
--- a/js/components/datasets/inspirationDialog.js
+++ b/js/components/datasets/inspirationDialog.js
@@ -156,7 +156,7 @@ export const InspirationDialog = memo(
let rationale = '';
if (datasetID && inspirationLists.hasOwnProperty(datasetID) && inspirationLists[datasetID][0]) {
const moleculeID = inspirationLists[datasetID][0];
- const molecule = moleculeLists[datasetID].find(molecule => molecule.id === moleculeID);
+ const molecule = moleculeLists[datasetID]?.find(molecule => molecule.id === moleculeID);
if (molecule !== undefined) {
rationale = molecule.text_scores.hasOwnProperty('rationale') ? molecule.text_scores.rationale : '';
}
@@ -194,7 +194,7 @@ export const InspirationDialog = memo(
}, [inspirationMoleculeDataList, searchString]);
const allSelectedMolecules = inspirationMoleculeDataList.filter(
- molecule => moleculesToEditIds.includes(molecule.id) /* || molForTagEditId.some(mid => molecule.id === mid)*/
+ molecule => moleculesToEditIds.includes(molecule?.id) /* || molForTagEditId.some(mid => molecule.id === mid)*/
);
// TODO: refactor from this line (duplicity in datasetMoleculeList.js)
@@ -451,6 +451,7 @@ export const InspirationDialog = memo(
{moleculeList.length > 0 &&
moleculeList.map((molecule, index, array) => {
+ if (!molecule) return <> >;
let data = molecule;
data.isInspiration = true;
let previousData = index > 0 && Object.assign({ isInspiration: true }, array[index - 1]);
diff --git a/js/components/datasets/redux/actions.js b/js/components/datasets/redux/actions.js
index 3ec64c23c..fea6b7ff3 100644
--- a/js/components/datasets/redux/actions.js
+++ b/js/components/datasets/redux/actions.js
@@ -623,3 +623,42 @@ export const setUpdatedDatasets = updatedDataset => ({
type: constants.SET_UPDATED_DATASETS,
payload: { updatedDataset }
});
+
+export const setToBeDisplayedListForDataset = (datasetID, toBeDisplayedList) => {
+ return {
+ type: constants.SET_TO_BE_DISPLAYED_LIST_DATASET,
+ toBeDisplayedList: toBeDisplayedList,
+ datasetID: datasetID
+ };
+};
+
+export const appendToBeDisplayedListForDataset = (datasetID, item) => {
+ return {
+ type: constants.APPEND_TO_BE_DISPLAYED_LIST_DATASET,
+ item: item,
+ datasetID: datasetID
+ };
+};
+
+export const removeFromToBeDisplayedListForDataset = (datasetID, item) => {
+ return {
+ type: constants.REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET,
+ item: item,
+ datasetID: datasetID
+ };
+};
+
+export const updateInToBeDisplayedListForDataset = (datasetID, item) => {
+ return {
+ type: constants.UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET,
+ item: item,
+ datasetID: datasetID
+ };
+};
+
+export const setToBeDisplayedLists = toBeDisplayedLists => {
+ return {
+ type: constants.SET_TO_BE_DISPLAYED_LISTS,
+ toBeDisplayedLists: toBeDisplayedLists
+ };
+};
diff --git a/js/components/datasets/redux/constants.js b/js/components/datasets/redux/constants.js
index 3e96418fe..8a740d779 100644
--- a/js/components/datasets/redux/constants.js
+++ b/js/components/datasets/redux/constants.js
@@ -122,7 +122,13 @@ export const constants = {
SET_SELECTED_COMPOUNDS_ITERATOR: prefix + 'SET_SELECTED_COMPOUNDS_ITERATOR',
SET_INSPIRATION_DIALOG_ACTION: prefix + 'SET_INSPIRATION_DIALOG_ACTION',
- SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND: prefix + 'SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND'
+ SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND: prefix + 'SET_INSPIRATION_DIALOG_OPENED_FOR_SELECTED_COMPOUND',
+
+ SET_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'SET_TO_BE_DISPLAYED_LIST_DATASET',
+ APPEND_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'APPEND_TO_BE_DISPLAYED_LIST_DATASET',
+ REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET',
+ UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET: prefix + 'UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET',
+ SET_TO_BE_DISPLAYED_LISTS: prefix + 'SET_TO_BE_DISPLAYED_LISTS'
};
export const COUNT_OF_VISIBLE_SCORES = 7;
diff --git a/js/components/datasets/redux/dispatchActions.js b/js/components/datasets/redux/dispatchActions.js
index dc556b549..0f3a0dcc5 100644
--- a/js/components/datasets/redux/dispatchActions.js
+++ b/js/components/datasets/redux/dispatchActions.js
@@ -37,7 +37,9 @@ import {
removeDataset,
appendCompoundToSelectedCompoundsByDataset,
setDatasetIterator,
- setSelectedCompoundsIterator
+ setSelectedCompoundsIterator,
+ appendToBeDisplayedListForDataset,
+ updateInToBeDisplayedListForDataset
} from './actions';
import { base_url } from '../../routes/constants';
import {
@@ -75,11 +77,10 @@ import {
} from '../../preview/molecule/redux/dispatchActions';
import { OBJECT_TYPE } from '../../nglView/constants';
import { getRepresentationsByType } from '../../nglView/generatingObjects';
-import { selectAllMoleculeList } from '../../preview/molecule/redux/selectors';
-import { getCompoundById } from '../../../reducers/tracking/dispatchActionsSwitchSnapshot';
import { getRandomColor } from '../../preview/molecule/utils/color';
-import { BreakfastDiningOutlined } from '@mui/icons-material';
import { isCompoundFromVectorSelector } from '../../preview/compounds/redux/dispatchActions';
+import { getCompoundById } from '../../../utils/genericDispatchActions';
+import { NGL_OBJECTS } from '../../../reducers/ngl/constants';
export const initializeDatasetFilter = datasetID => (dispatch, getState) => {
const state = getState();
@@ -106,34 +107,26 @@ export const addDatasetHitProtein = (
skipTracking = false,
representations = undefined
) => async dispatch => {
- dispatch(appendProteinList(datasetID, generateMoleculeCompoundId(data), skipTracking));
- return dispatch(
- loadObject({
- target: Object.assign(
- { display_div: VIEWS.MAJOR_VIEW },
- generateHitProteinObject(data, colourToggle, base_url, datasetID)
- ),
- stage,
- previousRepresentations: representations,
- orientationMatrix: null
+ dispatch(
+ appendToBeDisplayedListForDataset(datasetID, {
+ type: NGL_OBJECTS.PROTEIN,
+ id: data.id,
+ display: true,
+ representations: representations,
+ datasetID: datasetID
})
- ).finally(() => {
- const currentOrientation = stage.viewerControls.getOrientation();
- dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
- });
+ );
};
export const removeDatasetHitProtein = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
- deleteObject(
- Object.assign(
- { display_div: VIEWS.MAJOR_VIEW },
- generateHitProteinObject(data, colourToggle, base_url, datasetID)
- ),
- stage
- )
+ updateInToBeDisplayedListForDataset(datasetID, {
+ id: data.id,
+ display: false,
+ type: NGL_OBJECTS.PROTEIN,
+ datasetID: datasetID
+ })
);
- dispatch(removeFromProteinList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};
export const addDatasetComplex = (
@@ -144,31 +137,26 @@ export const addDatasetComplex = (
skipTracking = false,
representations = undefined
) => async dispatch => {
- dispatch(appendComplexList(datasetID, generateMoleculeCompoundId(data), skipTracking));
- return dispatch(
- loadObject({
- target: Object.assign(
- { display_div: VIEWS.MAJOR_VIEW },
- generateComplexObject(data, colourToggle, base_url, datasetID)
- ),
- stage,
- previousRepresentations: representations,
- orientationMatrix: null
+ dispatch(
+ appendToBeDisplayedListForDataset(datasetID, {
+ type: NGL_OBJECTS.COMPLEX,
+ id: data.id,
+ display: true,
+ representations: representations,
+ datasetID: datasetID
})
- ).finally(() => {
- const currentOrientation = stage.viewerControls.getOrientation();
- dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
- });
+ );
};
export const removeDatasetComplex = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
- deleteObject(
- Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateComplexObject(data, colourToggle, base_url, datasetID)),
- stage
- )
+ updateInToBeDisplayedListForDataset(datasetID, {
+ id: data.id,
+ display: false,
+ type: NGL_OBJECTS.COMPLEX,
+ datasetID: datasetID
+ })
);
- dispatch(removeFromComplexList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};
export const addDatasetSurface = (
@@ -178,31 +166,26 @@ export const addDatasetSurface = (
datasetID,
representations = undefined
) => async dispatch => {
- dispatch(appendSurfaceList(datasetID, generateMoleculeCompoundId(data)));
- return dispatch(
- loadObject({
- target: Object.assign(
- { display_div: VIEWS.MAJOR_VIEW },
- generateSurfaceObject(data, colourToggle, base_url, datasetID)
- ),
- stage,
- previousRepresentations: representations,
- orientationMatrix: null
+ dispatch(
+ appendToBeDisplayedListForDataset(datasetID, {
+ type: NGL_OBJECTS.SURFACE,
+ id: data.id,
+ display: true,
+ representations: representations,
+ datasetID: datasetID
})
- ).finally(() => {
- const currentOrientation = stage.viewerControls.getOrientation();
- dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation));
- });
+ );
};
export const removeDatasetSurface = (stage, data, colourToggle, datasetID) => dispatch => {
dispatch(
- deleteObject(
- Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url, datasetID)),
- stage
- )
+ updateInToBeDisplayedListForDataset(datasetID, {
+ id: data.id,
+ display: false,
+ type: NGL_OBJECTS.SURFACE,
+ datasetID: datasetID
+ })
);
- dispatch(removeFromSurfaceList(datasetID, generateMoleculeCompoundId(data)));
};
export const addDatasetLigand = (
@@ -213,43 +196,26 @@ export const addDatasetLigand = (
skipTracking = false,
representations = undefined
) => async (dispatch, getState) => {
- dispatch(appendLigandList(datasetID, generateMoleculeCompoundId(data), skipTracking));
- console.count(`Grabbed orientation before loading dataset ligand`);
- const currentOrientation = stage.viewerControls.getOrientation();
- return dispatch(
- loadObject({
- target: Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data, colourToggle, datasetID)),
- stage,
- previousRepresentations: representations,
- markAsRightSideLigand: true
+ dispatch(
+ appendToBeDisplayedListForDataset(datasetID, {
+ type: NGL_OBJECTS.LIGAND,
+ id: data.id,
+ display: true,
+ representations: representations,
+ datasetID: datasetID
})
- ).finally(() => {
- const state = getState();
- const skipOrientation = state.trackingReducers.skipOrientationChange;
- if (!skipOrientation) {
- const ligandOrientation = stage.viewerControls.getOrientation();
- dispatch(setOrientation(VIEWS.MAJOR_VIEW, ligandOrientation));
-
- dispatch(appendMoleculeOrientation(getDatasetMoleculeID(datasetID, data?.id), ligandOrientation));
-
- // keep current orientation of NGL View
- if (!skipOrientation) {
- console.count(`Before applying orientation after loading dataset ligand.`);
- stage.viewerControls.orient(currentOrientation);
- console.count(`After applying orientation after loading dataset ligand.`);
- }
- }
- });
+ );
};
export const removeDatasetLigand = (stage, data, colourToggle, datasetID, skipTracking = false) => dispatch => {
dispatch(
- deleteObject(
- Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateMoleculeObject(data, undefined, datasetID)),
- stage
- )
+ updateInToBeDisplayedListForDataset(datasetID, {
+ id: data.id,
+ display: false,
+ type: NGL_OBJECTS.LIGAND,
+ datasetID: datasetID
+ })
);
- dispatch(removeFromLigandList(datasetID, generateMoleculeCompoundId(data), skipTracking));
};
export const loadDataSets = targetId => async dispatch => {
@@ -553,7 +519,7 @@ export const autoHideDatasetDialogsOnScroll = ({ inspirationDialogRef, crossRefe
const state = getState();
const isOpenInspirationDialog = state.datasetsReducers.isOpenInspirationDialog;
const isOpenCrossReferenceDialog = state.datasetsReducers.isOpenCrossReferenceDialog;
- const isActionRestoring = state.trackingReducers.isActionRestoring;
+ const isActionRestoring = false; //state.trackingReducers.isActionRestoring;
const currentBoundingClientRectInspiration =
(inspirationDialogRef.current && inspirationDialogRef.current.getBoundingClientRect()) || null;
diff --git a/js/components/datasets/redux/reducer.js b/js/components/datasets/redux/reducer.js
index 43595c0ee..4a493e499 100644
--- a/js/components/datasets/redux/reducer.js
+++ b/js/components/datasets/redux/reducer.js
@@ -87,7 +87,20 @@ export const INITIAL_STATE = {
inspirationsDialogOpenedForSelectedCompound: false,
- isSelectedDatasetScrolled: false
+ isSelectedDatasetScrolled: false,
+ //Map of datasetID and its objects which shape is bellow
+ // Shape of the object in toBeDisplayedList:
+ // {
+ // type: 'L|P|C|S|V|RIBBON|etc...',
+ // id: 1,
+
+ // center: true,
+ // withQuality: true,
+ // representations: [] etc...
+
+ // display: true
+ // }
+ toBeDisplayedList: {}
};
/**
@@ -119,7 +132,9 @@ const setList = (state, listsName, datasetId, list) => {
const appendToList = (state, listsName, datasetId, itemId) => {
const newState = Object.assign({}, state);
- newState[listsName][datasetId] = [...new Set([...newState[listsName][datasetId], itemId])];
+ newState[listsName][datasetId]
+ ? (newState[listsName][datasetId] = [...new Set([...newState[listsName][datasetId], itemId])])
+ : (newState[listsName][datasetId] = [itemId]);
return newState;
};
@@ -191,6 +206,47 @@ const removeDatasetFromState = (state, datasetId) => {
export const datasetsReducers = (state = INITIAL_STATE, action = {}) => {
switch (action.type) {
+ case constants.SET_TO_BE_DISPLAYED_LISTS:
+ return { ...state, toBeDisplayedList: action.toBeDisplayedLists };
+ case constants.SET_TO_BE_DISPLAYED_LIST_DATASET: {
+ return setList(state, 'toBeDisplayedList', action.datasetID, action.list);
+ }
+ case constants.APPEND_TO_BE_DISPLAYED_LIST_DATASET: {
+ return {
+ ...state,
+ toBeDisplayedList: {
+ ...state.toBeDisplayedList,
+ [action.datasetID]: [...(state.toBeDisplayedList[action.datasetID] || []), action.item]
+ }
+ };
+ }
+ case constants.REMOVE_FROM_TO_BE_DISPLAYED_LIST_DATASET: {
+ return {
+ ...state,
+ toBeDisplayedList: {
+ ...state.toBeDisplayedList,
+ [action.datasetID]: state.toBeDisplayedList[action.datasetID].filter(
+ i => i.id !== action.item.id || i.type !== action.item.type
+ )
+ }
+ };
+ }
+ case constants.UPDATE_IN_TO_BE_DISPLAYED_LIST_DATASET: {
+ return {
+ ...state,
+ toBeDisplayedList: {
+ ...state.toBeDisplayedList,
+ [action.datasetID]: state.toBeDisplayedList[action.datasetID].map(item => {
+ if (item.id === action.item.id && item.type === action.item.type) {
+ return { ...item, ...action.item };
+ } else {
+ return item;
+ }
+ })
+ }
+ };
+ }
+
case constants.ADD_DATASET:
const increasedDatasets = state.datasets.slice();
increasedDatasets.push(action.payload);
diff --git a/js/components/datasets/redux/selectors.js b/js/components/datasets/redux/selectors.js
index 323839bf0..6453db684 100644
--- a/js/components/datasets/redux/selectors.js
+++ b/js/components/datasets/redux/selectors.js
@@ -461,17 +461,6 @@ export const getJoinedMoleculeLists = (datasetID, state) => {
}
}
- // const restoredSearchString = state.trackingReducers.current_actions_list.find(
- // action => action.type === 'SEARCH_STRING'
- // );
- // if (restoredSearchString !== null && restoredSearchString !== undefined) {
- // const searchedString = restoredSearchString.searchString;
- // if (searchedString !== undefined) {
- // moleculeList = moleculeList.filter(molecule =>
- // molecule.name.toLowerCase().includes(searchedString.toLowerCase())
- // );
- // }
- // }
if (searchString !== null && searchString !== undefined) {
moleculeList = moleculeList.filter(molecule => molecule.name.toLowerCase().includes(searchString.toLowerCase()));
}
diff --git a/js/components/datasets/useScrollToCompound.js b/js/components/datasets/useScrollToCompound.js
index 2ff67582d..4ad2de85d 100644
--- a/js/components/datasets/useScrollToCompound.js
+++ b/js/components/datasets/useScrollToCompound.js
@@ -41,6 +41,8 @@ export const useScrollToCompound = () => {
const rhsOpen = useSelector(state => state.previewReducers.viewerControls.sidesOpen.RHS);
const isSelectedCompoundsTab = tabValue === 1;
+ const rhsDataIsLoaded = useSelector(state => state.apiReducers.rhsDataIsLoaded);
+
const dialogOpenedForInspirationWithId =
isSelectedCompoundsTab && Object.keys(inspirationLists)?.length > 0
? inspirationLists[Object.keys(inspirationLists)]?.length > 0
@@ -112,7 +114,9 @@ export const useScrollToCompound = () => {
}
}
console.log(`${uuid} useScrollToCompound useEffect - end - setting selected dataset scrolled`);
- dispatch(setSelectedDatasetScrolled(true));
+ if (rhsDataIsLoaded) {
+ dispatch(setSelectedDatasetScrolled(true));
+ }
}
}
console.log(`${uuid} useScrollToCompound useEffect - end`);
@@ -132,7 +136,8 @@ export const useScrollToCompound = () => {
rhsOpen,
surfaceList,
surfaceListDataset,
- uuid
+ uuid,
+ rhsDataIsLoaded
]);
useEffect(() => {
diff --git a/js/components/datasets/useScrollToSelected.js b/js/components/datasets/useScrollToSelected.js
index 6857411e6..55343e6cf 100644
--- a/js/components/datasets/useScrollToSelected.js
+++ b/js/components/datasets/useScrollToSelected.js
@@ -41,6 +41,8 @@ export const useScrollToSelected = (datasetID, moleculesPerPage, setCurrentPage)
const tabValue = useSelector(state => state.datasetsReducers.tabValue);
const isComputedDatasetsTab = tabValue > 1;
+ const rhsDataIsLoaded = useSelector(state => state.apiReducers.rhsDataIsLoaded);
+
// First pass, iterates over all the molecules and checks if any of them is selected. If it is,
// it saves the ID of the molecule and determines how many pages of molecules should be displayed.
// This is done only once and only if right hand side is open.
@@ -89,7 +91,9 @@ export const useScrollToSelected = (datasetID, moleculesPerPage, setCurrentPage)
}
}
- dispatch(setDatasetScrolled(datasetID));
+ if (rhsDataIsLoaded) {
+ dispatch(setDatasetScrolled(datasetID));
+ }
}
}, [
compoundsToBuyList,
@@ -110,7 +114,8 @@ export const useScrollToSelected = (datasetID, moleculesPerPage, setCurrentPage)
proteinList,
complexList,
surfaceList,
- isComputedDatasetsTab
+ isComputedDatasetsTab,
+ rhsDataIsLoaded
]);
// Second pass, once the list of molecules is displayed and the refs to their DOM nodes have been
diff --git a/js/components/header/index.js b/js/components/header/index.js
index 11ba81ab1..c7a3b316a 100644
--- a/js/components/header/index.js
+++ b/js/components/header/index.js
@@ -2,7 +2,7 @@
* Created by abradley on 14/03/2018.
*/
-import React, { memo, useContext, forwardRef, useState, useEffect } from 'react';
+import React, { memo, useContext, forwardRef, useState, useEffect, useCallback } from 'react';
import {
Grid,
makeStyles,
@@ -40,7 +40,7 @@ import {
} from '@material-ui/icons';
import { HeaderContext } from './headerContext';
import { Button } from '../common';
-import { URLS } from '../routes/constants';
+import { base_url, URLS } from '../routes/constants';
import { useCombinedRefs } from '../../utils/refHelpers';
import { ComputeSize } from '../../utils/computeSize';
import { DJANGO_CONTEXT } from '../../utils/djangoContext';
@@ -48,7 +48,6 @@ import { DJANGO_CONTEXT } from '../../utils/djangoContext';
import { useHistory } from 'react-router-dom';
import { IssueReport } from '../userFeedback/issueReport';
import { FundersModal } from '../funders/fundersModal';
-import { TrackingModal } from '../tracking/trackingModal';
// eslint-disable-next-line import/extensions
import { version } from '../../../package.json';
import { isDiscourseAvailable, openDiscourseLink } from '../../utils/discourse';
@@ -58,17 +57,28 @@ import { DiscourseErrorModal } from './discourseErrorModal';
import { setOpenDiscourseErrorModal } from '../../reducers/api/actions';
import { lockLayout, resetCurrentLayout } from '../../reducers/layout/actions';
import { ChangeLayoutButton } from './changeLayoutButton';
-import { setIsActionsRestoring, setProjectActionListLoaded } from '../../reducers/tracking/actions';
import { layouts } from '../../reducers/layout/layouts';
-import { setOpenSnapshotSavingDialog } from '../snapshot/redux/actions';
-import { activateSnapshotDialog } from '../snapshot/redux/dispatchActions';
-import { setAddButton, setProjectModalIsLoading } from '../projects/redux/actions';
+import {
+ setDisableRedirect,
+ setDontShowShareSnapshot,
+ setOpenSnapshotSavingDialog,
+ setSnapshotEditDialogOpen,
+ setSnapshotToBeEdited
+} from '../snapshot/redux/actions';
+import { activateSnapshotDialog, createNewSnapshot } from '../snapshot/redux/dispatchActions';
+import { setAddButton, setCurrentSnapshot, setProjectModalIsLoading } from '../projects/redux/actions';
import { getVersions } from '../../utils/version';
import { AddProjectDetail } from '../projects/addProjectDetail';
import { ServicesStatusWrapper } from '../services';
import { COMPANIES, get_logo } from '../funders/constants';
import { setEditTargetDialogOpen } from '../target/redux/actions';
import { Upload } from '@mui/icons-material';
+import { SnapshotType } from '../projects/redux/constants';
+import { NglContext } from '../nglView/nglProvider';
+import { VIEWS } from '../../constants/constants';
+import moment from 'moment';
+import { ToastContext } from '../toast';
+import { api } from '../../utils/api';
const useStyles = makeStyles(theme => ({
padding: {
@@ -119,6 +129,9 @@ export default memo(
const classes = useStyles();
const { headerNavbarTitle, setHeaderNavbarTitle, headerButtons } = useContext(HeaderContext);
+ const { nglViewList, getNglView } = useContext(NglContext);
+ const stage = getNglView(VIEWS.MAJOR_VIEW) && getNglView(VIEWS.MAJOR_VIEW).stage;
+
const [openMenu, setOpenMenu] = useState(false);
const [openFunders, setOpenFunders] = useState(false);
const [openTrackingModal, setOpenTrackingModal] = useState(false);
@@ -139,10 +152,15 @@ export default memo(
const selectedLayoutName = useSelector(state => state.layoutReducers.selectedLayoutName);
+ const currentSnapshot = useSelector(state => state.projectReducers.currentSnapshot);
+ const currentSnapshotId = currentSnapshot && currentSnapshot.id;
+
const discourseAvailable = isDiscourseAvailable();
const targetDiscourseVisible = discourseAvailable && targetName;
const projectDiscourseVisible = discourseAvailable && currentProject && currentProject.title;
+ const { toastError, toastInfo } = useContext(ToastContext);
+
useEffect(() => {
setOpenFunders(isFundersLink);
}, [isFundersLink]);
@@ -160,6 +178,46 @@ export default memo(
window.open(link, '_blank');
};
+ const createSnapshot = useCallback(
+ (title, description) => {
+ if (!currentSnapshotId || !currentProject || !title || !description) return;
+ // Prepare snapshot data
+ const type = SnapshotType.MANUAL;
+ const author = DJANGO_CONTEXT['pk'] || null;
+ const parent = currentSnapshotId;
+ const session_project = currentProject.projectID;
+
+ // Prevents redirect and displaying of share snapshot dialog
+ dispatch(setDisableRedirect(true));
+ dispatch(setDontShowShareSnapshot(true));
+
+ // With the above flags set, createNewSnapshot returns the ID of newly created snapshot as the second item in the array
+ return dispatch(
+ createNewSnapshot({
+ title,
+ description,
+ type,
+ author,
+ parent,
+ session_project,
+ nglViewList,
+ stage,
+ overwriteSnapshot: false,
+ createDiscourse: false
+ })
+ );
+ },
+ [currentProject, currentSnapshotId, dispatch, nglViewList, stage]
+ );
+
+ const editSnapshot = useCallback(
+ snapshotCopy => {
+ dispatch(setSnapshotToBeEdited(snapshotCopy));
+ dispatch(setSnapshotEditDialogOpen(true));
+ },
+ [dispatch]
+ );
+
let authListItem;
let username = null;
@@ -257,11 +315,6 @@ export default memo(
variant="h5"
color="textPrimary"
onClick={() => {
- dispatch(setIsActionsRestoring(false, false));
- dispatch(setProjectActionListLoaded(false));
- // dispatch(setCurrentProject(null, null, null, null, null, [], null));
- // dispatch(setDialogCurrentStep(0));
- // dispatch(setForceCreateProject(false));
history.push(URLS.landing);
window.location.reload();
}}
@@ -273,14 +326,18 @@ export default memo(
targetName !== undefined ? (
<>
{currentProject.authorID === null ||
- currentProject.projectID === null ||
- currentProject.authorID === userId ? (
+ currentProject.projectID === null ||
+ currentProject.authorID === userId ? (
+ }
>
- {tagLabel}
-
-
- }
- )}
+