X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_nav%2FskyquakeNav.jsx;h=99d14829244bd57c550c730a5ce0daab44e1ff9b;hp=1aaaf4d454ce4dfcf341859d9d6424b036c48d9e;hb=9be8b4847b580cea9e28d2f2a02166753c29b58e;hpb=a81c177c80a2428371b00015fbc9e3837f33fea8 diff --git a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx index 1aaaf4d45..99d148292 100644 --- a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx +++ b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx @@ -25,10 +25,11 @@ import 'style/common.scss'; import './skyquakeNav.scss'; import SelectOption from '../form_controls/selectOption.jsx'; import {FormSection} from '../form_controls/formControls.jsx'; -import SkyquakeRBAC from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; +import {isRBACValid, SkyquakeRBAC} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; //Temporary, until api server is on same port as webserver -var rw = require('utils/rw.js'); +import rw from 'utils/rw.js'; + var API_SERVER = rw.getSearchParams(window.location).api_server; var UPLOAD_SERVER = rw.getSearchParams(window.location).upload_server; @@ -36,23 +37,6 @@ var UPLOAD_SERVER = rw.getSearchParams(window.location).upload_server; // Internal classes/functions // -class LogoutAppMenuItem extends React.Component { - handleLogout() { - Utils.clearAuthentication(); - } - render() { - return ( -
-

- - Logout - -

-
- ); - } -} - class SelectProject extends React.Component { constructor(props) { super(props); @@ -190,6 +174,9 @@ export default class skyquakeNav extends React.Component { skyquakeNav.defaultProps = { nav: {} } +skyquakeNav.contextTypes = { + userProfile: React.PropTypes.object +}; /** * Returns a React Component * @param {object} link Information about the nav link @@ -259,6 +246,7 @@ export function buildNav(nav, currentPlugin, props) { let secondaryNav = []; let adminNav = []; let self = this; + const User = this.context.userProfile; self.hasSubNav = {}; let secondaryNavHTML = (
@@ -305,6 +293,7 @@ export function buildNav(nav, currentPlugin, props) { label: nav[k].label || k, route: route }); + let shouldAllow = nav[k].allow || ['*']; if (nav[k].pluginName == currentPlugin) { navClass += " active"; } @@ -312,22 +301,27 @@ export function buildNav(nav, currentPlugin, props) { navItem.priority = nav[k].priority; navItem.order = nav[k].order; if(nav[k].admin_link) { - adminNav.push(( -
  • - {dashboardLink} -
  • - )) + + if (isRBACValid(User, shouldAllow) ){ + adminNav.push(( +
  • + {dashboardLink} +
  • + )) + } } else { - navItem.html = ( - -

    {dashboardLink} {self.hasSubNav[k] ? : ''}

    - -
    - ); + if (isRBACValid(User, shouldAllow) ){ + navItem.html = ( +
    +

    {dashboardLink} {self.hasSubNav[k] ? : ''}

    + +
    + ); + } navList.push(navItem) }