Launchpad RBAC
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 14 Apr 2017 16:19:29 +0000 (12:19 -0400)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Fri, 14 Apr 2017 16:19:29 +0000 (12:19 -0400)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/launchpad/src/instantiate/instantiateDashboard.jsx
skyquake/plugins/launchpad/src/launchpad.jsx
skyquake/plugins/launchpad/src/launchpad_card/launchpadCard.jsx
skyquake/plugins/launchpad/src/launchpad_card/vnfrConfigPrimitives.jsx
skyquake/plugins/launchpad/src/nsCardPanel/nsCardPanel.jsx
skyquake/plugins/launchpad/src/recordViewer/recordCard.jsx

index 9c358e8..b1d2163 100644 (file)
@@ -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 = (
             <Panel title={(self.state.selectedNSD['short-name'] || self.state.selectedNSD.name ) + ' Descriptor Preview'} className="CatalogDescriptorPreview">
             <span className="oi CatalogDescriptorPreview-button" data-glyph={"circle-x"} onClick={self.Store.deselectDescriptor}></span>
@@ -136,10 +142,11 @@ class InstantiateDashboard extends React.Component {
 
                     <Button label="Cancel" onClick={this.handleCancel}/>
                     {this.isSelectPage() ?
-                        <Button label="Next" isLoading={this.state.isSaving} onClick={this.state.selectedNSD && self.openDescriptor} className="dark"  type="submit"/>
+                        <Button label="Next" isLoading={this.state.isSaving} onClick={this.state.selectedNSD && self.openDescriptor} className="dark" type="submit"/>
                         : <div>
                             <Button label="Back" onClick={this.handleBack}/>
-                            <Button label="Launch" isLoading={this.state.isSaving} onClick={self.handleSave.bind(self, true)} className="dark"  type="submit"/>
+                            { hasAccess ? <Button label="Launch" isLoading={this.state.isSaving} onClick={self.handleSave.bind(self, true)} className="dark"  type="submit"
+                            /> : null}
                         </div>
                     }
                 </div>
@@ -148,6 +155,7 @@ class InstantiateDashboard extends React.Component {
     }
 }
 InstantiateDashboard.contextTypes = {
-    router: React.PropTypes.object
+    router: React.PropTypes.object,
+    userProfile: React.PropTypes.object
 };
 export default SkyquakeComponent(InstantiateDashboard);
index 1643926..c012309 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,12 @@ import Crouton from 'react-crouton'
 import AppHeader from 'widgets/header/header.jsx';
 import Utils from 'utils/utils.js';
 import './launchpad.scss';
+
+import {SkyquakeRBAC, isRBACValid} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx';
+import ROLES from 'utils/roleConstants.js';
+
+const PROJECT_ROLES = ROLES.PROJECT;
+
 let ReactCSSTransitionGroup = require('react-addons-css-transition-group');
 var LaunchpadFleetActions = require('./launchpadFleetActions.js');
 var LaunchpadFleetStore = require('./launchpadFleetStore.js');
@@ -91,6 +97,7 @@ export default class LaunchpadApp extends React.Component {
 
   render () {
     var self = this;
+    const hasAccess = isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN]);
     let mgmtDomainName = window.location.hash.split('/')[2];
     let navItems = [];
     if(!mgmtDomainName) {
@@ -111,14 +118,16 @@ export default class LaunchpadApp extends React.Component {
             isVisible={self.state.isNsListPanelVisible}
             />
           <NsCardPanel nsrs={self.state.nsrs}
-            openedNsrIDs={self.state.openedNsrIDs} />
+            openedNsrIDs={self.state.openedNsrIDs}
+            hasAccess={hasAccess} />
         </div>
       </div>
     );
     }
 }
 LaunchpadApp.contextTypes = {
-    router: React.PropTypes.object
+    router: React.PropTypes.object,
+    userProfile: React.PropTypes.object
 };
 LaunchpadApp.defaultProps = {
   // name: 'Loading...',
index e68a659..8154046 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -98,7 +98,7 @@ class LaunchpadCard extends React.Component {
               <img src={circleXImage} title="Close card" />
               </a>
       );
-
+      if (this.props.hasAccess) closebutton = null;
       html = (
         <DashboardCard className={'launchpadCard'} closeCard={closeButton}>
           <LaunchpadHeader nsr={this.props.nsr} name={this.props.name} isActive={this.props.isActive} id={this.props.id}/>
index d9b7182..19ccca7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,6 +61,7 @@
     }
 
     constructConfigPrimitiveTabs = (tabList, tabPanels) => {
+        const hasAccess = this.props.hasAccess;
         let mandatoryFieldValue = 'true';
         this.state.vnfrs && this.state.vnfrs.map((vnfr, vnfrIndex) => {
             if (vnfr['vnf-configuration'] && vnfr['vnf-configuration']['service-primitive'] && vnfr['vnf-configuration']['service-primitive'].length > 0) {
                                     {params}
                                 </ul>
                             </div>
-                            <button className="dark" role="button" onClick={this.handleExecuteClick.bind(this, configPrimitiveIndex, vnfrIndex)}>{configPrimitive.name}</button>
+                            {hasAccess ? <button className="dark" role="button" onClick={this.handleExecuteClick.bind(this, configPrimitiveIndex, vnfrIndex)}>{configPrimitive.name}</button> : null}
                         </TabPanel>
                     )
                 });
     }
 
     render() {
-
         let tabList = [];
         let tabPanels = [];
         let isConfiguring = (this.props.data['config-status'] && this.props.data['config-status'] != 'configured') || false;
index 2b9b4c1..5d2f536 100644 (file)
@@ -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}/>
                         );
                       }
                     }
index 88ff709..7b3cb21 100644 (file)
@@ -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 = (
             <div className="flex vnfrConfigPrimitiveContainer">
-              <VnfrConfigPrimitives data={configPrimitivesProps} />
+              <VnfrConfigPrimitives data={configPrimitivesProps} hasAccess={hasAccess} />
             {/* <NsrPrimitiveJobList jobs={cardData['config-agent-job']}/> */}
             <div style={{display:'flex', flexDirection: 'column',     flex: '1 1 40%'}}>
                 <div className="launchpadCard_title">
@@ -419,3 +425,7 @@ RecordCard.defaultProps = {
   isLoading: true,
   jobData: []
 }
+RecordCard.contextTypes = {
+    router: React.PropTypes.object,
+    userProfile: React.PropTypes.object
+};