From f792671ae247a931f34d902e9276202b5016ef9a Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Sun, 7 Jul 2019 19:23:03 +0300 Subject: Merge from ecomp 718fd196 - Modern UI Issue-ID: VID-378 Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f Signed-off-by: Ittay Stern --- .../app/shared/storeUtil/utils/vnf/vnf.reducers.ts | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts') diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts index cc24d8dc3..072634f2b 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts @@ -2,7 +2,7 @@ import {Action} from "redux"; import {VnfInstance} from "../../../models/vnfInstance"; import { CreateVnfInstanceAction, - DeleteActionVnfInstanceAction, RemoveVnfInstanceAction, UndoDeleteActionVnfInstanceAction, + RemoveVnfInstanceAction, UpdateVnfInstanceAction, UpdateVnfPosition, VNFActions } from "./vnf.actions"; @@ -10,6 +10,8 @@ import * as _ from "lodash"; import {ServiceInstance} from "../../../models/serviceInstance"; import {ServiceState} from "../main.reducer"; import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; +import {deleteFirstLevel, updateServiceValidationCounter} from "../reducersHelper"; +import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions"; export function vnfReducer(state: ServiceState, action: Action): ServiceState { switch (action.type) { @@ -52,21 +54,16 @@ export function vnfReducer(state: ServiceState, action: Action): ServiceState { } case VNFActions.DELETE_ACTION_VNF_INSTANCE : { - let newState = _.cloneDeep(state); - let vnf = newState.serviceInstance[(action).serviceId].vnfs[(action).vnfStoreKey]; - let oldAction = vnf.action; - if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState; - newState.serviceInstance[(action).serviceId].vnfs[(action).vnfStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions; - updateServiceValidationCounter(newState, vnf['isMissingData'], false, (action).serviceId); - return newState; + return deleteFirstLevel(state, action,true); + } case VNFActions.UNDO_DELETE_ACTION_VNF_INSTANCE : { let newState = _.cloneDeep(state); - let vnf = newState.serviceInstance[(action).serviceId].vnfs[(action).vnfStoreKey]; + let vnf = newState.serviceInstance[(action).serviceId].vnfs[(action).storeKey]; let oldState = vnf.action; - newState.serviceInstance[(action).serviceId].vnfs[(action).vnfStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions; - updateServiceValidationCounter(newState, vnf['isMissingData'], false, (action).serviceId); + newState.serviceInstance[(action).serviceId].vnfs[(action).storeKey].action = (oldState.split('_')[0]) as ServiceInstanceActions; + updateServiceValidationCounter(newState, vnf['isMissingData'], false, (action).serviceId); return newState; } @@ -86,13 +83,7 @@ export function vnfReducer(state: ServiceState, action: Action): ServiceState { } } -const updateServiceValidationCounter = (newState: any, oldValidationState: boolean, newValidationState: boolean, serviceUuid: string) => { - if (oldValidationState && !newValidationState) { - newState.serviceInstance[serviceUuid].validationCounter--; - } else if (!oldValidationState && newValidationState) { - newState.serviceInstance[serviceUuid].validationCounter++; - } -}; + const updateUniqueNames = (oldName: string, newName: string, serviceInstance: ServiceInstance): void => { -- cgit 1.2.3-korg