import React from 'react';
import { connect } from '../../redux/store';
import { compose } from 'recompose';
import { Link } from '@reach/router';
import { selectCurrentKapp, selectHasRoleSchedulerAdmin, selectHasRoleSchedulerManager } from '@kineticdata/bundle-common';
import { isActiveClass } from '../../utils';
import { I18n } from '@kineticdata/react';
export var SidebarComponent = function SidebarComponent(_ref) {
  var settingsBackPath = _ref.settingsBackPath,
      loading = _ref.loading,
      spaceAdmin = _ref.spaceAdmin,
      kapp = _ref.kapp,
      hasManagerAccess = _ref.hasManagerAccess;
  return /*#__PURE__*/React.createElement("div", {
    className: "sidebar"
  }, /*#__PURE__*/React.createElement(Link, {
    to: settingsBackPath,
    className: "nav-return"
  }, /*#__PURE__*/React.createElement("span", {
    className: "fa fa-fw fa-chevron-left"
  }), /*#__PURE__*/React.createElement(I18n, null, "Return to ".concat(kapp.name))), /*#__PURE__*/React.createElement("div", {
    className: "sidebar-group--content-wrapper"
  }, !loading && /*#__PURE__*/React.createElement("ul", {
    className: "nav flex-column sidebar-group"
  }, /*#__PURE__*/React.createElement("li", {
    className: "nav-item"
  }, /*#__PURE__*/React.createElement(Link, {
    to: "metrics",
    className: "nav-link",
    getProps: isActiveClass('nav-link')
  }, /*#__PURE__*/React.createElement(I18n, null, "Metrics"), /*#__PURE__*/React.createElement("span", {
    className: "fa fa-fw fa-angle-right"
  })), /*#__PURE__*/React.createElement(Link, {
    to: "general",
    className: "nav-link",
    getProps: isActiveClass('nav-link')
  }, /*#__PURE__*/React.createElement(I18n, null, "Tech Bars"), /*#__PURE__*/React.createElement("span", {
    className: "fa fa-fw fa-angle-right"
  })), hasManagerAccess && /*#__PURE__*/React.createElement(Link, {
    to: "schedulers",
    className: "nav-link",
    getProps: isActiveClass('nav-link')
  }, /*#__PURE__*/React.createElement(I18n, null, "Schedulers"), /*#__PURE__*/React.createElement("span", {
    className: "fa fa-fw fa-angle-right"
  }))))));
};
export var mapStateToProps = function mapStateToProps(state) {
  return {
    loading: false,
    pathname: state.router.location.pathname,
    kapp: selectCurrentKapp(state),
    hasManagerAccess: selectHasRoleSchedulerManager(state.app.profile) || selectHasRoleSchedulerAdmin(state.app.profile)
  };
};
export var Sidebar = compose(connect(mapStateToProps))(SidebarComponent);