aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil/utils/vnf
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-07-07 19:23:03 +0300
committerIttay Stern <ittay.stern@att.com>2019-07-08 16:13:43 +0300
commitf792671ae247a931f34d902e9276202b5016ef9a (patch)
tree6104971e8074c9a3d720836276ff18619719ec02 /vid-webpack-master/src/app/shared/storeUtil/utils/vnf
parentfc62274e8d15964d63c62bf0e2f4abc040252ee9 (diff)
Merge from ecomp 718fd196 - Modern UI
Issue-ID: VID-378 Change-Id: I2736b98426e324ec3aa233b034229ba84d99839f Signed-off-by: Ittay Stern <ittay.stern@att.com>
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 => {