From 05cd10cfcba612fadb218f06d2665dc14313ec2e Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Thu, 13 Oct 2016 16:46:20 +0200 Subject: [PATCH] Revert "Current topo follows details panel!" This reverts commit 7a5e04f44f46b3fc94dc0f67b68b4633659b88a9. --- client/app/scripts/actions/app-actions.js | 8 +--- client/app/scripts/reducers/root.js | 57 +++++++---------------- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/client/app/scripts/actions/app-actions.js b/client/app/scripts/actions/app-actions.js index 34203e885..eff78794b 100644 --- a/client/app/scripts/actions/app-actions.js +++ b/client/app/scripts/actions/app-actions.js @@ -286,7 +286,6 @@ export function clickRelative(nodeId, topologyId, label, origin) { topologyId }); updateRoute(getState); - resetUpdateBuffer(); const state = getState(); getNodeDetails( state.get('topologyUrlsById'), @@ -295,11 +294,6 @@ export function clickRelative(nodeId, topologyId, label, origin) { state.get('nodeDetails'), dispatch ); - getNodesDelta( - getCurrentTopologyUrl(state), - getActiveTopologyOptions(state), - dispatch - ); }; } @@ -467,7 +461,7 @@ export function hitEsc() { } else if (state.get('showingHelp')) { dispatch(hideHelp()); } else if (state.get('nodeDetails').last() && !controlPipe) { - dispatch({ type: ActionTypes.CLICK_CLOSE_DETAILS }); + dispatch({ type: ActionTypes.DESELECT_NODE }); updateRoute(getState); } }; diff --git a/client/app/scripts/reducers/root.js b/client/app/scripts/reducers/root.js index fc81a0802..09d6de922 100644 --- a/client/app/scripts/reducers/root.js +++ b/client/app/scripts/reducers/root.js @@ -69,7 +69,6 @@ export const initialState = makeMap({ exportingGraph: false }); - // adds ID field to topology (based on last part of URL path) and save urls in // map for easy lookup function processTopologies(state, nextTopologies) { @@ -88,14 +87,12 @@ function processTopologies(state, nextTopologies) { return state.mergeDeepIn(['topologies'], immNextTopologies); } - function setTopology(state, topologyId) { state = state.set('currentTopology', findTopologyById( state.get('topologies'), topologyId)); return state.set('currentTopologyId', topologyId); } - function setDefaultTopologyOptions(state, topologyList) { topologyList.forEach(topology => { let defaultOptions = makeOrderedMap(); @@ -116,7 +113,6 @@ function setDefaultTopologyOptions(state, topologyList) { return state; } - function closeNodeDetails(state, nodeId) { const nodeDetails = state.get('nodeDetails'); if (nodeDetails.size > 0) { @@ -132,7 +128,6 @@ function closeNodeDetails(state, nodeId) { return state; } - function closeAllNodeDetails(state) { while (state.get('nodeDetails').size) { state = closeNodeDetails(state); @@ -140,33 +135,10 @@ function closeAllNodeDetails(state) { return state; } - function resumeUpdate(state) { return state.set('updatePausedAt', null); } - -function setSelectedNode(state, {nodeId, label, origin, topologyId}) { - state = resumeUpdate(state); - if (state.hasIn(['nodeDetails', nodeId])) { - // bring to front - const details = state.getIn(['nodeDetails', nodeId]); - state = state.deleteIn(['nodeDetails', nodeId]); - state = state.setIn(['nodeDetails', nodeId], details); - } else { - state = state.setIn(['nodeDetails', nodeId], {id: nodeId, label, origin, topologyId}); - } - state = state.set('selectedNodeId', nodeId); - if (topologyId !== state.get('currentTopologyId')) { - state = setTopology(state, topologyId); - state = state.update('nodes', nodes => nodes.clear()); - state = state.set('availableCanvasMetrics', makeList()); - } - - return state; -} - - export function rootReducer(state = initialState, action) { if (!action.type) { error('Payload missing a type!', action); @@ -221,17 +193,7 @@ export function rootReducer(state = initialState, action) { } case ActionTypes.CLICK_CLOSE_DETAILS: { - state = closeNodeDetails(state, action.nodeId); - const topCard = state.get('nodeDetails').last(); - if (!topCard) { - return state; - } - - return setSelectedNode(state, { - nodeId: topCard.id, - label: topCard.label, - topologyId: topCard.topologyId, - }); + return closeNodeDetails(state, action.nodeId); } case ActionTypes.CLICK_CLOSE_TERMINAL: { @@ -271,7 +233,22 @@ export function rootReducer(state = initialState, action) { } case ActionTypes.CLICK_RELATIVE: { - return setSelectedNode(state, action); + if (state.hasIn(['nodeDetails', action.nodeId])) { + // bring to front + const details = state.getIn(['nodeDetails', action.nodeId]); + state = state.deleteIn(['nodeDetails', action.nodeId]); + state = state.setIn(['nodeDetails', action.nodeId], details); + } else { + state = state.setIn(['nodeDetails', action.nodeId], + { + id: action.nodeId, + label: action.label, + origin: action.origin, + topologyId: action.topologyId + } + ); + } + return state; } case ActionTypes.CLICK_RESUME_UPDATE: {