X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fframework%2Fwidgets%2Fskyquake_nav%2FskyquakeNav.jsx;h=d9dff0b3931305af8d09f89ff4eb464569f0dce5;hp=01158c7f001cffdce168165a485b0f3336f460ad;hb=2da8b7a246ba17396c5bc218a0b7f1685fb8d304;hpb=abf00ef39ee93f2a7ff05a4432eb3a50a88a487e
diff --git a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx
index 01158c7f0..d9dff0b39 100644
--- a/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx
+++ b/skyquake/framework/widgets/skyquake_nav/skyquakeNav.jsx
@@ -25,9 +25,11 @@ import 'style/common.scss';
import './skyquakeNav.scss';
import SelectOption from '../form_controls/selectOption.jsx';
import {FormSection} from '../form_controls/formControls.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;
@@ -52,26 +54,76 @@ class LogoutAppMenuItem extends React.Component {
}
}
+class SelectProject extends React.Component {
+ constructor(props) {
+ super(props);
+ }
+ selectProject(e) {
+ let value = JSON.parse(e.currentTarget.value);
+ console.log('selected project', value)
+ }
+ render() {
+ let props = this.props;
+ let currentValue = JSON.stringify(props.currentProject);
+ let projects = this.props.projects && this.props.projects.map((p,i) => {
+ return {
+ label: p.name,
+ value: p.name
+ }
+ });
+ let hasProjects = (this.props.projects && (this.props.projects.length > 0))
+ return (
+
+ {
+ hasProjects ? 'Project:' : 'No Projects Assigned'
+ }
+ {
+ hasProjects ?
+
+ : null
+ }
+
+ )
+ }
+}
class UserNav extends React.Component {
constructor(props) {
super(props);
}
+ handleLogout() {
+ Utils.clearAuthentication();
+ }
selectProject(e) {
let value = JSON.parse(e.currentTarget.value)
console.log('selected project', value)
}
render() {
- let projects = this.props.projects.map((p,i) => {
- return {
- label: p.name,
- value: p
+ let props = this.props;
+ let userProfileLink = '';
+ this.props.nav['user_management'] && this.props.nav['user_management'].routes.map((r) => {
+ if(r.unique) {
+ userProfileLink = returnLinkItem(r, props.currentUser)
}
})
return (
-
- Project:
-
+
+
+ USER: {userProfileLink}
+
+
+
)
}
@@ -139,6 +191,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
@@ -166,12 +221,12 @@ export function buildNavListItem (k, link, index) {
* @param {object} link Routing information from nav object.
* @return {object} component returns a react component that links to a new route.
*/
-export function returnLinkItem(link) {
+export function returnLinkItem(link, label) {
let ref;
let route = link.route;
if(link.isExternal) {
ref = (
-
{link.label}
+
{label || link.label}
)
} else {
if(link.path && link.path.replace(' ', '') != '') {
@@ -186,8 +241,8 @@ export function returnLinkItem(link) {
}
}
ref = (
-
- {link.label}
+
+ {label || link.label}
)
}
@@ -206,13 +261,32 @@ export function buildNav(nav, currentPlugin, props) {
let navList = [];
let navListHTML = [];
let secondaryNav = [];
+ let adminNav = [];
let self = this;
+ const User = this.context.userProfile;
self.hasSubNav = {};
let secondaryNavHTML = (
)
for (let k in nav) {
@@ -236,23 +310,38 @@ 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";
}
NavList = nav[k].routes.map(buildNavListItem.bind(self, k));
navItem.priority = nav[k].priority;
navItem.order = nav[k].order;
- navItem.html = (
-
-
{dashboardLink} {self.hasSubNav[k] ? : ''}
-
-
- );
+ if(nav[k].admin_link) {
+
+ if (isRBACValid(User, shouldAllow) ){
+ adminNav.push((
+
+ {dashboardLink}
+
+ ))
+ }
+ } else {
+ if (isRBACValid(User, shouldAllow) ){
+ navItem.html = (
+
+
{dashboardLink} {self.hasSubNav[k] ? : ''}
+
+
+ );
+ }
navList.push(navItem)
+ }
+
}
}
//Sorts nav items by order and returns only the markup