'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = DeprecateButton;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactIntl = require('react-intl');

var _cspaceInput = require('cspace-input');

var _DeprecateButton = require('../../../styles/cspace-ui/DeprecateButton.css');

var _DeprecateButton2 = _interopRequireDefault(_DeprecateButton);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const Button = _cspaceInput.components.Button;


const messages = (0, _reactIntl.defineMessages)({
  label: {
    'id': 'deprecateButton.label',
    'defaultMessage': 'Deactivate'
  }
});

const propTypes = {
  isDeprecatable: _propTypes2.default.bool,
  isModified: _propTypes2.default.bool,
  isSavePending: _propTypes2.default.bool,
  onClick: _propTypes2.default.func
};

function DeprecateButton(props) {
  const isDeprecatable = props.isDeprecatable,
        isModified = props.isModified,
        isSavePending = props.isSavePending,
        onClick = props.onClick;


  if (!isDeprecatable) {
    return null;
  }

  return _react2.default.createElement(
    Button,
    {
      className: _DeprecateButton2.default.common,
      disabled: isModified || isSavePending,
      icon: true,
      name: 'deprecate',
      onClick: onClick
    },
    _react2.default.createElement(_reactIntl.FormattedMessage, messages.label)
  );
}

DeprecateButton.propTypes = propTypes;