Skip to content

Commit

Permalink
Fixed the flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Jul 3, 2017
1 parent dc985dc commit 720bb7d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
18 changes: 11 additions & 7 deletions client/app/scripts/actions/app-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,18 @@ export function receiveNodesDelta(delta) {
setTimeout(() => dispatch({ type: ActionTypes.SET_RECEIVED_NODES_DELTA }), 0);

const state = getState();
const hasChanges = delta.add || delta.update || delta.remove;

if (hasChanges) {
if (isPausedSelector(state)) {
// dispatch({ type: ActionTypes.BUFFER_NODES_DELTA, delta });
} else {
if (!isPausedSelector(state)) {
// When moving in time, we will consider the transition complete
// only when the first batch of nodes delta has been received. We
// do that because we want to keep the previous state blurred instead
// of transitioning over an empty state like when switching topologies.
if (state.get('timeTravelTransitioning')) {
dispatch({ type: ActionTypes.FINISH_TIME_TRAVEL_TRANSITION });
}

const hasChanges = delta.add || delta.update || delta.remove;
if (hasChanges) {
dispatch({
type: ActionTypes.RECEIVE_NODES_DELTA,
delta
Expand Down Expand Up @@ -599,8 +605,6 @@ export function jumpToTime(timestamp) {
timestamp,
});
getNodes(getState(), dispatch);
// updateWebsocketChannel(getState(), dispatch);
// dispatch(resetNodesDeltaBuffer());
getTopologies(getState(), dispatch);
if (isResourceViewModeSelector(getState())) {
getResourceViewNodesSnapshot(getState(), dispatch);
Expand Down
30 changes: 14 additions & 16 deletions client/app/scripts/components/time-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,30 @@ class TimeControl extends React.Component {
this.handleNowClick = this.handleNowClick.bind(this);
this.handlePauseClick = this.handlePauseClick.bind(this);
this.handleTravelClick = this.handleTravelClick.bind(this);
this.getTrackingMetadata = this.getTrackingMetadata.bind(this);
}

handleNowClick() {
getTrackingMetadata() {
const { currentTopology } = this.props;
trackMixpanelEvent('scope.time.resume.click', {
return {
layout: this.props.topologyViewMode,
topologyId: currentTopology && currentTopology.get('id'),
parentTopologyId: currentTopology && currentTopology.get('parentId'),
});
};
}

handleNowClick() {
trackMixpanelEvent('scope.time.resume.click', this.getTrackingMetadata());
this.props.clickResumeUpdate();
}

handlePauseClick() {
const { currentTopology } = this.props;
trackMixpanelEvent('scope.time.pause.click', {
layout: this.props.topologyViewMode,
topologyId: currentTopology && currentTopology.get('id'),
parentTopologyId: currentTopology && currentTopology.get('parentId'),
});
trackMixpanelEvent('scope.time.pause.click', this.getTrackingMetadata());
this.props.clickPauseUpdate();
}

handleTravelClick() {
const { currentTopology } = this.props;
trackMixpanelEvent('scope.time.travel.click', {
layout: this.props.topologyViewMode,
topologyId: currentTopology && currentTopology.get('id'),
parentTopologyId: currentTopology && currentTopology.get('parentId'),
});
trackMixpanelEvent('scope.time.travel.click', this.getTrackingMetadata());
this.props.clickTimeTravel();
}

Expand Down Expand Up @@ -95,14 +90,17 @@ class TimeControl extends React.Component {
title={moment(pausedAt).utc().toISOString()}>
Paused {moment(pausedAt).fromNow()}
</span>}
{isRunningNow && timeTravelTransitioning && <span
className="time-control-info">
Resuming the live state
</span>}
</div>
);
}
}

function mapStateToProps(state) {
return {
update: state.get('topologyViewMode'),
topologyViewMode: state.get('topologyViewMode'),
currentTopology: state.get('currentTopology'),
showingTimeTravel: state.get('showingTimeTravel'),
Expand Down
3 changes: 2 additions & 1 deletion client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ export function rootReducer(state = initialState, action) {
//

case ActionTypes.RESUME_TIME_FROM_NOW: {
state = state.set('timeTravelTransitioning', true);
state = state.set('showingTimeTravel', false);
return state.set('pausedAt', null);
}
Expand Down Expand Up @@ -582,7 +583,7 @@ export function rootReducer(state = initialState, action) {
'update', size(action.delta.update),
'add', size(action.delta.add));

// nodes that no longer exist
// remove nodes that no longer exist
each(action.delta.remove, (nodeId) => {
state = state.deleteIn(['nodes', nodeId]);
});
Expand Down
2 changes: 0 additions & 2 deletions client/app/scripts/utils/web-api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ export function getResourceViewNodesSnapshot(state, dispatch) {
}

export function getTopologies(state, dispatch, initialPoll = false) {
// TODO: Remove this once TimeTravel is out of the feature flag.
state = state.scope || state;
// Used to resume polling when navigating between pages in Weave Cloud.
continuePolling = initialPoll === true ? true : continuePolling;
clearTimeout(topologyTimer);
Expand Down

0 comments on commit 720bb7d

Please sign in to comment.