update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b third try
[osm/UI.git] / skyquake / plugins / composer / src / src / components / CatalogPanelToolbar.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
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
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 *
18 */
19 'use strict';
20
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'
26
27 import '../styles/CatalogPanelToolbar.scss'
28
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;
39
40 const CatalogHeader = React.createClass({
41 mixins: [PureRenderMixin],
42 getInitialState() {
43 return {};
44 },
45 getDefaultProps() {
46 },
47 componentWillMount() {
48 },
49 componentDidMount() {
50 },
51 componentDidUpdate() {
52 },
53 componentWillUnmount() {
54 },
55 contextTypes: {
56 userProfile: React.PropTypes.object
57 },
58 render() {
59 const disabled = !isRBACValid(this.context.userProfile, [PROJECT_ROLES.PROJECT_ADMIN, PROJECT_ROLES.CATALOG_ADMIN]);
60 return (
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}/>
68 </div>
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}/>
75 </div>
76 </div>
77 <Button type="image" title="Copy catalog item" className="action-copy-catalog-item" onClick={this.onClickDuplicateCatalogItem} src={imgCopy} disabled={disabled}/>
78 </div>
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}/>
81 </div>
82 </div>
83 </div>
84 );
85 },
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
91 },
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
97 },
98 onClickDeleteCatalogItem() {
99 CatalogItemsActions.deleteSelectedCatalogItem();
100 },
101 onClickCreateCatalogItem(type) {
102 CatalogItemsActions.createCatalogItem(type);
103 },
104 onClickDuplicateCatalogItem() {
105 CatalogPanelTrayActions.open();
106 CatalogItemsActions.duplicateSelectedCatalogItem();
107 },
108 onClickExportCatalogItems() {
109 CatalogPanelTrayActions.open();
110 CatalogItemsActions.exportSelectedCatalogItems();
111 }
112 });
113
114 export default CatalogHeader;