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

Show loading indicator on topology changes #2232

Merged
merged 2 commits into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions client/app/scripts/reducers/__tests__/root-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ describe('RootReducer', () => {
let nextState = initialState.set('currentTopology', fromJS(topologies[0]));
nextState = reducer(nextState, {type: ActionTypes.SET_RECEIVED_NODES_DELTA});
expect(nextState.get('gridMode')).toBe(true);
expect(nextState.get('initialNodesLoaded')).toBe(true);
});
it('cleans up old adjacencies', () => {
// Add some nodes
Expand Down
21 changes: 16 additions & 5 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export const initialState = makeMap({
version: '...',
versionUpdate: null,
websocketClosed: false,
exportingGraph: false
exportingGraph: false,
initialNodesLoaded: false
});

// adds ID field to topology (based on last part of URL path) and save urls in
Expand Down Expand Up @@ -148,6 +149,12 @@ function resumeUpdate(state) {
return state.set('updatePausedAt', null);
}

function clearNodes(state) {
return state
.update('nodes', nodes => nodes.clear())
.set('nodesLoaded', false);
}

export function rootReducer(state = initialState, action) {
if (!action.type) {
error('Payload missing a type!', action);
Expand Down Expand Up @@ -278,9 +285,10 @@ export function rootReducer(state = initialState, action) {

if (action.topologyId !== state.get('currentTopologyId')) {
state = setTopology(state, action.topologyId);
state = state.update('nodes', nodes => nodes.clear());
state = clearNodes(state);
}
state = state.set('availableCanvasMetrics', makeList());

return state;
}

Expand All @@ -290,8 +298,9 @@ export function rootReducer(state = initialState, action) {

if (action.topologyId !== state.get('currentTopologyId')) {
state = setTopology(state, action.topologyId);
state = state.update('nodes', nodes => nodes.clear());
state = clearNodes(state);
}

state = state.set('availableCanvasMetrics', makeList());
return state;
}
Expand Down Expand Up @@ -515,12 +524,14 @@ export function rootReducer(state = initialState, action) {
}

case ActionTypes.SET_RECEIVED_NODES_DELTA: {
// Turn on the table view if the graph is too complex
if (!state.get('nodesLoaded')) {
// Turn on the table view if the graph is too complex, but skip this block if
// the user has already loaded topologies once.
if (!state.get('initialNodesLoaded') && !state.get('nodesLoaded')) {
const topoStats = state.get('currentTopology').get('stats');
state = graphExceedsComplexityThresh(topoStats)
? state.set('gridMode', true)
: state;
state = state.set('initialNodesLoaded', true);
}
return state.set('nodesLoaded', true);
}
Expand Down