blob: 8c805cca9c63153834be87037fbe3ccf9ed21159 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020016import React, { Component } from 'react';
Michael Landoefa037d2017-02-19 12:57:33 +020017import i18n from 'nfvo-utils/i18n/i18n.js';
AviZi280f8012017-06-09 02:39:56 +030018import Input from 'nfvo-components/input/validation/Input.jsx';
19import Form from 'nfvo-components/input/validation/Form.jsx';
Michael Landoefa037d2017-02-19 12:57:33 +020020
21class FlowsEditorModalView extends Component {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020022 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 <Input
43 type="text"
44 name="name"
45 label={i18n('Name')}
46 isValid={genericFieldInfo['artifactName'].isValid}
47 errorText={
48 genericFieldInfo['artifactName'].errorText
49 }
50 isRequired={true}
51 value={artifactName}
52 onChange={artifactName =>
53 onDataChanged({ artifactName })
54 }
55 />
56 <Input
57 type="textarea"
58 name="description"
59 label={i18n('Description')}
60 isValid={genericFieldInfo['description'].isValid}
61 errorText={
62 genericFieldInfo['description'].errorText
63 }
64 isRequired={true}
65 value={description}
66 overlayPos="bottom"
67 onChange={description =>
68 onDataChanged({ description })
69 }
70 />
71 </Form>
72 )}
73 </div>
74 );
75 }
Michael Landoefa037d2017-02-19 12:57:33 +020076
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020077 onSaveClicked() {
78 let { currentFlow, onSubmit } = this.props;
79 if (onSubmit) {
80 onSubmit(currentFlow);
81 }
82 }
Michael Landoefa037d2017-02-19 12:57:33 +020083}
84
85export default FlowsEditorModalView;