'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactIntl = require('react-intl');

var _reactRouterDom = require('react-router-dom');

var _AdminNavBar = require('../../../styles/cspace-ui/AdminNavBar.css');

var _AdminNavBar2 = _interopRequireDefault(_AdminNavBar);

var _AdminNavItem = require('../../../styles/cspace-ui/AdminNavItem.css');

var _AdminNavItem2 = _interopRequireDefault(_AdminNavItem);

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

const messages = (0, _reactIntl.defineMessages)({
  account: {
    'id': 'adminNavBar.account',
    'defaultMessage': 'Users'
  },
  authrole: {
    'id': 'adminNavBar.authrole',
    'defaultMessage': 'Roles and Permissions'
  },
  vocabulary: {
    'id': 'adminNavBar.vocabulary',
    'defaultMessage': 'Term Lists'
  }
});

const renderLinkItem = (basename, tab) => _react2.default.createElement(
  'li',
  { key: tab },
  _react2.default.createElement(
    _reactRouterDom.NavLink,
    {
      to: `${basename}/${tab}`,
      className: _AdminNavItem2.default.common,
      activeClassName: _AdminNavItem2.default.active
    },
    _react2.default.createElement(_reactIntl.FormattedMessage, messages[tab])
  )
);

const propTypes = {
  basename: _propTypes2.default.string,
  tabs: _propTypes2.default.arrayOf(_propTypes2.default.string)
};

function AdminNavBar(props) {
  const basename = props.basename,
        tabs = props.tabs;


  const items = tabs.map(tab => renderLinkItem(basename, tab));

  return _react2.default.createElement(
    'nav',
    { className: _AdminNavBar2.default.common },
    _react2.default.createElement(
      'ul',
      null,
      items
    )
  );
}

AdminNavBar.propTypes = propTypes;