'use strict';

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

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 _UndeprecateButton = require('../../../styles/cspace-ui/UndeprecateButton.css');

var _UndeprecateButton2 = _interopRequireDefault(_UndeprecateButton);

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

var Button = _cspaceInput.components.Button;


var messages = (0, _reactIntl.defineMessages)({
  label: {
    'id': 'undeprecateButton.label',
    'defaultMessage': 'Activate'
  }
});

var propTypes = {
  isDeprecated: _propTypes2.default.bool,
  isModified: _propTypes2.default.bool,
  isSavePending: _propTypes2.default.bool,
  showDeprecationButtons: _propTypes2.default.bool,
  onClick: _propTypes2.default.func
};

function UndeprecateButton(props) {
  var isDeprecated = props.isDeprecated,
      isModified = props.isModified,
      isSavePending = props.isSavePending,
      showDeprecationButtons = props.showDeprecationButtons,
      onClick = props.onClick;


  if (!showDeprecationButtons || !isDeprecated) {
    return null;
  }

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

UndeprecateButton.propTypes = propTypes;