/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
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;
if (!this.state.nsd) {
this.setState({
nsd: this.props.data.nsd
- });
+ });
}
if (!this.state.nsrId) {
if (!this.state.nsd) {
this.setState({
nsd: nextProps.data.nsd
- });
+ });
}
if (!this.state.nsrId) {
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
});
}
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})
});
}
let nsd = nsr.nsd && nsr.nsd;
nsr['decorated-vlrs'] && nsr['decorated-vlrs'].map((vlr, vlrIndex) => {
- let name = vlr.name || 'New virtual link being created';
+ let name = vlr.name || 'Undergoing virtual link operation';
let operationalStatus = vlr['operational-status'];
let vlrId = vlr['id'];
let vldId = vlr['vld-ref'];
<tr key={vlrIndex} className={selectedClassName} onClick={this.handleSelectVirtualLinkClick.bind(this, vlrId)}>
<td>{name}</td>
<td>{operationalStatus}</td>
- <td>
- <a onClick={this.handleEditVirtualLinkClick.bind(this, this.props.data.id, vlrId, vldId)}>
- <span className="oi" data-glyph="pencil" aria-hidden="true"></span>
- </a>
- <a onClick={this.handleDeleteVirtualLinkClick.bind(this, this.props.data.id, vldId)}>
- <span className="oi" data-glyph="trash" aria-hidden="true"></span>
- </a>
- </td>
+ {
+ isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ?
+ <td>
+ <a onClick={this.handleEditVirtualLinkClick.bind(this, this.props.data.id, vlrId, vldId)}>
+ <span className="oi" data-glyph="pencil" aria-hidden="true"></span>
+ </a>
+ <a onClick={this.handleDeleteVirtualLinkClick.bind(this, this.props.data.id, vldId)}>
+ <span className="oi" data-glyph="trash" aria-hidden="true"></span>
+ </a>
+ </td>
+ : null
+ }
</tr>
);
});
<tr>
<th style={{width: '50%'}}>Name</th>
<th style={{width: '35%'}}>Status</th>
- <th style={{width: '15%'}}> </th>
+ {
+ isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ?
+ <th style={{width: '15%'}}> </th> : null
+ }
</tr>
</thead>
{tbody}
<div className="launchpadCard_title" style={{textAlign:'right'}}><span style={{float:'left'}}>VLD DETAILS</span>
</div>
{
- <NSVirtualLinkCreate vld={this.state.editingVirtualLink} mode={this.state.mode} nsd={this.state.nsd} nsrId={this.state.nsrId} onCancel={this.handleCancelCreate}/>
+ <NSVirtualLinkCreate vld={this.state.editingVirtualLink} mode={this.state.mode} nsd={this.state.nsd} nsrId={this.state.nsrId} onSuccess={this.resetState.bind(this)} onCancel={this.handleCancelCreate}/>
}
</div>
);
{nsVirtualLinksTable}
</div>
<div className='nsVirtualLinksCreateButtonWrapper'>
- {nsVirtualLinkCreateButton}
+ { isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]) ? nsVirtualLinkCreateButton : null}
</div>
</div>
{nsVirtualLinkDetails}
);
}
}
-export default SkyquakeComponent(NsVirtualLinks);
\ No newline at end of file
+export default SkyquakeComponent(NsVirtualLinks);