import React, { Component } from 'react';
import { ActionCreators } from '@redux-devtools/core';
import { Button, Toolbar, Divider } from '@redux-devtools/ui';
import RecordButton from './buttons/RecordButton';
import PersistButton from './buttons/PersistButton';
import LockButton from './buttons/LockButton';
import InstanceSelector from './InstanceSelector';
import SyncButton from './buttons/SyncButton';
// eslint-disable-next-line @typescript-eslint/unbound-method
const {
  reset,
  rollback,
  commit,
  sweep
} = ActionCreators;
export default class TopButtons extends Component {
  shouldComponentUpdate(nextProps) {
    return nextProps.options !== this.props.options || nextProps.liftedState !== this.props.liftedState;
  }
  handleRollback = () => {
    this.props.dispatch(rollback());
  };
  handleSweep = () => {
    this.props.dispatch(sweep());
  };
  handleCommit = () => {
    this.props.dispatch(commit());
  };
  handleReset = () => {
    this.props.dispatch(reset());
  };
  render() {
    const options = this.props.options;
    const features = options.features;
    const {
      computedStates,
      skippedActionIds,
      isPaused,
      isLocked
    } = this.props.liftedState;
    const noStates = computedStates.length < 2;
    return /*#__PURE__*/React.createElement(Toolbar, {
      borderPosition: "bottom"
    }, features.pause && /*#__PURE__*/React.createElement(RecordButton, {
      paused: isPaused
    }), features.persist && /*#__PURE__*/React.createElement(PersistButton, null), features.lock && /*#__PURE__*/React.createElement(LockButton, {
      locked: isLocked,
      disabled: options.lib !== 'redux'
    }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(Button, {
      title: "Reset to the state you created the store with",
      tooltipPosition: "bottom",
      onClick: this.handleReset
    }, "Reset"), /*#__PURE__*/React.createElement(Button, {
      title: "Roll back to the last committed state",
      tooltipPosition: "bottom",
      onClick: this.handleRollback,
      disabled: noStates
    }, "Revert"), /*#__PURE__*/React.createElement(Button, {
      title: "Remove all currently disabled actions from the log",
      tooltipPosition: "bottom",
      onClick: this.handleSweep,
      disabled: skippedActionIds.length === 0
    }, "Sweep"), /*#__PURE__*/React.createElement(Button, {
      title: "Remove all actions from the log,\\a and make the current state your initial state",
      tooltipPosition: "bottom",
      onClick: this.handleCommit,
      disabled: noStates
    }, "Commit"), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(InstanceSelector, null), features.sync && /*#__PURE__*/React.createElement(SyncButton, null));
  }
}