'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _MediaSnapshotPanelContainer = require('../../containers/record/MediaSnapshotPanelContainer');

var _MediaSnapshotPanelContainer2 = _interopRequireDefault(_MediaSnapshotPanelContainer);

var _RelatedObjectPanelContainer = require('../../containers/record/RelatedObjectPanelContainer');

var _RelatedObjectPanelContainer2 = _interopRequireDefault(_RelatedObjectPanelContainer);

var _RelatedProcedurePanelContainer = require('../../containers/record/RelatedProcedurePanelContainer');

var _RelatedProcedurePanelContainer2 = _interopRequireDefault(_RelatedProcedurePanelContainer);

var _TermsUsedPanelContainer = require('../../containers/record/TermsUsedPanelContainer');

var _TermsUsedPanelContainer2 = _interopRequireDefault(_TermsUsedPanelContainer);

var _UsedByPanelContainer = require('../../containers/record/UsedByPanelContainer');

var _UsedByPanelContainer2 = _interopRequireDefault(_UsedByPanelContainer);

var _RecordSideBar = require('../../../styles/cspace-ui/RecordSideBar.css');

var _RecordSideBar2 = _interopRequireDefault(_RecordSideBar);

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

var propTypes = {
  config: _react.PropTypes.object,
  csid: _react.PropTypes.string,
  recordType: _react.PropTypes.string,
  vocabulary: _react.PropTypes.string
};

function RecordSideBar(props) {
  var config = props.config,
      csid = props.csid,
      recordType = props.recordType,
      vocabulary = props.vocabulary;

  // TODO: Make sidebar components configurable based on service type/record type.

  var recordTypeConfig = config.recordTypes[recordType];

  if (!recordTypeConfig) {
    return null;
  }

  var serviceType = recordTypeConfig.serviceConfig.serviceType;
  var isAuthority = serviceType === 'authority';

  var relatedObjects = null;
  var relatedProcedures = null;
  var usedBy = null;

  if (!isAuthority) {
    relatedObjects = _react2.default.createElement(_RelatedObjectPanelContainer2.default, {
      color: 'blue',
      csid: csid,
      config: config,
      recordType: recordType
    });

    relatedProcedures = _react2.default.createElement(_RelatedProcedurePanelContainer2.default, {
      color: 'blue',
      csid: csid,
      config: config,
      recordType: recordType
    });
  }

  if (isAuthority) {
    usedBy = _react2.default.createElement(_UsedByPanelContainer2.default, {
      color: 'blue',
      csid: csid,
      config: config,
      recordType: recordType,
      vocabulary: vocabulary
    });
  }

  return _react2.default.createElement(
    'div',
    { className: _RecordSideBar2.default.common },
    _react2.default.createElement(_MediaSnapshotPanelContainer2.default, {
      color: 'blue',
      csid: csid,
      config: config,
      recordType: recordType
    }),
    _react2.default.createElement(_TermsUsedPanelContainer2.default, {
      color: 'blue',
      csid: csid,
      config: config,
      recordType: recordType,
      vocabulary: vocabulary
    }),
    relatedObjects,
    relatedProcedures,
    usedBy
  );
}

RecordSideBar.propTypes = propTypes;