Merge pull request #3097 from weaveworks/1999-fix-default-topology-options-filtering

Pick up default topology options on initial load
This commit is contained in:
Filip Barl
2018-02-27 21:08:07 +01:00
committed by GitHub

View File

@@ -650,11 +650,15 @@ export function rootReducer(state = initialState, action) {
log(`Set currentTopologyId to ${state.get('currentTopologyId')}`);
}
state = setTopology(state, state.get('currentTopologyId'));
// only set on first load, if options are not already set via route
if (!state.get('topologiesLoaded') && state.get('topologyOptions').size === 0) {
state = state.set('topologyOptions', getDefaultTopologyOptions(state));
// Expand topology options with topologies' defaults on first load, but let
// the current state of topologyOptions (which at this point reflects the
// URL state) still take the precedence over defaults.
if (!state.get('topologiesLoaded')) {
const options = getDefaultTopologyOptions(state).mergeDeep(state.get('topologyOptions'));
state = state.set('topologyOptions', options);
state = state.set('topologiesLoaded', true);
}
state = state.set('topologiesLoaded', true);
return state;
}
@@ -683,6 +687,9 @@ export function rootReducer(state = initialState, action) {
selectedNodeId: action.state.selectedNodeId,
pinnedMetricType: action.state.pinnedMetricType,
});
if (action.state.topologyOptions) {
state = state.set('topologyOptions', fromJS(action.state.topologyOptions));
}
if (action.state.topologyViewMode) {
state = state.set('topologyViewMode', action.state.topologyViewMode);
}
@@ -716,12 +723,6 @@ export function rootReducer(state = initialState, action) {
} else {
state = state.update('nodeDetails', nodeDetails => nodeDetails.clear());
}
// Use the default topology options for all the fields not
// explicitly listed in the Scope state (URL or local storage).
state = state.set(
'topologyOptions',
getDefaultTopologyOptions(state).mergeDeep(action.state.topologyOptions),
);
return state;
}