From 75bf86d3a27521b674fa7ef78dafb22e2b02a565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1na=20Kohanov=C3=A1?= Date: Fri, 27 Nov 2020 11:41:03 +0100 Subject: [PATCH 1/2] #453 Undo/Redo Actions - hide all mass action --- .../preview/molecule/redux/dispatchActions.js | 46 ++++++++--- js/reducers/selection/actions.js | 21 +++-- js/reducers/selection/constants.js | 1 + js/reducers/selection/selectionReducers.js | 4 + js/reducers/tracking/constants.js | 3 + js/reducers/tracking/dispatchActions.js | 79 ++++++++++++++++++- js/reducers/tracking/trackingActions.js | 14 ++++ 7 files changed, 149 insertions(+), 19 deletions(-) diff --git a/js/components/preview/molecule/redux/dispatchActions.js b/js/components/preview/molecule/redux/dispatchActions.js index 96db239fa..7d4b8234e 100644 --- a/js/components/preview/molecule/redux/dispatchActions.js +++ b/js/components/preview/molecule/redux/dispatchActions.js @@ -19,7 +19,8 @@ import { updateVectorCompounds, updateBondColorMapOfCompounds, resetBondColorMapOfVectors, - setCurrentVector + setCurrentVector, + setHideAll } from '../../../../reducers/selection/actions'; import { base_url } from '../../../routes/constants'; import { @@ -115,11 +116,11 @@ const handleVector = (json, stage, data) => (dispatch, getState) => { dispatch(updateBondColorMapOfCompounds(data.smiles, vectorBondColorMap)); }; -export const addVector = (stage, data) => async (dispatch, getState) => { +export const addVector = (stage, data, skipTracking = false) => async (dispatch, getState) => { const currentVector = getState().selectionReducers.currentVector; dispatch(incrementCountOfPendingVectorLoadRequests()); - dispatch(appendVectorOnList(generateMoleculeId(data))); + dispatch(appendVectorOnList(generateMoleculeId(data), skipTracking)); dispatch(selectVectorAndResetCompounds(currentVector)); return api({ url: getViewUrl('graph', data) }) @@ -226,7 +227,7 @@ export const removeComplex = (stage, data, colourToggle, skipTracking = false) = dispatch(removeFromComplexList(generateMoleculeId(data), skipTracking)); }; -export const addSurface = (stage, data, colourToggle) => dispatch => { +export const addSurface = (stage, data, colourToggle, skipTracking = false) => dispatch => { dispatch( loadObject({ target: Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)), @@ -237,17 +238,17 @@ export const addSurface = (stage, data, colourToggle) => dispatch => { const currentOrientation = stage.viewerControls.getOrientation(); dispatch(setOrientation(VIEWS.MAJOR_VIEW, currentOrientation)); }); - dispatch(appendSurfaceList(generateMoleculeId(data))); + dispatch(appendSurfaceList(generateMoleculeId(data), skipTracking)); }; -export const removeSurface = (stage, data, colourToggle) => dispatch => { +export const removeSurface = (stage, data, colourToggle, skipTracking = false) => dispatch => { dispatch( deleteObject( Object.assign({ display_div: VIEWS.MAJOR_VIEW }, generateSurfaceObject(data, colourToggle, base_url)), stage ) ); - dispatch(removeFromSurfaceList(generateMoleculeId(data))); + dispatch(removeFromSurfaceList(generateMoleculeId(data), skipTracking)); }; export const addDensity = (stage, data, colourToggle) => dispatch => { @@ -330,23 +331,33 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch, const vectorOnList = state.selectionReducers.vectorOnList; const surfaceList = state.selectionReducers.surfaceList; const proteinList = state.selectionReducers.proteinList; + const vectorList = state.selectionReducers.vector_list; + + let ligandDataList = []; + let complexDataList = []; + let vectorOnDataList = []; + let surfaceDataList = []; + let proteinDataList = []; fragmentDisplayList.forEach(moleculeId => { const data = currentMolecules.find(molecule => molecule.id === moleculeId); if (data) { - dispatch(removeLigand(stage, data)); + ligandDataList.push(data); + dispatch(removeLigand(stage, data, true)); } }); complexList.forEach(moleculeId => { const data = currentMolecules.find(molecule => molecule.id === moleculeId); if (data) { - dispatch(removeComplex(stage, data, colourList[0])); + complexDataList.push(data); + dispatch(removeComplex(stage, data, colourList[0], true)); } }); vectorOnList.forEach(moleculeId => { const data = currentMolecules.find(molecule => molecule.id === moleculeId); if (data) { - dispatch(removeVector(stage, data)); + vectorOnDataList.push(data); + dispatch(removeVector(stage, data, true)); } }); @@ -354,7 +365,8 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch, surfaceList.forEach(moleculeId => { const data = currentMolecules.find(molecule => molecule.id === moleculeId); if (data) { - dispatch(removeSurface(stage, data)); + surfaceDataList.push(data); + dispatch(removeSurface(stage, data, colourList[0], true)); } }); @@ -362,7 +374,8 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch, proteinList.forEach(moleculeId => { const data = currentMolecules.find(molecule => molecule.id === moleculeId); if (data) { - dispatch(removeHitProtein(stage, data)); + proteinDataList.push(data); + dispatch(removeHitProtein(stage, data, colourList[0], true)); } }); @@ -371,6 +384,15 @@ export const hideAllSelectedMolecules = (stage, currentMolecules) => (dispatch, dispatch(resetCompoundsOfVectors()); dispatch(resetBondColorMapOfVectors()); dispatch(setCompoundImage(noCompoundImage)); + + let data = { + ligandList: ligandDataList, + proteinList: proteinDataList, + complexList: complexDataList, + surfaceList: surfaceDataList, + vectorOnList: vectorOnDataList + }; + dispatch(setHideAll(data)); }; export const searchMoleculeGroupByMoleculeID = moleculeID => (dispatch, getState) => diff --git a/js/reducers/selection/actions.js b/js/reducers/selection/actions.js index 54f92371e..9c154498c 100644 --- a/js/reducers/selection/actions.js +++ b/js/reducers/selection/actions.js @@ -114,17 +114,19 @@ export const setSurfaceList = function(surfaceList) { }; }; -export const appendSurfaceList = function(item) { +export const appendSurfaceList = function(item, skipTracking = false) { return { type: constants.APPEND_SURFACE_LIST, - item: item + item: item, + skipTracking: skipTracking }; }; -export const removeFromSurfaceList = function(item) { +export const removeFromSurfaceList = function(item, skipTracking = false) { return { type: constants.REMOVE_FROM_SURFACE_LIST, - item: item + item: item, + skipTracking: skipTracking }; }; @@ -156,10 +158,11 @@ export const setVectorOnList = function(vectorOnList) { }; }; -export const appendVectorOnList = function(item) { +export const appendVectorOnList = function(item, skipTracking = false) { return { type: constants.APPEND_VECTOR_ON_LIST, - item: item + item: item, + skipTracking: skipTracking }; }; @@ -253,3 +256,9 @@ export const setDeselectedAllByType = (type, items, isInspiration) => ({ type: constants.SET_DESELECTED_ALL_BY_TYPE, payload: { type, items, isInspiration } }); + +export const setHideAll = (data, isHide = true) => ({ + type: constants.SET_HIDE_ALL, + isHide: isHide, + data: data +}); diff --git a/js/reducers/selection/constants.js b/js/reducers/selection/constants.js index 6d64dce57..24269ecef 100644 --- a/js/reducers/selection/constants.js +++ b/js/reducers/selection/constants.js @@ -36,6 +36,7 @@ export const constants = { SET_DESELECTED_ALL: prefix + 'SET_DESELECTED_ALL', SET_SELECTED_ALL_BY_TYPE: prefix + 'SET_SELECTED_ALL_BY_TYPE', SET_DESELECTED_ALL_BY_TYPE: prefix + 'SET_DESELECTED_ALL_BY_TYPE', + SET_HIDE_ALL: prefix + 'SET_HIDE_ALL', RESET_COMPOUNDS_OF_VECTORS: prefix + 'RESET_COMPOUNDS_OF_VECTORS', UPDATE_VECTOR_COMPOUNDS: prefix + 'UPDATE_VECTOR_COMPOUNDS', diff --git a/js/reducers/selection/selectionReducers.js b/js/reducers/selection/selectionReducers.js index c68307d65..62f909d2e 100644 --- a/js/reducers/selection/selectionReducers.js +++ b/js/reducers/selection/selectionReducers.js @@ -299,6 +299,10 @@ export function selectionReducers(state = INITIAL_STATE, action = {}) { return Object.assign({}, state, { moleculeAllTypeSelection: action.payload.type }); + + case constants.SET_HIDE_ALL: + return state; + // Cases like: @@redux/INIT default: return state; diff --git a/js/reducers/tracking/constants.js b/js/reducers/tracking/constants.js index 228820c83..f7017793b 100644 --- a/js/reducers/tracking/constants.js +++ b/js/reducers/tracking/constants.js @@ -42,6 +42,7 @@ export const actionType = { REPRESENTATION_REMOVED: 'REPRESENTATION_REMOVED', UNDO: 'UNDO', REDO: 'REDO', + ALL_HIDE: 'ALL_HIDE', ALL_TURNED_ON: 'ALL_TURNED_ON', ALL_TURNED_OFF: 'ALL_TURNED_OFF', ALL_TURNED_ON_BY_TYPE: 'ALL_TURNED_ON_BY_TYPE', @@ -54,6 +55,8 @@ export const actionDescription = { TURNED_OFF: 'was turned off', SELECTED: 'was selected', DESELECTED: 'was deselected', + HIDDEN: 'hidden', + CANCELED: 'canceled', ADDED: 'was added', REMOVED: 'was removed', CHANGED: 'was changed', diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js index 18a8bbb18..a774bb46e 100644 --- a/js/reducers/tracking/dispatchActions.js +++ b/js/reducers/tracking/dispatchActions.js @@ -6,7 +6,7 @@ import { } from './actions'; import { actionType, actionObjectType } from './constants'; import { VIEWS } from '../../../js/constants/constants'; -import { setCurrentVector, appendToBuyList, removeFromToBuyList } from '../selection/actions'; +import { setCurrentVector, appendToBuyList, removeFromToBuyList, setHideAll } from '../selection/actions'; import { unmountPreviewComponent, shouldLoadProtein } from '../../components/preview/redux/dispatchActions'; import { selectMoleculeGroup, @@ -749,6 +749,9 @@ const handleUndoAction = (action, stages) => (dispatch, getState) => { const type = action.type; switch (type) { + case actionType.ALL_HIDE: + dispatch(handleAllHideAction(action, true, majorViewStage)); + break; case actionType.ALL_TURNED_ON: dispatch(handleAllAction(action, false, majorViewStage, state)); break; @@ -844,6 +847,9 @@ const handleRedoAction = (action, stages) => (dispatch, getState) => { const type = action.type; switch (type) { + case actionType.ALL_HIDE: + dispatch(handleAllHideAction(action, false, majorViewStage)); + break; case actionType.ALL_TURNED_ON: dispatch(handleAllAction(action, true, majorViewStage, state)); break; @@ -1005,6 +1011,77 @@ const handleAllActionByType = (action, isAdd, stage) => (dispatch, getState) => } }; +const handleAllHideAction = (action, isAdd, stage) => (dispatch, getState) => { + let data = action.data; + let ligandDataList = data.ligandList; + let proteinDataList = data.proteinList; + let complexDataList = data.complexList; + let surfaceDataList = data.surfaceList; + let vectorOnDataList = data.vectorOnList; + + dispatch(setHideAll(data, !isAdd)); + + if (isAdd) { + ligandDataList.forEach(data => { + if (data) { + dispatch(addType['ligand'](stage, data, colourList[data.id % colourList.length], true, true)); + } + }); + + proteinDataList.forEach(data => { + if (data) { + dispatch(addType['protein'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + + complexDataList.forEach(data => { + if (data) { + dispatch(addType['complex'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + + surfaceDataList.forEach(data => { + if (data) { + dispatch(addType['surface'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + vectorOnDataList.forEach(data => { + if (data) { + dispatch(addType['vector'](stage, data, true)); + } + }); + } else { + ligandDataList.forEach(data => { + if (data) { + dispatch(removeType['ligand'](stage, data, true)); + } + }); + + proteinDataList.forEach(data => { + if (data) { + dispatch(removeType['protein'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + + complexDataList.forEach(data => { + if (data) { + dispatch(removeType['complex'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + + surfaceDataList.forEach(data => { + if (data) { + dispatch(removeType['surface'](stage, data, colourList[data.id % colourList.length], true)); + } + }); + vectorOnDataList.forEach(data => { + if (data) { + dispatch(removeType['vector'](stage, data, true)); + } + }); + } +}; + const handleAllAction = (action, isSelected, majorViewStage, state) => (dispatch, getState) => { let isSelection = action.object_type === actionObjectType.MOLECULE || action.object_type === actionObjectType.INSPIRATION; diff --git a/js/reducers/tracking/trackingActions.js b/js/reducers/tracking/trackingActions.js index 5e4b28b78..93b2f37a8 100644 --- a/js/reducers/tracking/trackingActions.js +++ b/js/reducers/tracking/trackingActions.js @@ -56,6 +56,20 @@ export const findTrackAction = (action, state) => { text: `${actionDescription.SITE} ${molGroupName} ${actionDescription.TURNED_OFF}` }; } + } else if (action.type === selectionConstants.SET_HIDE_ALL) { + if (action.data) { + let objectType = actionObjectType.MOLECULE; + let description = action.isHide === true ? `` : `${actionDescription.CANCELED}`; + + trackAction = { + type: actionType.ALL_HIDE, + timestamp: Date.now(), + username: username, + object_type: objectType, + data: action.data, + text: `${actionDescription.ALL} ${actionDescription.HIDDEN} ${description}` + }; + } } else if (action.type === selectionConstants.SET_SELECTED_ALL) { if (action.item) { let objectType = action.item.isInspiration === true ? actionObjectType.INSPIRATION : actionObjectType.MOLECULE; From 2be6880f34e9658d69aa961de60a5c7df2e4ded6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1na=20Kohanov=C3=A1?= Date: Mon, 30 Nov 2020 14:52:07 +0100 Subject: [PATCH 2/2] #433 Restore NGL view state --- .../preview/redux/dispatchActions.js | 2 - .../snapshot/modals/newSnapshotForm.js | 17 ++++--- .../snapshot/redux/dispatchActions.js | 21 +++++--- .../snapshot/withSnapshotManagement.js | 2 +- js/reducers/tracking/constants.js | 1 + js/reducers/tracking/dispatchActions.js | 48 +++++++++++++++---- 6 files changed, 68 insertions(+), 23 deletions(-) diff --git a/js/components/preview/redux/dispatchActions.js b/js/components/preview/redux/dispatchActions.js index ebd038920..f2c3d5cc1 100644 --- a/js/components/preview/redux/dispatchActions.js +++ b/js/components/preview/redux/dispatchActions.js @@ -46,8 +46,6 @@ export const shouldLoadProtein = ({ const state = getState(); const targetIdList = state.apiReducers.target_id_list; const targetOnName = state.apiReducers.target_on_name; - const currentSnapshotData = state.projectReducers.currentSnapshot.data; - // const isLoadingCurrentSnapshot = state.projectReducers.isLoadingCurrentSnapshot; if ( targetIdList && targetIdList.length > 0 && diff --git a/js/components/snapshot/modals/newSnapshotForm.js b/js/components/snapshot/modals/newSnapshotForm.js index ce57e290c..eb9d5309a 100644 --- a/js/components/snapshot/modals/newSnapshotForm.js +++ b/js/components/snapshot/modals/newSnapshotForm.js @@ -1,4 +1,4 @@ -import React, { memo, useState } from 'react'; +import React, { memo, useState, useContext } from 'react'; import { Grid, makeStyles, Typography } from '@material-ui/core'; import { useDispatch, useSelector } from 'react-redux'; import { DJANGO_CONTEXT } from '../../../utils/djangoContext'; @@ -9,6 +9,8 @@ import { TextField } from 'formik-material-ui'; import { Button } from '../../common/Inputs/Button'; import { SnapshotType } from '../../projects/redux/constants'; import { createNewSnapshot } from '../redux/dispatchActions'; +import { NglContext } from '../../nglView/nglProvider'; + import moment from 'moment'; const useStyles = makeStyles(theme => ({ @@ -33,6 +35,7 @@ export const NewSnapshotForm = memo(({ handleCloseModal }) => { const classes = useStyles(); const [state, setState] = useState(); const dispatch = useDispatch(); + const { nglViewList } = useContext(NglContext); const currentSnapshot = useSelector(state => state.projectReducers.currentSnapshot); const currentProject = useSelector(state => state.projectReducers.currentProject); @@ -70,11 +73,13 @@ export const NewSnapshotForm = memo(({ handleCloseModal }) => { const parent = isForceProjectCreated === false ? currentSnapshot.id : null; const session_project = currentProject.projectID; - dispatch(createNewSnapshot({ title, description, type, author, parent, session_project })).catch(error => { - setState(() => { - throw error; - }); - }); + dispatch(createNewSnapshot({ title, description, type, author, parent, session_project, nglViewList })).catch( + error => { + setState(() => { + throw error; + }); + } + ); }} > {({ submitForm, isSubmitting }) => ( diff --git a/js/components/snapshot/redux/dispatchActions.js b/js/components/snapshot/redux/dispatchActions.js index 6d5d22b56..9844a9b0f 100644 --- a/js/components/snapshot/redux/dispatchActions.js +++ b/js/components/snapshot/redux/dispatchActions.js @@ -178,7 +178,7 @@ export const createInitSnapshotFromCopy = ({ return Promise.reject('ProjectID is missing'); }; -export const createNewSnapshot = ({ title, description, type, author, parent, session_project }) => ( +export const createNewSnapshot = ({ title, description, type, author, parent, session_project, nglViewList }) => ( dispatch, getState ) => { @@ -215,7 +215,7 @@ export const createNewSnapshot = ({ title, description, type, author, parent, se }).then(res => { // redirect to project with newest created snapshot /:projectID/:snapshotID if (res.data.id && session_project) { - dispatch(saveCurrentActionsList(res.data.id, session_project)); + dispatch(saveCurrentActionsList(res.data.id, session_project, nglViewList)); if (disableRedirect === false) { // Really bad usage or redirection. Hint for everybody in this line ignore it, but in other parts of code @@ -284,7 +284,8 @@ export const createNewSnapshotWithoutStateModification = ({ type, author, parent, - session_project + session_project, + nglViewList }) => (dispatch, getState) => { if (!session_project) { return Promise.reject('Project ID is missing!'); @@ -320,13 +321,13 @@ export const createNewSnapshotWithoutStateModification = ({ disableRedirect: true }) ); - dispatch(saveCurrentActionsList(res.data.id, session_project)); + dispatch(saveCurrentActionsList(res.data.id, session_project, nglViewList)); } }); }); }; -export const saveAndShareSnapshot = (target = undefined) => (dispatch, getState) => { +export const saveAndShareSnapshot = nglViewList => (dispatch, getState) => { const state = getState(); const targetId = state.apiReducers.target_on; const loggedInUserID = DJANGO_CONTEXT['pk']; @@ -357,7 +358,15 @@ export const saveAndShareSnapshot = (target = undefined) => (dispatch, getState) dispatch(sendTrackingActionsByProjectId(projectID, author)); return dispatch( - createNewSnapshotWithoutStateModification({ title, description, type, author, parent, session_project }) + createNewSnapshotWithoutStateModification({ + title, + description, + type, + author, + parent, + session_project, + nglViewList + }) ); }) .catch(error => { diff --git a/js/components/snapshot/withSnapshotManagement.js b/js/components/snapshot/withSnapshotManagement.js index 7c8b0b662..500521c40 100644 --- a/js/components/snapshot/withSnapshotManagement.js +++ b/js/components/snapshot/withSnapshotManagement.js @@ -78,7 +78,7 @@ export const withSnapshotManagement = WrappedComponent => { startIcon={} disabled={disableShareButton || disableUserInteraction} onClick={() => { - dispatch(saveAndShareSnapshot(target)); + dispatch(saveAndShareSnapshot(nglViewList)); }} > Share diff --git a/js/reducers/tracking/constants.js b/js/reducers/tracking/constants.js index f7017793b..0d2bdf68d 100644 --- a/js/reducers/tracking/constants.js +++ b/js/reducers/tracking/constants.js @@ -40,6 +40,7 @@ export const actionType = { REPRESENTATION_CHANGED: 'REPRESENTATION_CHANGED', REPRESENTATION_ADDED: 'REPRESENTATION_ADDED', REPRESENTATION_REMOVED: 'REPRESENTATION_REMOVED', + NGL_STATE: 'NGL_STATE', UNDO: 'UNDO', REDO: 'REDO', ALL_HIDE: 'ALL_HIDE', diff --git a/js/reducers/tracking/dispatchActions.js b/js/reducers/tracking/dispatchActions.js index a774bb46e..6e4da0ac2 100644 --- a/js/reducers/tracking/dispatchActions.js +++ b/js/reducers/tracking/dispatchActions.js @@ -53,7 +53,7 @@ import { } from '../../../js/reducers/ngl/actions'; import * as listType from '../../constants/listTypes'; import { assignRepresentationToComp } from '../../components/nglView/generatingObjects'; -import { deleteObject } from '../../../js/reducers/ngl/dispatchActions'; +import { deleteObject, setOrientation } from '../../../js/reducers/ngl/dispatchActions'; import { setSendActionsList, setIsActionsSending, setIsActionsLoading, setActionsList } from './actions'; import { api, METHOD } from '../../../js/utils/api'; import { base_url } from '../../components/routes/constants'; @@ -80,7 +80,7 @@ import { setDeselectedAllByType as setDeselectedAllByTypeOfDataset } from '../../components/datasets/redux/actions'; -export const saveCurrentActionsList = (snapshotID, projectID) => (dispatch, getState) => { +export const saveCurrentActionsList = (snapshotID, projectID, nglViewList) => (dispatch, getState) => { const state = getState(); let actionList = state.trackingReducers.track_actions_list; @@ -91,11 +91,11 @@ export const saveCurrentActionsList = (snapshotID, projectID) => (dispatch, getS dispatch(saveActionsList(snapshotID, actionList)); }); } else { - dispatch(saveActionsList(snapshotID, actionList)); + dispatch(saveActionsList(snapshotID, actionList, nglViewList)); } }; -export const saveActionsList = (snapshotID, actionList) => (dispatch, getState) => { +export const saveActionsList = (snapshotID, actionList, nglViewList) => (dispatch, getState) => { const state = getState(); const currentTargetOn = state.apiReducers.target_on; @@ -215,6 +215,18 @@ export const saveActionsList = (snapshotID, actionList) => (dispatch, getState) currentActions ); + let nglStateList = nglViewList.map(nglView => { + return { id: nglView.id, orientation: nglView.stage.viewerControls.getOrientation() }; + }); + + let trackAction = { + type: actionType.NGL_STATE, + timestamp: Date.now(), + nglStateList: nglStateList + }; + + currentActions.push(Object.assign({ ...trackAction })); + dispatch(setCurrentActionsList(currentActions)); dispatch(saveTrackingActions(currentActions, snapshotID)); }; @@ -403,14 +415,34 @@ export const restoreAfterTargetActions = stages => (dispatch, getState) => { throw error; }) .finally(() => { - dispatch(restoreSitesActions(orderedActionList, summaryView)); - dispatch(loadAllMolecules(orderedActionList, targetId, majorView.stage)); - dispatch(loadAllDatasets(orderedActionList, targetId, majorView.stage)); - dispatch(restoreRepresentationActions(orderedActionList, stages)); + Promise.resolve( + dispatch(restoreSitesActions(orderedActionList, summaryView)), + dispatch(loadAllMolecules(orderedActionList, targetId, majorView.stage)), + dispatch(loadAllDatasets(orderedActionList, targetId, majorView.stage)) + ).then(() => { + dispatch(restoreNglStateAction(orderedActionList, stages)); + dispatch(restoreRepresentationActions(orderedActionList, stages)); + }); }); } }; +const restoreNglStateAction = (orderedActionList, stages) => (dispatch, getState) => { + let action = orderedActionList.find(action => action.type === actionType.NGL_STATE); + if (action && action.nglStateList) { + action.nglStateList.forEach(nglView => { + dispatch(setOrientation(nglView.id, nglView.orientation)); + + if (nglView.id !== VIEWS.SUMMARY_VIEW) { + let viewStage = stages.find(s => s.id === nglView.id); + if (viewStage) { + viewStage.stage.viewerControls.orient(nglView.orientation.elements); + } + } + }); + } +}; + const loadAllDatasets = (orderedActionList, target_on, stage) => (dispatch, getState) => { dispatch(setMoleculeListIsLoading(true)); dispatch(loadDataSets(target_on))