Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pick up default topology options on initial load #3097

Merged
merged 1 commit into from
Feb 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down