"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _immutable = _interopRequireDefault(require("immutable"));

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

var _NavLink = _interopRequireDefault(require("./NavLink"));

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

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

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

const 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"
  },
  tool: {
    "id": "navBar.tool",
    "defaultMessage": "Tools"
  }
});
const propTypes = {
  perms: _propTypes.default.instanceOf(_immutable.default.Map)
};

function NavBar(props) {
  const {
    perms
  } = props;
  const createLink = (0, _permissionHelpers.canCreateNew)(perms) ? /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_NavLink.default, {
    to: "/create"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.create))) : null;
  const toolLink = (0, _permissionHelpers.canTool)(perms) ? /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_NavLink.default, {
    to: "/tool"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.tool))) : null;
  const adminLink = (0, _permissionHelpers.canAdmin)(perms) ? /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_NavLink.default, {
    to: "/admin"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.admin))) : null;
  return /*#__PURE__*/_react.default.createElement("nav", {
    className: _NavBar.default.common
  }, /*#__PURE__*/_react.default.createElement("ul", null, /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_NavLink.default, {
    to: "/dashboard"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.dashboard))), createLink, /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_NavLink.default, {
    to: "/search"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, messages.search))), toolLink, adminLink));
}

NavBar.propTypes = propTypes;