blob: 6ac316ed5c1e214d3d8b29a9355d9534a11b1dd6 [file] [log] [blame]
Einav Weiss Keidar1801b242018-08-13 16:19:46 +03001/*
2 * Copyright © 2016-2018 European Support Limited
AviZi280f8012017-06-09 02:39:56 +03003 *
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 *
Einav Weiss Keidar1801b242018-08-13 16:19:46 +03008 * http://www.apache.org/licenses/LICENSE-2.0
AviZi280f8012017-06-09 02:39:56 +03009 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
Einav Weiss Keidar1801b242018-08-13 16:19:46 +030012 * 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.
AviZi280f8012017-06-09 02:39:56 +030015 */
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}
Einav Weiss Keidar1801b242018-08-13 16:19:46 +030041 onValidateForm={() => onValidateForm()}
42 btnClassName="sdc-modal__footer">
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020043 <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 }
Michael Landoefa037d2017-02-19 12:57:33 +020077
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020078 onSaveClicked() {
79 let { currentFlow, onSubmit } = this.props;
80 if (onSubmit) {
81 onSubmit(currentFlow);
82 }
83 }
Michael Landoefa037d2017-02-19 12:57:33 +020084}
85
86export default FlowsEditorModalView;