import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import {LIMITS_FORM_NAME, selectValues} from './LimitEditorConstants.js'; import Button from 'sdc-ui/lib/react/Button.js'; import Validator from 'nfvo-utils/Validator.js'; import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; const LimitPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, metric: React.PropTypes.shape({ choice: React.PropTypes.string, other: React.PropTypes.string }), value: React.PropTypes.string, aggregationFunction: React.PropTypes.string, time: React.PropTypes.string, unit: React.PropTypes.shape({ choice: React.PropTypes.string, other: React.PropTypes.string }) }); class LimitEditor extends React.Component { static propTypes = { data: LimitPropType, limitsNames: React.PropTypes.object, isReadOnlyMode: React.PropTypes.bool, isFormValid: React.PropTypes.bool, formReady: React.PropTypes.bool, genericFieldInfo: React.PropTypes.object.isRequired, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, onValidateForm: React.PropTypes.func.isRequired, onCancel: React.PropTypes.func.isRequired }; componentDidUpdate(prevProps) { if (this.props.formReady && this.props.formReady !== prevProps.formReady) { this.submit(); } } render() { let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo, onCancel, isFormValid, formReady, onValidateForm} = this.props; let {name, description, metric, value, aggregationFunction, time, unit} = data; return (