4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 import React
from 'react'
22 import Button
from './Button'
23 import PureRenderMixin
from 'react-addons-pure-render-mixin'
24 import CatalogPanelTrayActions
from '../actions/CatalogPanelTrayActions'
25 import CatalogItemsActions
from '../actions/CatalogItemsActions'
27 import '../styles/CatalogPanelToolbar.scss'
29 import imgAdd
from '../../../node_modules/open-iconic/svg/plus.svg'
30 import imgCopy
from '../../../node_modules/open-iconic/svg/layers.svg'
31 import imgOnboard
from '../../../node_modules/open-iconic/svg/cloud-upload.svg'
32 import imgUpdate
from '../../../node_modules/open-iconic/svg/rain.svg'
33 import imgDownload
from '../../../node_modules/open-iconic/svg/cloud-download.svg'
34 import imgDelete
from '../../../node_modules/open-iconic/svg/trash.svg'
35 import {SkyquakeRBAC
, isRBACValid
} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx';
36 import ROLES
from 'utils/roleConstants.js';
37 const PROJECT_ROLES
= ROLES
.PROJECT
;
38 const PLATFORM
= ROLES
.PLATFORM
;
40 const CatalogHeader
= React
.createClass({
41 mixins
: [PureRenderMixin
],
47 componentWillMount() {
51 componentDidUpdate() {
53 componentWillUnmount() {
56 userProfile
: React
.PropTypes
.object
59 const disabled
= !isRBACValid(this.context
.userProfile
, [PROJECT_ROLES
.CAT_ADMIN
]);
61 <div className
="CatalogPanelToolbar">
62 <h1
>Descriptor Catalogs
</h1
>
63 <div className
="btn-bar">
64 <div className
="btn-group">
65 <Button type
="image" title
="OnBoard a catalog package" className
="action-onboard-catalog-package" onClick
={this.onClickOnBoardCatalog
} src
={imgOnboard
} disabled
={disabled
}/>
66 <Button type
="image" title
="Update a catalog package" className
="action-update-catalog-package" onClick
={this.onClickUpdateCatalog
} src
={imgUpdate
} disabled
={disabled
}/>
67 <Button type
="image" title
="Export selected catalog item(s)" className
="action-export-catalog-items" onClick
={this.onClickExportCatalogItems
} src
={imgDownload
} disabled
={disabled
}/>
69 <div className
="btn-group">
70 <div className
="menu">
71 <Button type
="image" title
="Create a new catalog item" className
="action-create-catalog-item" onClick
={this.onClickCreateCatalogItem
.bind(null, 'nsd')} src
={imgAdd
} disabled
={disabled
}/>
72 <div className
="sub-menu">
73 <Button type
="image" title
="Create a new catalog item" className
="action-create-catalog-item" onClick
={this.onClickCreateCatalogItem
.bind(null, 'nsd')} src
={imgAdd
} label
="Add NSD" disabled
={disabled
}/>
74 <Button type
="image" title
="Create a new catalog item" className
="action-create-catalog-item" onClick
={this.onClickCreateCatalogItem
.bind(null, 'vnfd')} src
={imgAdd
} label
="Add VNFD" disabled
={disabled
}/>
77 <Button type
="image" title
="Copy catalog item" className
="action-copy-catalog-item" onClick
={this.onClickDuplicateCatalogItem
} src
={imgCopy
} disabled
={disabled
}/>
79 <div className
="btn-group">
80 <Button type
="image" title
="Delete catalog item" className
="action-delete-catalog-item" onClick
= {this.onClickDeleteCatalogItem
} src
={imgDelete
} disabled
={disabled
}/>
86 onClickUpdateCatalog() {
87 //CatalogPanelTrayActions.open();
88 // note CatalogPackageManagerUploadDropZone wired our btn
89 // click event to the DropZone.js configuration and will
90 // open the tray when/if files are added to the drop zone
92 onClickOnBoardCatalog() {
93 //CatalogPanelTrayActions.open();
94 // note CatalogPackageManagerUploadDropZone wired our btn
95 // click event to the DropZone.js configuration and will
96 // open the tray when/if files are added to the drop zone
98 onClickDeleteCatalogItem() {
99 CatalogItemsActions
.deleteSelectedCatalogItem();
101 onClickCreateCatalogItem(type
) {
102 CatalogItemsActions
.createCatalogItem(type
);
104 onClickDuplicateCatalogItem() {
105 CatalogPanelTrayActions
.open();
106 CatalogItemsActions
.duplicateSelectedCatalogItem();
108 onClickExportCatalogItems() {
109 CatalogPanelTrayActions
.open();
110 CatalogItemsActions
.exportSelectedCatalogItems();
114 export default CatalogHeader
;