2018-12-22 03:50:57 +03:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import shouldPureComponentUpdate from 'react-pure-render/function';
|
|
|
|
import { ActionCreators } from 'redux-devtools';
|
|
|
|
import LogMonitorButton from './LogMonitorButton';
|
|
|
|
|
|
|
|
const { reset, rollback, commit, sweep } = ActionCreators;
|
|
|
|
|
|
|
|
const style = {
|
|
|
|
textAlign: 'center',
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
borderBottomStyle: 'solid',
|
|
|
|
borderColor: 'transparent',
|
|
|
|
zIndex: 1,
|
|
|
|
display: 'flex',
|
2020-08-08 23:26:39 +03:00
|
|
|
flexDirection: 'row',
|
2018-12-22 03:50:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default class LogMonitorButtonBar extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
dispatch: PropTypes.func,
|
2020-08-08 23:26:39 +03:00
|
|
|
theme: PropTypes.object,
|
2018-12-22 03:50:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
shouldComponentUpdate = shouldPureComponentUpdate;
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.handleReset = this.handleReset.bind(this);
|
|
|
|
this.handleRollback = this.handleRollback.bind(this);
|
|
|
|
this.handleSweep = this.handleSweep.bind(this);
|
|
|
|
this.handleCommit = this.handleCommit.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleRollback() {
|
|
|
|
this.props.dispatch(rollback());
|
|
|
|
}
|
|
|
|
|
|
|
|
handleSweep() {
|
|
|
|
this.props.dispatch(sweep());
|
|
|
|
}
|
|
|
|
|
|
|
|
handleCommit() {
|
|
|
|
this.props.dispatch(commit());
|
|
|
|
}
|
|
|
|
|
|
|
|
handleReset() {
|
|
|
|
this.props.dispatch(reset());
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { theme, hasStates, hasSkippedActions } = this.props;
|
|
|
|
return (
|
2019-01-10 21:51:14 +03:00
|
|
|
<div style={{ ...style, borderColor: theme.base02 }}>
|
|
|
|
<LogMonitorButton theme={theme} onClick={this.handleReset} enabled>
|
2018-12-22 03:50:57 +03:00
|
|
|
Reset
|
|
|
|
</LogMonitorButton>
|
|
|
|
<LogMonitorButton
|
|
|
|
theme={theme}
|
|
|
|
onClick={this.handleRollback}
|
2019-01-10 21:51:14 +03:00
|
|
|
enabled={hasStates}
|
|
|
|
>
|
2018-12-22 03:50:57 +03:00
|
|
|
Revert
|
|
|
|
</LogMonitorButton>
|
|
|
|
<LogMonitorButton
|
|
|
|
theme={theme}
|
|
|
|
onClick={this.handleSweep}
|
2019-01-10 21:51:14 +03:00
|
|
|
enabled={hasSkippedActions}
|
|
|
|
>
|
2018-12-22 03:50:57 +03:00
|
|
|
Sweep
|
|
|
|
</LogMonitorButton>
|
|
|
|
<LogMonitorButton
|
|
|
|
theme={theme}
|
|
|
|
onClick={this.handleCommit}
|
2019-01-10 21:51:14 +03:00
|
|
|
enabled={hasStates}
|
|
|
|
>
|
2018-12-22 03:50:57 +03:00
|
|
|
Commit
|
|
|
|
</LogMonitorButton>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|