import React from 'react'; import PropTypes from 'prop-types'; 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 'onap-ui-react'; 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 = PropTypes.shape({ id: PropTypes.string, name: PropTypes.string, description: PropTypes.string, metric: PropTypes.shape({ choice: PropTypes.string, other: PropTypes.string }), value: PropTypes.string, aggregationFunction: PropTypes.string, time: PropTypes.string, unit: PropTypes.shape({ choice: PropTypes.string, other: PropTypes.string }) }); class LimitEditor extends React.Component { static propTypes = { data: LimitPropType, limitsNames: PropTypes.object, isReadOnlyMode: PropTypes.bool, isFormValid: PropTypes.bool, formReady: PropTypes.bool, genericFieldInfo: PropTypes.object.isRequired, onDataChanged: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired, onValidateForm: PropTypes.func.isRequired, onCancel: 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 (