'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _RecordButtonBar = require('./RecordButtonBar');

var _RecordButtonBar2 = _interopRequireDefault(_RecordButtonBar);

var _RecordFormSelector = require('./RecordFormSelector');

var _RecordFormSelector2 = _interopRequireDefault(_RecordFormSelector);

var _RecordHistory = require('./RecordHistory');

var _RecordHistory2 = _interopRequireDefault(_RecordHistory);

var _RecordHeader = require('../../../styles/cspace-ui/RecordHeader.css');

var _RecordHeader2 = _interopRequireDefault(_RecordHeader);

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

const propTypes = {
  config: _propTypes2.default.object,
  data: _propTypes2.default.instanceOf(_immutable2.default.Map),
  formName: _propTypes2.default.string,
  isCloneable: _propTypes2.default.bool,
  isDeletable: _propTypes2.default.bool,
  isDeprecatable: _propTypes2.default.bool,
  isUndeprecatable: _propTypes2.default.bool,
  isModified: _propTypes2.default.bool,
  isReadPending: _propTypes2.default.bool,
  isSavePending: _propTypes2.default.bool,
  readOnly: _propTypes2.default.bool,
  recordType: _propTypes2.default.string.isRequired,
  showDeprecationButtons: _propTypes2.default.bool,
  validationErrors: _propTypes2.default.instanceOf(_immutable2.default.Map),
  onCloneButtonClick: _propTypes2.default.func,
  onCommit: _propTypes2.default.func,
  onDeprecateButtonClick: _propTypes2.default.func,
  onDeleteButtonClick: _propTypes2.default.func,
  onRevertButtonClick: _propTypes2.default.func,
  onSaveButtonClick: _propTypes2.default.func,
  onSaveButtonErrorBadgeClick: _propTypes2.default.func,
  onUndeprecateButtonClick: _propTypes2.default.func
};

function RecordHeader(props) {
  const config = props.config,
        data = props.data,
        formName = props.formName,
        isCloneable = props.isCloneable,
        isDeletable = props.isDeletable,
        isDeprecatable = props.isDeprecatable,
        isUndeprecatable = props.isUndeprecatable,
        isModified = props.isModified,
        isReadPending = props.isReadPending,
        isSavePending = props.isSavePending,
        readOnly = props.readOnly,
        recordType = props.recordType,
        showDeprecationButtons = props.showDeprecationButtons,
        validationErrors = props.validationErrors,
        onCloneButtonClick = props.onCloneButtonClick,
        onCommit = props.onCommit,
        onDeprecateButtonClick = props.onDeprecateButtonClick,
        onDeleteButtonClick = props.onDeleteButtonClick,
        onRevertButtonClick = props.onRevertButtonClick,
        onSaveButtonClick = props.onSaveButtonClick,
        onSaveButtonErrorBadgeClick = props.onSaveButtonErrorBadgeClick,
        onUndeprecateButtonClick = props.onUndeprecateButtonClick;


  return _react2.default.createElement(
    'div',
    { className: _RecordHeader2.default.common },
    _react2.default.createElement(_RecordButtonBar2.default, {
      isCloneable: isCloneable,
      isDeletable: isDeletable,
      isDeprecatable: isDeprecatable,
      isUndeprecatable: isUndeprecatable,
      isModified: isModified,
      isReadPending: isReadPending,
      isSavePending: isSavePending,
      readOnly: readOnly,
      showDeprecationButtons: showDeprecationButtons,
      validationErrors: validationErrors,
      onCloneButtonClick: onCloneButtonClick,
      onDeprecateButtonClick: onDeprecateButtonClick,
      onDeleteButtonClick: onDeleteButtonClick,
      onRevertButtonClick: onRevertButtonClick,
      onSaveButtonClick: onSaveButtonClick,
      onSaveButtonErrorBadgeClick: onSaveButtonErrorBadgeClick,
      onUndeprecateButtonClick: onUndeprecateButtonClick
    }),
    _react2.default.createElement(_RecordFormSelector2.default, {
      config: config,
      formName: formName,
      recordType: recordType,
      onCommit: onCommit
    }),
    _react2.default.createElement(_RecordHistory2.default, {
      data: data,
      isModified: isModified,
      isSavePending: isSavePending
    })
  );
}

RecordHeader.propTypes = propTypes;