From 8a3927012ae0fc7e136612682a5641b7ba0af567 Mon Sep 17 00:00:00 2001 From: Laurence Maultsby Date: Fri, 14 Apr 2017 12:19:29 -0400 Subject: [PATCH] Launchpad RBAC Signed-off-by: Laurence Maultsby --- .../src/instantiate/instantiateDashboard.jsx | 16 ++++++++++++---- skyquake/plugins/launchpad/src/launchpad.jsx | 15 ++++++++++++--- .../src/launchpad_card/launchpadCard.jsx | 4 ++-- .../src/launchpad_card/vnfrConfigPrimitives.jsx | 6 +++--- .../launchpad/src/nsCardPanel/nsCardPanel.jsx | 3 ++- .../launchpad/src/recordViewer/recordCard.jsx | 12 +++++++++++- 6 files changed, 42 insertions(+), 14 deletions(-) diff --git a/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx b/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx index 9c358e8c0..b1d216369 100644 --- a/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx +++ b/skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx @@ -24,10 +24,15 @@ import InstantiateSelectDescriptorPanel from './instantiateSelectDescriptorPanel import CatalogDescriptorRaw from './catalogDescriptorRaw.jsx' import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx'; import {Panel, PanelWrapper} from 'widgets/panel/panel'; -import Button from 'widgets/button/rw.button.js' +import Button from 'widgets/button/rw.button.js'; +import {SkyquakeRBAC, isRBACValid} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; +import ROLES from 'utils/roleConstants.js'; import 'style/layout.scss'; import './instantiateDashboard.scss'; +const PROJECT_ROLES = ROLES.PROJECT; +const PLATFORM = ROLES.PLATFORM; + class InstantiateDashboard extends React.Component { constructor(props) { super(props); @@ -107,6 +112,7 @@ class InstantiateDashboard extends React.Component { let html; let selectedNSDid = self.state.selectedNSDid; let isPreviewing = self.state.isPreviewing; + const hasAccess = isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN]); let descriptorPreview = ( @@ -136,10 +142,11 @@ class InstantiateDashboard extends React.Component { + {hasAccess ? : null} ) }); @@ -112,7 +113,6 @@ } render() { - let tabList = []; let tabPanels = []; let isConfiguring = (this.props.data['config-status'] && this.props.data['config-status'] != 'configured') || false; diff --git a/skyquake/plugins/launchpad/src/nsCardPanel/nsCardPanel.jsx b/skyquake/plugins/launchpad/src/nsCardPanel/nsCardPanel.jsx index 2b9b4c12e..5d2f53604 100644 --- a/skyquake/plugins/launchpad/src/nsCardPanel/nsCardPanel.jsx +++ b/skyquake/plugins/launchpad/src/nsCardPanel/nsCardPanel.jsx @@ -32,7 +32,8 @@ export default class NsCardPanel extends React.Component { data={nsr.data} nsr={nsr} isActive={nsr["admin-status"] == "ENABLED"} - closeButtonAction={this.onCloseCard(nsr.id)}/> + closeButtonAction={this.onCloseCard(nsr.id)} + hasAccess={this.props.hasAccess}/> ); } } diff --git a/skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx b/skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx index 88ff709a4..7b3cb2188 100644 --- a/skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx +++ b/skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx @@ -36,6 +36,10 @@ import LaunchpadFleetStore from '../launchpadFleetStore.js'; import Prism from 'prismjs'; import 'prismjs/themes/prism.css'; +import {SkyquakeRBAC, isRBACValid} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx'; +import ROLES from 'utils/roleConstants.js'; + +const PROJECT_ROLES = ROLES.PROJECT; export default class RecordCard extends React.Component { constructor(props) { @@ -77,6 +81,8 @@ export default class RecordCard extends React.Component { let notice = null; + let hasAccess = isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN]); + switch(this.props.type) { case 'vnfr' : cardData = this.props.data[0]; @@ -86,7 +92,7 @@ export default class RecordCard extends React.Component { if (displayConfigPrimitives) { configPrimitiveComponent = (
- + {/* */}
@@ -419,3 +425,7 @@ RecordCard.defaultProps = { isLoading: true, jobData: [] } +RecordCard.contextTypes = { + router: React.PropTypes.object, + userProfile: React.PropTypes.object +}; -- 2.25.1