'use strict';

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

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 _reactIntl = require('react-intl');

var _NavLink = require('./NavLink');

var _NavLink2 = _interopRequireDefault(_NavLink);

var _permissionHelpers = require('../../helpers/permissionHelpers');

var _NavBar = require('../../../styles/cspace-ui/NavBar.css');

var _NavBar2 = _interopRequireDefault(_NavBar);

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

var messages = (0, _reactIntl.defineMessages)({
  admin: {
    'id': 'navBar.admin',
    'defaultMessage': 'Administration'
  },
  create: {
    'id': 'navBar.create',
    'defaultMessage': 'Create New'
  },
  dashboard: {
    'id': 'navBar.dashboard',
    'defaultMessage': 'My CollectionSpace'
  },
  search: {
    'id': 'navBar.search',
    'defaultMessage': 'Search'
  }
});

var propTypes = {
  perms: _propTypes2.default.instanceOf(_immutable2.default.Map)
};

function NavBar(props) {
  var perms = props.perms;


  var createLink = (0, _permissionHelpers.canCreateNew)(perms) ? _react2.default.createElement(
    'li',
    null,
    _react2.default.createElement(
      _NavLink2.default,
      { to: '/create' },
      _react2.default.createElement(_reactIntl.FormattedMessage, messages.create)
    )
  ) : null;

  var adminLink = (0, _permissionHelpers.canAdmin)(perms) ? _react2.default.createElement(
    'li',
    null,
    _react2.default.createElement(
      _NavLink2.default,
      { to: '/admin' },
      _react2.default.createElement(_reactIntl.FormattedMessage, messages.admin)
    )
  ) : null;

  return _react2.default.createElement(
    'nav',
    { className: _NavBar2.default.common },
    _react2.default.createElement(
      'ul',
      null,
      _react2.default.createElement(
        'li',
        null,
        _react2.default.createElement(
          _NavLink2.default,
          { to: '/dashboard' },
          _react2.default.createElement(_reactIntl.FormattedMessage, messages.dashboard)
        )
      ),
      createLink,
      _react2.default.createElement(
        'li',
        null,
        _react2.default.createElement(
          _NavLink2.default,
          { to: '/search' },
          _react2.default.createElement(_reactIntl.FormattedMessage, messages.search)
        )
      ),
      adminLink
    )
  );
}

NavBar.propTypes = propTypes;