Added logic to remove non-transferrable state keys when switching Cloud instances

This commit is contained in:
jpellizzari
2017-02-13 17:37:09 -08:00
committed by Jordan Pellizzari
parent c9048d8661
commit 3d13e916af
5 changed files with 22 additions and 0 deletions

View File

@@ -684,6 +684,8 @@ export function toggleTroubleshootingMenu(ev) {
export function changeInstance() {
return (dispatch, getState) => {
dispatch({ type: ActionTypes.CHANGE_INSTANCE });
updateRoute(getState);
const state = getState();
getNodesDelta(
getCurrentTopologyUrl(state),

View File

@@ -58,6 +58,7 @@ const ACTION_TYPES = [
'SET_RECEIVED_NODES_DELTA',
'SORT_ORDER_CHANGED',
'SET_GRID_MODE',
'CHANGE_INSTANCE'
];
export default zipObject(ACTION_TYPES, ACTION_TYPES);

View File

@@ -192,6 +192,10 @@ describe('RootReducer', () => {
state: {}
};
const ChangeInstanceAction = {
type: ActionTypes.CHANGE_INSTANCE
};
// Basic tests
it('returns initial state', () => {
@@ -525,4 +529,13 @@ describe('RootReducer', () => {
nextState = reducer(nextState, action3);
expect(nextState.getIn(['nodes', 'n1', 'adjacency'])).toBeFalsy();
});
it('removes non-transferrable state values when changing instances', () => {
let nextState = initialState;
nextState = reducer(nextState, ClickNodeAction);
expect(nextState.get('selectedNodeId')).toEqual('n1');
expect(nextState.getIn(['nodeDetails', 'n1'])).toBeTruthy();
nextState = reducer(nextState, ChangeInstanceAction);
expect(nextState.get('selectedNodeId')).toBeFalsy();
expect(nextState.getIn(['nodeDetails', 'n1'])).toBeFalsy();
});
});

View File

@@ -721,6 +721,11 @@ export function rootReducer(state = initialState, action) {
return state.set('showingTroubleshootingMenu', !state.get('showingTroubleshootingMenu'));
}
case ActionTypes.CHANGE_INSTANCE: {
state = closeAllNodeDetails(state);
return state;
}
default: {
return state;
}

View File

@@ -61,6 +61,7 @@
"eslint-plugin-import": "2.2.0",
"eslint-plugin-jsx-a11y": "2.2.3",
"eslint-plugin-react": "6.8.0",
"expect": "^1.20.2",
"extract-text-webpack-plugin": "1.0.1",
"file-loader": "0.9.0",
"html-webpack-plugin": "2.24.1",