time-travel-wrapper.js 940 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import { TimeTravel } from 'weaveworks-ui-components';
  4. import { jumpToTime, resumeTime, pauseTimeAtNow } from '../actions/request-actions';
  5. class TimeTravelWrapper extends React.Component {
  6. handleLiveModeChange = (showingLive) => {
  7. if (showingLive) {
  8. this.props.resumeTime();
  9. } else {
  10. this.props.pauseTimeAtNow();
  11. }
  12. }
  13. render() {
  14. return (
  15. <TimeTravel
  16. hasLiveMode
  17. timestamp={this.props.timestamp}
  18. showingLive={this.props.showingLive}
  19. onChangeTimestamp={this.props.jumpToTime}
  20. onChangeLiveMode={this.handleLiveModeChange}
  21. />
  22. );
  23. }
  24. }
  25. function mapStateToProps(state) {
  26. return {
  27. showingLive: !state.get('pausedAt'),
  28. timestamp: state.get('pausedAt'),
  29. };
  30. }
  31. export default connect(
  32. mapStateToProps,
  33. {
  34. jumpToTime, pauseTimeAtNow, resumeTime
  35. },
  36. )(TimeTravelWrapper);