'use strict';

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

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

var _CloneButton2 = _interopRequireDefault(_CloneButton);

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

var Button = _cspaceInput.components.Button;


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

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

var defaultProps = {
  isCloneable: true
};

function CloneButton(props) {
  var isCloneable = props.isCloneable,
      isModified = props.isModified,
      isSavePending = props.isSavePending,
      onClick = props.onClick;


  if (!isCloneable) {
    return null;
  }

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

CloneButton.propTypes = propTypes;
CloneButton.defaultProps = defaultProps;