aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/vnf
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils/vnf')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts23
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts17
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.ts27
3 files changed, 26 insertions, 41 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
index b84284490..25179fe2e 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.actions.ts
@@ -1,5 +1,6 @@
import {Action, ActionCreator} from "redux";
import {VnfInstance} from "../../../models/vnfInstance";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
export enum VNFActions {
CREATE_VNF_INSTANCE = "CREATE_VNF_INSTANCE",
@@ -31,18 +32,6 @@ export interface UpdateVnfInstanceAction extends Action {
vnfStoreKey?:string;
}
-
-
-export interface DeleteActionVnfInstanceAction extends Action {
- vnfStoreKey: string;
- serviceId?: string;
-}
-
-export interface UndoDeleteActionVnfInstanceAction extends Action {
- vnfStoreKey: string;
- serviceId?: string;
-}
-
export interface RemoveVnfInstanceAction extends Action {
vnfStoreKey: string;
serviceId?: string;
@@ -66,15 +55,17 @@ export const updateVNFInstance: ActionCreator<UpdateVnfInstanceAction> = (vnfIns
});
-export const deleteActionVnfInstance: ActionCreator<DeleteActionVnfInstanceAction> = (vnfStoreKey, serviceId) => ({
+export const deleteActionVnfInstance: ActionCreator<ActionOnFirstLevel> = (vnfStoreKey, serviceId) => ({
type: VNFActions.DELETE_ACTION_VNF_INSTANCE,
- vnfStoreKey: vnfStoreKey,
+ firstLevelName: 'vnfs',
+ storeKey: vnfStoreKey,
serviceId: serviceId
});
-export const undoDeleteActionVnfInstance: ActionCreator<UndoDeleteActionVnfInstanceAction> = (vnfStoreKey, serviceId) => ({
+export const undoDeleteActionVnfInstance: ActionCreator<ActionOnFirstLevel> = (vnfStoreKey, serviceId) => ({
type: VNFActions.UNDO_DELETE_ACTION_VNF_INSTANCE,
- vnfStoreKey: vnfStoreKey,
+ firstLevelName: 'vnfs',
+ storeKey: vnfStoreKey,
serviceId: serviceId
});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
index 3241f11d9..a5e37fcab 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vnf/vnf.reducers.spec.ts
@@ -1,14 +1,15 @@
import {VnfInstance} from "../../../models/vnfInstance";
import {
CreateVnfInstanceAction,
- DeleteActionVnfInstanceAction, RemoveVnfInstanceAction,
- UndoDeleteActionVnfInstanceAction, UpdateVnfPosition,
+ RemoveVnfInstanceAction,
+ UpdateVnfPosition,
VNFActions
} from "./vnf.actions";
import {vnfReducer} from "./vnf.reducers";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
-describe('networkReducer', () => {
+describe('vnfReducer', () => {
test('#UPDATE_VNF_POSITION', () => {
let vnfInstance: VnfInstance = new VnfInstance();
vnfInstance.isMissingData = false;
@@ -70,9 +71,10 @@ describe('networkReducer', () => {
}
}
}},
- <DeleteActionVnfInstanceAction>{
+ <ActionOnFirstLevel>{
type: VNFActions.DELETE_ACTION_VNF_INSTANCE,
- vnfStoreKey: 'vnfStoreKey',
+ firstLevelName: 'vnfs',
+ storeKey: 'vnfStoreKey',
serviceId: 'serviceModelId'
}).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'];
@@ -91,9 +93,10 @@ describe('networkReducer', () => {
}
}
}},
- <UndoDeleteActionVnfInstanceAction>{
+ <ActionOnFirstLevel>{
type: VNFActions.UNDO_DELETE_ACTION_VNF_INSTANCE,
- vnfStoreKey: 'vnfStoreKey',
+ storeKey: 'vnfStoreKey',
+ firstLevelName: 'vnfs',
serviceId: 'serviceModelId'
}).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'];
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[(<DeleteActionVnfInstanceAction>action).serviceId].vnfs[(<DeleteActionVnfInstanceAction>action).vnfStoreKey];
- let oldAction = vnf.action;
- if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
- newState.serviceInstance[(<DeleteActionVnfInstanceAction>action).serviceId].vnfs[(<DeleteActionVnfInstanceAction>action).vnfStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
- updateServiceValidationCounter(newState, vnf['isMissingData'], false, (<RemoveVnfInstanceAction>action).serviceId);
- return newState;
+ return deleteFirstLevel(state, <ActionOnFirstLevel>action,true);
+
}
case VNFActions.UNDO_DELETE_ACTION_VNF_INSTANCE : {
let newState = _.cloneDeep(state);
- let vnf = newState.serviceInstance[(<UndoDeleteActionVnfInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVnfInstanceAction>action).vnfStoreKey];
+ let vnf = newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId].vnfs[(<ActionOnFirstLevel>action).storeKey];
let oldState = vnf.action;
- newState.serviceInstance[(<UndoDeleteActionVnfInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVnfInstanceAction>action).vnfStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
- updateServiceValidationCounter(newState, vnf['isMissingData'], false, (<UndoDeleteActionVnfInstanceAction>action).serviceId);
+ newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId].vnfs[(<ActionOnFirstLevel>action).storeKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
+ updateServiceValidationCounter(newState, vnf['isMissingData'], false, (<ActionOnFirstLevel>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 => {