'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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 = {
  csid: _react.PropTypes.string,
  isModified: _react.PropTypes.bool,
  isSavePending: _react.PropTypes.bool,
  clone: _react.PropTypes.func
};

function CloneButton(props) {
  var csid = props.csid,
      isModified = props.isModified,
      isSavePending = props.isSavePending,
      clone = props.clone;


  if (!csid) {
    return null;
  }

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

CloneButton.propTypes = propTypes;