RIFT-15726 - optimize download size -> lodash usage in UI
[osm/UI.git] / skyquake / plugins / launchpad / src / virtual_links / nsVirtualLinkCreateStore.js
index 61ebe3d..ac050e4 100644 (file)
@@ -18,7 +18,9 @@
 import NSVirtualLinkCreateActions from './nsVirtualLinkCreateActions.js';
 import NSVirtualLinkCreateSource from './nsVirtualLinkCreateSource.js';
 import Alt from '../alt';
-import _ from 'lodash';
+import _cloneDeep from 'lodash/cloneDeep';
+import _pickBy from 'lodash/pickBy';
+import _identity from 'lodash/identity';
 
 class NSVirtualLinkCreateStore {
        constructor() {
@@ -84,7 +86,8 @@ class NSVirtualLinkCreateStore {
             saveVnfdIdRefs: this.saveVnfdIdRefs,
             saveIpProfileNames: this.saveIpProfileNames,
             removeVirtualLink: this.removeVirtualLink,
-            saveMode: this.saveMode
+            saveMode: this.saveMode,
+            saveOnSuccess: this.saveOnSuccess
         });
        }
 
@@ -97,6 +100,12 @@ class NSVirtualLinkCreateStore {
                });
        }
 
+       saveOnSuccess = (onSuccess) => {
+               this.setState({
+                       onSuccess: onSuccess
+               })
+       }
+
        saveMode = (mode) => {
                this.setState({
                        mode: mode
@@ -134,7 +143,7 @@ class NSVirtualLinkCreateStore {
        }
 
        updateFirstLevelKey = (key, e) => {
-               let vld = _.cloneDeep(this.vld);
+               let vld = _cloneDeep(this.vld);
                let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
                vld[key] = value;
                this.setState({
@@ -143,7 +152,7 @@ class NSVirtualLinkCreateStore {
        }
 
        updateSecondLevelKey = (firstLevelKey, secondLevelKey, e) => {
-               let vld = _.cloneDeep(this.vld);
+               let vld = _cloneDeep(this.vld);
                if (!vld[firstLevelKey]) {
                        vld[firstLevelKey] = {};
                }
@@ -169,7 +178,7 @@ class NSVirtualLinkCreateStore {
        }
 
        updateVLDInitParamsValue = (currentVLDInitParamsType, e) => {
-               let vld = _.cloneDeep(this.vld);
+               let vld = _cloneDeep(this.vld);
                this.vldInitParamsTypes.map((vldInitParamType) => {
                        if (currentVLDInitParamsType == vldInitParamType) {
                                let value = e.target.nodeName == "SELECT" ? JSON.parse(e.target.value) : e.target.value;
@@ -185,7 +194,7 @@ class NSVirtualLinkCreateStore {
        }
 
        updateFirstLevelListKeyChange = (listName, index, keyName, e) => {
-               let vld = _.cloneDeep(this.vld);
+               let vld = _cloneDeep(this.vld);
                
 
                !vld[listName] && (vld[listName] = []);
@@ -200,7 +209,7 @@ class NSVirtualLinkCreateStore {
        addConnectionPointRef = () => {
                let vld = {};
                if (this.vld) {
-                       vld = _.cloneDeep(this.vld);
+                       vld = _cloneDeep(this.vld);
                        if (!vld['vnfd-connection-point-ref']) {
                                vld['vnfd-connection-point-ref'] = [];
                        }
@@ -217,7 +226,7 @@ class NSVirtualLinkCreateStore {
        }
 
        removeConnectionPointRef = (vnfdConnectionPointRefIndex) => {
-               let vld = _.cloneDeep(this.vld);
+               let vld = _cloneDeep(this.vld);
                vld['vnfd-connection-point-ref'].splice(vnfdConnectionPointRefIndex, 1);
                this.setState({
                        vld: vld
@@ -240,27 +249,18 @@ class NSVirtualLinkCreateStore {
        }
 
        createVirtualLinkSuccess(data) {
-               this.setState({
-                       // vld: this.vld,
-                       mode: 'editing',
-                       isLoading: false
-               });
+               this.onSuccess();
        }
        editVirtualLinkSuccess(data) {
-               this.setState({
-                       mode: 'editing',
-                       isLoading: false
-               });
+               this.onSuccess();
        }
        deleteVirtualLinkSuccess(data) {
-               this.setState({
-                       deleteState: 'success'
-               });
+               this.onSuccess();
        }
 
        cleanupPayload = (mode, vld) => {
                // Do necessary cleanup here
-               let cleanVld = _.pickBy(vld, _.identity);
+               let cleanVld = _pickBy(vld, _identity);
                return cleanVld;
        }