UNPKG

2.09 kBJavaScriptView Raw
1import React, { Component } from 'react';
2import PropTypes from 'prop-types';
3import shouldPureComponentUpdate from 'react-pure-render/function';
4import { ActionCreators } from 'redux-devtools';
5import LogMonitorButton from './LogMonitorButton';
6
7const { reset, rollback, commit, sweep } = ActionCreators;
8
9const style = {
10 textAlign: 'center',
11 borderBottomWidth: 1,
12 borderBottomStyle: 'solid',
13 borderColor: 'transparent',
14 zIndex: 1,
15 display: 'flex',
16 flexDirection: 'row'
17};
18
19export default class LogMonitorButtonBar extends Component {
20 static propTypes = {
21 dispatch: PropTypes.func,
22 theme: PropTypes.object
23 };
24
25 shouldComponentUpdate = shouldPureComponentUpdate;
26
27 constructor(props) {
28 super(props);
29 this.handleReset = this.handleReset.bind(this);
30 this.handleRollback = this.handleRollback.bind(this);
31 this.handleSweep = this.handleSweep.bind(this);
32 this.handleCommit = this.handleCommit.bind(this);
33 }
34
35 handleRollback() {
36 this.props.dispatch(rollback());
37 }
38
39 handleSweep() {
40 this.props.dispatch(sweep());
41 }
42
43 handleCommit() {
44 this.props.dispatch(commit());
45 }
46
47 handleReset() {
48 this.props.dispatch(reset());
49 }
50
51 render() {
52 const { theme, hasStates, hasSkippedActions } = this.props;
53 return (
54 <div style={{ ...style, borderColor: theme.base02 }}>
55 <LogMonitorButton theme={theme} onClick={this.handleReset} enabled>
56 Reset
57 </LogMonitorButton>
58 <LogMonitorButton
59 theme={theme}
60 onClick={this.handleRollback}
61 enabled={hasStates}
62 >
63 Revert
64 </LogMonitorButton>
65 <LogMonitorButton
66 theme={theme}
67 onClick={this.handleSweep}
68 enabled={hasSkippedActions}
69 >
70 Sweep
71 </LogMonitorButton>
72 <LogMonitorButton
73 theme={theme}
74 onClick={this.handleCommit}
75 enabled={hasStates}
76 >
77 Commit
78 </LogMonitorButton>
79 </div>
80 );
81 }
82}