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 * Export Selector Dialog component.
22 * @module ExportSelectorDialog
23 * @author Kiran Kashalkar <kiran.kashalkar@riftio.com>
26 import React
from 'react'
29 catalogItemExportFormats
: ['mano', 'rift'],
30 catalogItemExportGrammars
: ['osm', 'tosca']
33 export default class ExportSelectorDialog
extends React
.Component
{
37 this.state
.onCancel
= props
.onCancel
;
38 this.state
.onDownload
= props
.onDownload
;
39 this.state
.onSelectGrammar
= props
.onSelectGrammar
;
40 this.state
.onSelectFormat
= props
.onSelectFormat
;
41 this.state
.currentlySelectedFormat
= props
.currentlySelectedFormat
;
42 this.state
.currentlySelectedGrammar
= props
.currentlySelectedGrammar
;
45 selectFormat
= (format
, event
) => {
47 currentlySelectedFormat
: format
50 this.state
.onSelectFormat
.call(this, format
);
53 selectGrammar
= (grammar
, event
) => {
55 currentlySelectedGrammar
: grammar
58 this.state
.onSelectGrammar
.call(this, grammar
);
62 let dialogListElements
= [];
64 let schemaList
= defaults
.catalogItemExportFormats
.map((format
) => {
65 let classNames
= 'action Button';
66 if (format
== this.state
.currentlySelectedFormat
) {
67 classNames
+= ' primary-action';
69 classNames
+= ' secondary-action';
74 <a className
={classNames
} onClick
={this.selectFormat
.bind(this, format
)} style
={{textTransform
: 'uppercase'}}>{format
}</a
>
79 let grammarList
= defaults
.catalogItemExportGrammars
.map((grammar
) => {
80 let classNames
= 'action Button';
81 if (grammar
== this.state
.currentlySelectedGrammar
) {
82 classNames
+= ' primary-action';
84 classNames
+= ' secondary-action';
89 <a className
={classNames
} onClick
={this.selectGrammar
.bind(this, grammar
)} style
={{textTransform
: 'uppercase'}}>{grammar
}</a
>
94 dialogListElements
.push(
97 <li
>Select a descriptor schema
:</li
>
101 <li
>Select a descriptor grammar
:</li
>
107 dialogListElements
.push(
109 <a className
="action Button" onClick
={this.state
.onCancel
} style
={{textTransform
: 'capitalize', marginTop
: '4rem', float: 'right'}}>Cancel
</a
>
110 <a className
="action Button" onClick
={this.state
.onDownload
} style
={{textTransform
: 'capitalize', marginTop
: '4rem', float: 'right'}}>Download
</a
>
115 <div className
="actions panel">
116 <div className
="panel-header" style
={{minWidth
: '30rem'}}>
117 <h1
>Export Catalog Item
</h1
>
119 <div className
="panel-body">
120 <ul className
="schema-selector">