X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_nav%2FskyquakeNav.jsx;h=f9161cc5d3fc77c8c48eeaf8d0604e08f0e66e3b;hp=1aaaf4d454ce4dfcf341859d9d6424b036c48d9e;hb=027dcf27274b717a71fc23034c35089d310ada65;hpb=a81c177c80a2428371b00015fbc9e3837f33fea8 diff --git a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx index 1aaaf4d45..f9161cc5d 100644 --- a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx +++ b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx @@ -25,7 +25,7 @@ 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'); @@ -190,6 +190,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 +262,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 +309,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 +317,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) }