diff options
author | 2019-07-09 14:23:37 +0000 | |
---|---|---|
committer | 2019-07-09 14:23:37 +0000 | |
commit | 58d22b526418ffeb89337fed9e20406da420bc6f (patch) | |
tree | 4357c9cfe1c92d57ac0a3f90167cade7af505b95 /vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts | |
parent | 302b02a847e7aa8ccf3ff4bc14ff8a9cf67511b0 (diff) | |
parent | 97d9f66df456ef4573047a90baa3cc3ee4bfb0b7 (diff) |
Merge changes Ib4430bf2,Icc0bdb9e,I2736b984
* changes:
Merge from ecomp 718fd196 - Ext. Services Simulator
Merge from ecomp 718fd196 - Integration Tests
Merge from ecomp 718fd196 - Modern UI
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts index bcbbea57d..a8154e856 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts @@ -2,8 +2,8 @@ import {Action} from "redux"; import * as _ from "lodash"; import {NetworkInstance} from "../../../models/networkInstance"; import { - CreateNetworkInstanceAction, DeleteActionNetworkInstanceAction, - NetworkActions, UndoDeleteActionNetworkInstanceAction, + CreateNetworkInstanceAction, + NetworkActions, UpdateNetworkCollectionFunction, UpdateNetworkInstanceAction } from "./network.actions"; @@ -11,6 +11,8 @@ import {ServiceInstance} from "../../../models/serviceInstance"; import {calculateNextUniqueModelName} from "../vnf/vnf.reducers"; import {ServiceState} from "../main.reducer"; import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; +import {deleteFirstLevel, updateServiceValidationCounter} from "../reducersHelper"; +import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions"; export function networkReducer(state: ServiceState , action: Action) : ServiceState { @@ -58,23 +60,18 @@ export function networkReducer(state: ServiceState , action: Action) : ServiceSt Object.assign(state, {'networkFunctions': networkFunctionReduxObj}); return Object.assign({}, state); } + case NetworkActions.DELETE_ACTION_NETWORK_INSTANCE : { - let newState = _.cloneDeep(state); - let network = newState.serviceInstance[(<DeleteActionNetworkInstanceAction>action).serviceId].networks[(<DeleteActionNetworkInstanceAction>action).networkStoreKey]; - let oldAction = network.action; - if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState; - newState.serviceInstance[(<DeleteActionNetworkInstanceAction>action).serviceId].networks[(<DeleteActionNetworkInstanceAction>action).networkStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions; - updateServiceValidationCounter(newState, network['isMissingData'], false , (<DeleteActionNetworkInstanceAction>action).serviceId); + return deleteFirstLevel(state, <ActionOnFirstLevel>action,true); - return newState; } case NetworkActions.UNDO_DELETE_ACTION_NETWORK_INSTANCE : { let newState = _.cloneDeep(state); - let network = newState.serviceInstance[(<UndoDeleteActionNetworkInstanceAction>action).serviceId].networks[(<UndoDeleteActionNetworkInstanceAction>action).networkStoreKey]; + let network = newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId].networks[(<ActionOnFirstLevel>action).storeKey]; let oldState = network.action; - newState.serviceInstance[(<UndoDeleteActionNetworkInstanceAction>action).serviceId].networks[(<UndoDeleteActionNetworkInstanceAction>action).networkStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions; - updateServiceValidationCounter(newState, network['isMissingData'], false , (<DeleteActionNetworkInstanceAction>action).serviceId); + newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId].networks[(<ActionOnFirstLevel>action).storeKey].action = (oldState.split('_')[0]) as ServiceInstanceActions; + updateServiceValidationCounter(newState, network['isMissingData'], false , (<ActionOnFirstLevel>action).serviceId); return newState; } } @@ -91,12 +88,5 @@ const updateUniqueNames = (oldName : string, newName : string, serviceInstance : }; -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++; - } -}; |