Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016-2018 European Support Limited |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 | * |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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, |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 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. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 15 | */ |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 16 | import React, { Component } from 'react'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 17 | import i18n from 'nfvo-utils/i18n/i18n.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | import Input from 'nfvo-components/input/validation/Input.jsx'; |
| 19 | import Form from 'nfvo-components/input/validation/Form.jsx'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 20 | |
| 21 | class FlowsEditorModalView extends Component { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 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} |
Einav Weiss Keidar | 1801b24 | 2018-08-13 16:19:46 +0300 | [diff] [blame] | 41 | onValidateForm={() => onValidateForm()} |
| 42 | btnClassName="sdc-modal__footer"> |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 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 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 77 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 78 | onSaveClicked() { |
| 79 | let { currentFlow, onSubmit } = this.props; |
| 80 | if (onSubmit) { |
| 81 | onSubmit(currentFlow); |
| 82 | } |
| 83 | } |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | export default FlowsEditorModalView; |