nic creation issue fix 99/45199/3
authorsvishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
Tue, 8 May 2018 13:15:21 +0000 (16:15 +0300)
committerEinav Keidar <einavw@amdocs.com>
Wed, 9 May 2018 07:26:12 +0000 (07:26 +0000)
Issue-ID: SDC-1274
Change-Id: Ifd9297d3559f1b8820b0a64f063f1211b6957dd4
Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
openecomp-ui/src/nfvo-components/input/validation/Form.jsx
openecomp-ui/src/nfvo-components/loader/LoaderReducer.js
openecomp-ui/src/nfvo-components/modal/Modal.jsx
openecomp-ui/src/nfvo-utils/RestAPIUtil.js
openecomp-ui/src/nfvo-utils/json/JSONSchema.js
openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationView.jsx
openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx
openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx

index 62fc29a..b5db67c 100644 (file)
@@ -70,8 +70,8 @@ class Form extends React.Component {
         return (
             <form
                 {...formProps}
-                ref={form => (this.form = form)}
-                onSubmit={event => this.handleFormValidation(event)}>
+                ref={this.setFormRef}
+                onSubmit={this.handleFormValidation}>
                 <div className="validation-form-content">
                     <fieldset disabled={isReadOnlyMode}>{children}</fieldset>
                 </div>
@@ -80,7 +80,7 @@ class Form extends React.Component {
                         labledButtons={labledButtons}
                         submitButtonText={submitButtonText}
                         cancelButtonText={cancelButtonText}
-                        ref={buttons => (this.buttons = buttons)}
+                        ref={this.setButtonsRef}
                         isReadOnlyMode={isReadOnlyMode}
                     />
                 )}
@@ -88,14 +88,19 @@ class Form extends React.Component {
         );
     }
 
-    handleFormValidation(event) {
+    handleFormValidation = event => {
         event.preventDefault();
         if (this.props.onValidateForm && !this.props.formReady) {
             return this.props.onValidateForm();
         } else {
             return this.handleFormSubmit(event);
         }
-    }
+    };
+
+    setButtonsRef = buttons => (this.buttons = buttons);
+
+    setFormRef = form => (this.form = form);
+
     handleFormSubmit(event) {
         if (event) {
             event.preventDefault();
@@ -128,7 +133,10 @@ class Form extends React.Component {
                 this.props.onValidityChanged(this.props.isValid);
             }
         }
-        if (this.props.formReady) {
+        if (
+            this.props.formReady &&
+            this.props.formReady !== prevProps.formReady
+        ) {
             // if form validation succeeded -> continue with submit
             this.handleFormSubmit();
         }
index 1d0f679..3f9eb17 100644 (file)
@@ -26,13 +26,6 @@ export default (
             fetchingRequests++;
             newArray = state.currentlyFetching.slice();
             newArray.splice(0, 0, action.url);
-            if (DEBUG) {
-                console.log('Loader SEND REQUEST url: ' + action.url);
-                console.log(
-                    'Loader SEND REQUEST number of fetching requests: ' +
-                        fetchingRequests
-                );
-            }
             return {
                 fetchingRequests: fetchingRequests,
                 currentlyFetching: newArray,
@@ -44,13 +37,6 @@ export default (
             newArray = state.currentlyFetching.filter(item => {
                 return item !== action.url;
             });
-            if (DEBUG) {
-                console.log('Loader RECEIVE_RESPONSE url: ' + action.url);
-                console.log(
-                    'Loader RECEIVE_RESPONSE: number of fetching requests: ' +
-                        fetchingRequests
-                );
-            }
             return {
                 currentlyFetching: newArray,
                 fetchingRequests: fetchingRequests,
index cfd7575..2f70a6a 100644 (file)
@@ -1,22 +1,22 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 import React from 'react';
 import ReactDOM from 'react-dom';
 import BootstrapModal from 'react-bootstrap/lib/Modal.js';
-
+import { isEqual } from 'lodash';
 let nextModalId = 0;
 
 export default class Modal extends React.Component {
@@ -47,6 +47,18 @@ export default class Modal extends React.Component {
                 )
             );
         }
+
+        componentWillUnmount() {
+            let element = ReactDOM.findDOMNode(this);
+
+            ['wheel', 'mousewheel', 'DOMMouseScroll', 'click'].forEach(
+                eventType => element.removeEventListener(eventType)
+            );
+        }
+
+        shouldComponentUpdate(nextProps) {
+            return !isEqual(this.props, nextProps);
+        }
     };
 
     componentWillMount() {
index 6be5db7..a8b40d3 100644 (file)
@@ -79,10 +79,6 @@ function handleSuccess(responseHeaders, requestHeaders) {
 
 class RestAPIUtil {
     handleRequest(url, type, options = {}, data) {
-        if (DEBUG) {
-            console.log('axios --> Making REST call (' + type + '): ' + url);
-        }
-
         applySecurity(options, data);
 
         // TODO see ig necessary or in transformrequest funtion
index 53d288f..028d82f 100644 (file)
@@ -110,7 +110,7 @@ export default class JSONSchema {
             if (items && items.length > 0) {
                 let values = items
                     .filter(value => value)
-                    .map(value => ({ enum: value, title: value }));
+                    .map(value => ({ enum: value, title: value.toString() }));
                 enumResult = values;
             }
         }
index 88525c0..6789ba4 100644 (file)
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 import React from 'react';
 import PropTypes from 'prop-types';
@@ -20,6 +20,7 @@ import Input from 'nfvo-components/input/validation/Input.jsx';
 import Form from 'nfvo-components/input/validation/Form.jsx';
 import GridSection from 'nfvo-components/grid/GridSection.jsx';
 import GridItem from 'nfvo-components/grid/GridItem.jsx';
+import isEqual from 'lodash/isEqual.js';
 
 const NICPropType = PropTypes.shape({
     id: PropTypes.string,
@@ -35,14 +36,25 @@ class NICCreationView extends React.Component {
         onSubmit: PropTypes.func.isRequired,
         onCancel: PropTypes.func.isRequired
     };
-
+    shouldComponentUpdate(nextProps) {
+        let res = true;
+        const { data, isFormValid, formReady, genericFieldInfo } = this.props;
+        if (
+            isEqual(data, nextProps.data) &&
+            isEqual(isFormValid, nextProps.isFormValid) &&
+            formReady === nextProps.formReady &&
+            isEqual(genericFieldInfo, nextProps.genericFieldInfo)
+        ) {
+            res = false;
+        }
+        return res;
+    }
     render() {
         let {
             data = {},
             onDataChanged,
             genericFieldInfo,
             isFormValid,
-            onValidateForm,
             formReady
         } = this.props;
         let { name, description, networkDescription } = data;
@@ -50,16 +62,15 @@ class NICCreationView extends React.Component {
             <div>
                 {genericFieldInfo && (
                     <Form
-                        ref={form => (this.form = form)}
                         hasButtons={true}
-                        onSubmit={() => this.submit()}
+                        onSubmit={this.submit}
                         submitButtonText={
                             data.id ? i18n('Save') : i18n('Create')
                         }
-                        onReset={() => this.props.onCancel()}
+                        onReset={this.cancel}
                         labledButtons={true}
                         isValid={isFormValid}
-                        onValidateForm={() => onValidateForm()}
+                        onValidateForm={this.validate}
                         formReady={formReady}>
                         <GridSection hasLastColSet>
                             <GridItem colSpan={4} lastColInRow>
@@ -148,10 +159,18 @@ class NICCreationView extends React.Component {
         );
     }
 
-    submit() {
+    submit = () => {
         const { data: nic, componentId } = this.props;
         this.props.onSubmit({ nic, componentId });
-    }
+    };
+
+    validate = () => {
+        this.props.onValidateForm();
+    };
+
+    cancel = () => {
+        this.props.onCancel();
+    };
 }
 
 export default NICCreationView;
index 5a89239..634b43f 100644 (file)
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 import React from 'react';
 import PropTypes from 'prop-types';
@@ -25,8 +25,7 @@ const NameAndPurpose = ({
     genericFieldInfo,
     isReadOnlyMode,
     name,
-    description,
-    isManual
+    description
 }) => {
     return (
         <GridSection hastLastColSet>
@@ -35,7 +34,7 @@ const NameAndPurpose = ({
                     label={i18n('Name')}
                     value={name}
                     data-test-id="nic-name"
-                    disabled={!isManual}
+                    disabled={true}
                     isRequired={true}
                     onChange={name => onDataChanged({ name })}
                     isValid={genericFieldInfo['name'].isValid}
index ac7e4a8..653e0ac 100644 (file)
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 import React from 'react';
 import PropTypes from 'prop-types';
@@ -161,7 +161,9 @@ const SnapshotBackupSection = ({
                         'storage/snapshotBackup/snapshotFrequency': snapshotFrequency
                     })
                 }
-                label={i18n('Backup Storage Size (GB)')}
+                label={i18n(
+                    'ComponentQuestionnaire/storage/snapshotBackup/snapshotFrequency'
+                )}
                 type="number"
                 isValid={
                     qgenericFieldInfo[