'use strict';

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

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

var _DeleteButton2 = _interopRequireDefault(_DeleteButton);

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

var Button = _cspaceInput.components.Button;


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

var propTypes = {
  disabled: _propTypes2.default.bool,
  isDeletable: _propTypes2.default.bool,
  isSavePending: _propTypes2.default.bool,
  onClick: _propTypes2.default.func
};

function DeleteButton(props) {
  var disabled = props.disabled,
      isDeletable = props.isDeletable,
      isSavePending = props.isSavePending,
      onClick = props.onClick;


  if (!isDeletable) {
    return null;
  }

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

DeleteButton.propTypes = propTypes;