"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.mapStateToProps = exports.SidebarComponent = exports.Sidebar = void 0;
var _react = _interopRequireDefault(require("react"));
var _store = require("../../redux/store");
var _recompose = require("recompose");
var _router = require("@reach/router");
var _bundleCommon = require("@kineticdata/bundle-common");
var _utils = require("../../utils");
var _react2 = require("@kineticdata/react");
var SidebarComponent = exports.SidebarComponent = function SidebarComponent(_ref) {
  var settingsBackPath = _ref.settingsBackPath,
    loading = _ref.loading,
    spaceAdmin = _ref.spaceAdmin,
    kapp = _ref.kapp,
    hasManagerAccess = _ref.hasManagerAccess;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "sidebar"
  }, /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: settingsBackPath,
    className: "nav-return"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-fw fa-chevron-left"
  }), /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Return to ".concat(kapp.name))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sidebar-group--content-wrapper"
  }, !loading && /*#__PURE__*/_react["default"].createElement("ul", {
    className: "nav flex-column sidebar-group"
  }, /*#__PURE__*/_react["default"].createElement("li", {
    className: "nav-item"
  }, /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: "metrics",
    className: "nav-link",
    getProps: (0, _utils.isActiveClass)('nav-link')
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Metrics"), /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-fw fa-angle-right"
  })), /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: "general",
    className: "nav-link",
    getProps: (0, _utils.isActiveClass)('nav-link')
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Tech Bars"), /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-fw fa-angle-right"
  })), hasManagerAccess && /*#__PURE__*/_react["default"].createElement(_router.Link, {
    to: "schedulers",
    className: "nav-link",
    getProps: (0, _utils.isActiveClass)('nav-link')
  }, /*#__PURE__*/_react["default"].createElement(_react2.I18n, null, "Schedulers"), /*#__PURE__*/_react["default"].createElement("span", {
    className: "fa fa-fw fa-angle-right"
  }))))));
};
var mapStateToProps = exports.mapStateToProps = function mapStateToProps(state) {
  return {
    loading: false,
    pathname: state.router.location.pathname,
    kapp: (0, _bundleCommon.selectCurrentKapp)(state),
    hasManagerAccess: (0, _bundleCommon.selectHasRoleSchedulerManager)(state.app.profile) || (0, _bundleCommon.selectHasRoleSchedulerAdmin)(state.app.profile)
  };
};
var Sidebar = exports.Sidebar = (0, _recompose.compose)((0, _store.connect)(mapStateToProps))(SidebarComponent);