Skip to content

Commit

Permalink
Addressed some of @foot's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Jul 6, 2017
1 parent b7b4afa commit 94da5e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/app/scripts/actions/app-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export function resumeTime() {
};
}

export function clickTimeTravel() {
export function startTimeTravel() {
return (dispatch, getState) => {
dispatch({
type: ActionTypes.START_TIME_TRAVEL
Expand Down
16 changes: 11 additions & 5 deletions client/app/scripts/components/time-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { connect } from 'react-redux';
import CloudFeature from './cloud-feature';
import TimeTravelButton from './time-travel-button';
import { trackMixpanelEvent } from '../utils/tracking-utils';
import { pauseTimeAtNow, resumeTime, clickTimeTravel } from '../actions/app-actions';
import { pauseTimeAtNow, resumeTime, startTimeTravel } from '../actions/app-actions';


const className = isSelected => (
Expand All @@ -23,12 +23,13 @@ class TimeControl extends React.Component {
this.getTrackingMetadata = this.getTrackingMetadata.bind(this);
}

getTrackingMetadata() {
getTrackingMetadata(data = {}) {
const { currentTopology } = this.props;
return {
layout: this.props.topologyViewMode,
topologyId: currentTopology && currentTopology.get('id'),
parentTopologyId: currentTopology && currentTopology.get('parentId'),
...data
};
}

Expand All @@ -43,8 +44,13 @@ class TimeControl extends React.Component {
}

handleTravelClick() {
trackMixpanelEvent('scope.time.travel.click', this.getTrackingMetadata());
this.props.clickTimeTravel();
if (!this.props.showingTimeTravel) {
trackMixpanelEvent('scope.time.travel.click', this.getTrackingMetadata({ open: true }));
this.props.startTimeTravel();
} else {
trackMixpanelEvent('scope.time.travel.click', this.getTrackingMetadata({ open: false }));
this.props.resumeTime();
}
}

render() {
Expand Down Expand Up @@ -117,6 +123,6 @@ export default connect(
{
resumeTime,
pauseTimeAtNow,
clickTimeTravel,
startTimeTravel,
}
)(TimeControl);
11 changes: 6 additions & 5 deletions client/app/scripts/reducers/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@ export function rootReducer(state = initialState, action) {
return state;
}

case ActionTypes.FINISH_TIME_TRAVEL_TRANSITION: {
state = state.set('timeTravelTransitioning', false);
return clearNodes(state);
}

case ActionTypes.CLICK_SHOW_TOPOLOGY_FOR_NODE: {
state = state.update('nodeDetails',
nodeDetails => nodeDetails.filter((v, k) => k === action.nodeId));
Expand Down Expand Up @@ -375,6 +370,7 @@ export function rootReducer(state = initialState, action) {
}

case ActionTypes.START_TIME_TRAVEL: {
state = state.set('timeTravelTransitioning', false);
state = state.set('showingTimeTravel', true);
return state.set('pausedAt', moment().utc());
}
Expand All @@ -387,6 +383,11 @@ export function rootReducer(state = initialState, action) {
return state.set('timeTravelTransitioning', true);
}

case ActionTypes.FINISH_TIME_TRAVEL_TRANSITION: {
state = state.set('timeTravelTransitioning', false);
return clearNodes(state);
}

//
// websockets
//
Expand Down

0 comments on commit 94da5e9

Please sign in to comment.