import React from 'react'; import classNames from 'classnames'; import { connect } from 'react-redux'; import { TimestampTag } from 'weaveworks-ui-components'; import { trackAnalyticsEvent } from '../utils/tracking-utils'; import { pauseTimeAtNow, resumeTime } from '../actions/request-actions'; import { isPausedSelector, timeTravelSupportedSelector } from '../selectors/time-travel'; import moment from 'moment' const className = isSelected => ( classNames('time-control-action', { 'time-control-action-selected': isSelected }) ); class TimeControl extends React.Component { getTrackingMetadata = (data = {}) => { const { currentTopology } = this.props; return { layout: this.props.topologyViewMode, parentTopologyId: currentTopology && currentTopology.get('parentId'), topologyId: currentTopology && currentTopology.get('id'), ...data, }; } handleNowClick = () => { trackAnalyticsEvent('scope.time.resume.click', this.getTrackingMetadata()); this.props.resumeTime(); } handlePauseClick = () => { trackAnalyticsEvent('scope.time.pause.click', this.getTrackingMetadata()); this.props.pauseTimeAtNow(); } render() { const { isPaused, pausedAt, topologiesLoaded } = this.props; // If Time Travel is supported, show an empty placeholder div instead // of this control, since time will be controlled through the timeline. // We return
instead of null so that selector controls would // be aligned the same way between WC Explore and Scope standalone. if (this.props.timeTravelSupported) return ; return (