X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Flaunchpad%2Fsrc%2Fvirtual_links%2FnsVirtualLinks.jsx;h=aa4fe43cbbee56453fe249c39b74693eb18e2746;hp=fa09d9ffac6f797f1716b96d3b50ef6a51ed2a0d;hb=refs%2Ftags%2Fv3.0.0rc2;hpb=756a58911e5ab70e42b7793ffef9807738d2f5e1 diff --git a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx index fa09d9ffa..aa4fe43cb 100644 --- a/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx +++ b/skyquake/plugins/launchpad/src/virtual_links/nsVirtualLinks.jsx @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,17 +19,23 @@ import React from 'react'; import NSVirtualLinkCreateStore from './nsVirtualLinkCreateStore.js'; import Button from 'widgets/button/rw.button.js'; import Utils from 'utils/utils.js'; -import _ from 'lodash'; +import _find from 'lodash/find'; import './nsVirtualLinks.scss'; import UpTime from 'widgets/uptime/uptime.jsx'; import NSVirtualLinkDetails from './nsVirtualLinkDetails.jsx'; import NSVirtualLinkCreate from './nsVirtualLinkCreate.jsx'; import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx'; +import ROLES from 'utils/roleConstants.js'; +import {SkyquakeRBAC, isRBACValid} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; + +const PROJECT_ROLES = ROLES.PROJECT; +const PLATFORM = ROLES.PLATFORM; class NsVirtualLinks extends React.Component { constructor(props) { super(props); - this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore); + this.Store = this.props.flux.stores.hasOwnProperty('NSVirtualLinkCreateStore') ? + this.props.flux.stores.NSVirtualLinkCreateStore : this.props.flux.createStore(NSVirtualLinkCreateStore, 'NSVirtualLinkCreateStore'); this.state = {}; this.state.mode = 'viewing'; // Can be 'viewing'/'creating'/'editing'/'deleting'. Default is 'viewing' this.selectedVirtualLink = null; @@ -58,7 +64,7 @@ class NsVirtualLinks extends React.Component { if (!this.state.nsd) { this.setState({ nsd: this.props.data.nsd - }); + }); } if (!this.state.nsrId) { @@ -77,7 +83,7 @@ class NsVirtualLinks extends React.Component { if (!this.state.nsd) { this.setState({ nsd: nextProps.data.nsd - }); + }); } if (!this.state.nsrId) { @@ -113,7 +119,7 @@ class NsVirtualLinks extends React.Component { handleSelectVirtualLinkClick = (virtualLinkId, event) => { this.setState({ mode: 'viewing', - selectedVirtualLink: this.props.data && this.props.data['decorated-vlrs'] && _.find(this.props.data['decorated-vlrs'], {id: virtualLinkId}), + selectedVirtualLink: this.props.data && this.props.data['decorated-vlrs'] && _find(this.props.data['decorated-vlrs'], {id: virtualLinkId}), editingVirtualLink: null }); } @@ -121,8 +127,8 @@ class NsVirtualLinks extends React.Component { event.stopPropagation(); this.setState({ mode: 'editing', - editingVirtualLink: this.props.data && this.props.data['nsd'] && this.props.data['nsd']['vld'] && _.find(this.props.data['nsd']['vld'], {id: vldId}), - selectedVirtualLink: this.props.data && this.props.data['decorated-vlrs'] && _.find(this.props.data['decorated-vlrs'], {id: vlrId}) + editingVirtualLink: this.props.data && this.props.data['nsd'] && this.props.data['nsd']['vld'] && _find(this.props.data['nsd']['vld'], {id: vldId}), + selectedVirtualLink: this.props.data && this.props.data['decorated-vlrs'] && _find(this.props.data['decorated-vlrs'], {id: vlrId}) }); } @@ -148,14 +154,18 @@ class NsVirtualLinks extends React.Component { {name} {operationalStatus} - - - - - - - - + { + isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ? + + + + + + + + + : null + } ); }); @@ -172,7 +182,10 @@ class NsVirtualLinks extends React.Component { Name Status - + { + isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ? + : null + } {tbody} @@ -223,7 +236,7 @@ class NsVirtualLinks extends React.Component { {nsVirtualLinksTable}
- {nsVirtualLinkCreateButton} + { isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ? nsVirtualLinkCreateButton : null}
{nsVirtualLinkDetails} @@ -231,4 +244,4 @@ class NsVirtualLinks extends React.Component { ); } } -export default SkyquakeComponent(NsVirtualLinks); \ No newline at end of file +export default SkyquakeComponent(NsVirtualLinks);