react 16 upgrade
[sdc.git] / openecomp-ui / src / sdc-app / flows / FlowsEditorModalView.jsx
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 import React, { Component } from 'react';
17 import i18n from 'nfvo-utils/i18n/i18n.js';
18 import Input from 'nfvo-components/input/validation/Input.jsx';
19 import Form from 'nfvo-components/input/validation/Form.jsx';
20
21 class FlowsEditorModalView extends Component {
22     render() {
23         let {
24             onCancel,
25             onDataChanged,
26             currentFlow,
27             genericFieldInfo,
28             formReady,
29             isFormValid,
30             onValidateForm
31         } = this.props;
32         let { artifactName, description } = currentFlow;
33         return (
34             <div>
35                 {genericFieldInfo && (
36                     <Form
37                         onSubmit={() => this.onSaveClicked()}
38                         onReset={onCancel}
39                         formReady={formReady}
40                         isValid={isFormValid}
41                         onValidateForm={() => onValidateForm()}
42                         btnClassName="sdc-modal__footer">
43                         <Input
44                             type="text"
45                             name="name"
46                             label={i18n('Name')}
47                             isValid={genericFieldInfo['artifactName'].isValid}
48                             errorText={
49                                 genericFieldInfo['artifactName'].errorText
50                             }
51                             isRequired={true}
52                             value={artifactName}
53                             onChange={artifactName =>
54                                 onDataChanged({ artifactName })
55                             }
56                         />
57                         <Input
58                             type="textarea"
59                             name="description"
60                             label={i18n('Description')}
61                             isValid={genericFieldInfo['description'].isValid}
62                             errorText={
63                                 genericFieldInfo['description'].errorText
64                             }
65                             isRequired={true}
66                             value={description}
67                             overlayPos="bottom"
68                             onChange={description =>
69                                 onDataChanged({ description })
70                             }
71                         />
72                     </Form>
73                 )}
74             </div>
75         );
76     }
77
78     onSaveClicked() {
79         let { currentFlow, onSubmit } = this.props;
80         if (onSubmit) {
81             onSubmit(currentFlow);
82         }
83     }
84 }
85
86 export default FlowsEditorModalView;