aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/storeUtil
diff options
context:
space:
mode:
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil')
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.actions.ts21
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.spec.ts56
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.ts23
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/firstLevel/firstLevel.actions.ts8
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts10
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts73
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts102
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts62
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts16
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.actions.ts33
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.spec.ts64
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.ts26
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/network/network.actions.ts20
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.spec.ts14
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.ts28
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts25
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts2
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.spec.ts74
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.ts6
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts8
-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
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.actions.ts84
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.spec.ts152
-rw-r--r--vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.ts90
26 files changed, 937 insertions, 127 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.actions.ts
new file mode 100644
index 000000000..428a309d7
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.actions.ts
@@ -0,0 +1,21 @@
+import {Action, ActionCreator} from "redux";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
+
+export enum CrActions{
+ DELETE_ACTION_CR_INSTANCE = "DELETE_ACTION_CR_INSTANCE",
+ UNDO_DELETE_ACTION_CR_INSTANCE = "UNDO_DELETE_ACTION_CR_INSTANCE"
+}
+
+export const deleteActionCrInstance: ActionCreator<ActionOnFirstLevel> = (collectionResourceStoreKey, serviceId) => ({
+ type: CrActions.DELETE_ACTION_CR_INSTANCE,
+ firstLevelName: 'collectionResources',
+ storeKey: collectionResourceStoreKey,
+ serviceId: serviceId
+});
+
+export const undoDeleteActionCrInstance: ActionCreator<ActionOnFirstLevel> = (collectionResourceStoreKey, serviceId) => ({
+ type: CrActions.UNDO_DELETE_ACTION_CR_INSTANCE,
+ firstLevelName: 'collectionResources',
+ storeKey: collectionResourceStoreKey,
+ serviceId: serviceId
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.spec.ts
new file mode 100644
index 000000000..e457cf9dc
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.spec.ts
@@ -0,0 +1,56 @@
+
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import { crReducer} from "./cr.reducer";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
+import {CrActions} from "./cr.actions";
+describe('crReducer', () => {
+
+ test('#DELETE_ACTION_CR_INSTANCE', () => {
+ let crState = crReducer(<any>{
+ serviceInstance: {
+ 'serviceModelId': {
+ collectionResources: {
+ 'crStoreKey': {
+ isMissingData: true,
+ action: 'None'
+ }
+ }
+ }
+ }
+ },
+ <ActionOnFirstLevel>{
+ type: CrActions.DELETE_ACTION_CR_INSTANCE,
+ storeKey: 'crStoreKey',
+ firstLevelName: 'collectionResources',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId']['collectionResources']['crStoreKey'];
+
+ expect(crState).toBeDefined();
+ expect(crState.action).toEqual(ServiceInstanceActions.None_Delete);
+ });
+
+ test('#UNDO_DELETE_ACTION_CR_INSTANCE', () => {
+ let crState = crReducer(<any>{
+ serviceInstance: {
+ 'serviceModelId': {
+ collectionResources: {
+ 'crStoreKey': {
+ isMissingData: true,
+ action: 'Update_Delete'
+ }
+ }
+ }
+ }
+ },
+ <ActionOnFirstLevel>{
+ type: CrActions.UNDO_DELETE_ACTION_CR_INSTANCE,
+ storeKey: 'crStoreKey',
+ firstLevelName: 'collectionResources',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId']['collectionResources']['crStoreKey'];
+
+ expect(crState).toBeDefined();
+ expect(crState.action).toEqual(ServiceInstanceActions.Update);
+ });
+
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.ts
new file mode 100644
index 000000000..72894e6f0
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/cr/cr.reducer.ts
@@ -0,0 +1,23 @@
+import {ServiceState} from "../main.reducer";
+import {Action} from "redux";
+import * as _ from "lodash";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {CrActions} from "./cr.actions";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
+import {deleteFirstLevel} from "../reducersHelper";
+
+export function crReducer(state: ServiceState, action: Action): ServiceState {
+ switch (action.type) {
+ case CrActions.DELETE_ACTION_CR_INSTANCE : {
+ return deleteFirstLevel(state, <ActionOnFirstLevel>action, false);
+ }
+
+ case CrActions.UNDO_DELETE_ACTION_CR_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let vnf = newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId]['collectionResources'][(<ActionOnFirstLevel>action).storeKey];
+ let oldState = vnf.action;
+ newState.serviceInstance[(<ActionOnFirstLevel>action).serviceId]['collectionResources'][(<ActionOnFirstLevel>action).storeKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
+ return newState;
+ }
+ }
+ }
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/firstLevel/firstLevel.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/firstLevel/firstLevel.actions.ts
new file mode 100644
index 000000000..a4ca9ffdb
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/firstLevel/firstLevel.actions.ts
@@ -0,0 +1,8 @@
+import {Action} from "redux";
+
+export interface ActionOnFirstLevel extends Action {
+ type: string;
+ firstLevelName: string;
+ storeKey : string;
+ serviceId? : string;
+}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
index 8ee47331f..5b265dbfd 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/general/general.reducers.ts
@@ -12,6 +12,7 @@ import * as _ from "lodash";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import {ServiceInstance} from "../../../models/serviceInstance";
import {ServiceState} from "../main.reducer";
+import {updateServiceValidationCounter} from "../reducersHelper";
export function generalReducer(state: ServiceState, action: Action) : ServiceState {
switch (action.type) {
@@ -90,6 +91,8 @@ export function generalReducer(state: ServiceState, action: Action) : ServiceSta
newState.serviceInstance[serviceId][typeNodeInformation.hierarchyName] = Object.assign({}, newState.serviceInstance[serviceId][typeNodeInformation.hierarchyName], objects);
return newState;
}
+
+
}
}
@@ -135,13 +138,6 @@ const updateIsMissingDataOnDeleteVFModule = (state: any, serviceModelId: string,
});
};
-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++;
- }
-};
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts
index 609ec69f4..4af0243e6 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.actions.ts
@@ -3,7 +3,15 @@ import {Action, ActionCreator} from "redux";
export enum GlobalActions {
UPDATE_NAME = 'UPDATE_NAME',
UPDATE_FLAGS = 'UPDATE_FLAGS',
- UPDATE_DRAWING_BOARD_STATUS = 'UPDATE_DRAWING_BOARD_STATUS'
+ UPDATE_DRAWING_BOARD_STATUS = 'UPDATE_DRAWING_BOARD_STATUS',
+ UPDATE_GENERIC_MODAL_CRITERIA = 'UPDATE_GENERIC_MODAL_CRITERIA',
+ UPDATE_GENERIC_MODAL_HELPER = 'UPDATE_GENERIC_MODAL_HELPER',
+ DELETE_GENERIC_MODAL_HELPER = 'DELETE_GENERIC_MODAL_HELPER',
+ CLEAR_ALL_GENERIC_MODAL_HELPER = 'CLEAR_ALL_GENERIC_MODAL_HELPER',
+ UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER = 'UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER',
+ DELETE_GENERIC_MODAL_TABLE_DATA_HELPER = 'DELETE_GENERIC_MODAL_TABLE_DATA_HELPER',
+ UPDATE_GENERIC_CURRNT_VRF_HELPER = 'UPDATE_GENERIC_CURRNT_VRF_HELPER',
+ DELETE_GENERIC_CURRNT_VRF_HELPER = 'DELETE_GENERIC_CURRNT_VRF_HELPER'
}
export interface UpdateGlobalAction extends Action {
@@ -18,6 +26,33 @@ export interface UpdateDrawingBoardStatusAction extends Action{
drawingBoardStatus?: any;
}
+export interface UpdateGenericModalCriteria extends Action {
+ field: any;
+ values: any;
+}
+
+export interface UpdateGenericModalTableDataHelper extends Action {
+ field: any;
+ values: any;
+}
+export interface UpdateGenericModalHelper extends Action {
+ field: any;
+ values: any;
+ uniqObjectField : string;
+}
+
+export interface DeleteGenericModalHelper extends Action {
+ field: any;
+ uniqObjectField : string;
+}
+
+export interface DeleteGenericModalTabelDataHelper extends Action {
+ field: any;
+}
+
+
+export interface ClearGenericModalHelper extends Action {}
+
export const updateName: ActionCreator<UpdateGlobalAction> =
(name) => ({
type: GlobalActions.UPDATE_NAME,
@@ -35,3 +70,39 @@ export const updateDrawingBoardStatus: ActionCreator<UpdateDrawingBoardStatusAct
type: GlobalActions.UPDATE_DRAWING_BOARD_STATUS,
drawingBoardStatus: drawingBoardStatus
});
+
+
+export const updateGenericModalCriteria: ActionCreator<UpdateGenericModalCriteria> = (field, values) => ({
+ type : GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA,
+ field: field,
+ values: values
+});
+
+export const updateGenericModalhelper: ActionCreator<UpdateGenericModalHelper> = (field, values, uniqObjectField) => ({
+ type : GlobalActions.UPDATE_GENERIC_MODAL_HELPER,
+ field: field,
+ values: values,
+ uniqObjectField : uniqObjectField
+});
+
+export const deleteGenericModalhelper: ActionCreator<DeleteGenericModalHelper> = (field, uniqObjectField) => ({
+ type : GlobalActions.DELETE_GENERIC_MODAL_HELPER,
+ field: field,
+ uniqObjectField : uniqObjectField
+});
+
+
+export const updateGenericModalTableDataHelper: ActionCreator<UpdateGenericModalTableDataHelper> = (field, values) => ({
+ type : GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER,
+ field: field,
+ values: values,
+});
+
+export const deleteGenericModalTableDataHelper: ActionCreator<DeleteGenericModalTabelDataHelper> = (field) => ({
+ type : GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER,
+ field: field,
+});
+
+export const clearAllGenericModalhelper: ActionCreator<ClearGenericModalHelper> = (field, uniqObjectField) => ({
+ type : GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts
index 4fc80863a..c8aecdd57 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.spec.ts
@@ -1,4 +1,14 @@
-import {GlobalActions, UpdateFlagsAction, UpdateGlobalAction, UpdateDrawingBoardStatusAction} from "./global.actions";
+import {
+ GlobalActions,
+ UpdateFlagsAction,
+ UpdateGlobalAction,
+ UpdateDrawingBoardStatusAction,
+ UpdateGenericModalCriteria,
+ UpdateGenericModalHelper,
+ DeleteGenericModalHelper,
+ ClearGenericModalHelper,
+ UpdateGenericModalTableDataHelper
+} from "./global.actions";
import {globalReducer} from "./global.reducers";
@@ -42,6 +52,96 @@ describe('globalReducer', () => {
expect(globalDrawingBoardState).toBeDefined();
expect(globalDrawingBoardState.drawingBoardStatus).toEqual(drawingBoardStatus);
});
+
+ test('#UPDATE_GENERIC_MODAL_CRITERIA : should update updateGenericModalCriteria object', ()=> {
+ const values = ["value1", "value2"];
+ const fieldName = "someFieldName";
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalCriteria : {}},
+ <UpdateGenericModalCriteria>{
+ type: GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA,
+ field : fieldName,
+ values : values
+ });
+ expect(globalDrawingBoardState).toBeDefined();
+ expect(globalDrawingBoardState.genericModalCriteria[fieldName]).toEqual(values);
+ });
+
+ test('#UPDATE_GENERIC_MODAL_HELPER : should update updateGenericModalHelper object', ()=> {
+ const uniqObjectField = "uniqObjectField";
+ const values = {name : "value1", uniqObjectField: uniqObjectField};
+ const fieldName = "someFieldName";
+
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : {}},
+ <UpdateGenericModalHelper>{
+ type: GlobalActions.UPDATE_GENERIC_MODAL_HELPER,
+ field : fieldName,
+ values : values,
+ uniqObjectField : uniqObjectField
+ });
+ expect(globalDrawingBoardState).toBeDefined();
+ expect(globalDrawingBoardState.genericModalHelper[fieldName][uniqObjectField]).toEqual({"name": "value1", "uniqObjectField": "uniqObjectField"});
+ });
+
+ test('#DELETE_GENERIC_MODAL_HELPER : should delete exist ', ()=> {
+ const uniqObjectField = "uniqObjectField";
+ const fieldName = "someFieldName";
+
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : {
+ "someFieldName" : {
+ "uniqObjectField" : true
+ }
+ }},
+ <DeleteGenericModalHelper>{
+ type: GlobalActions.DELETE_GENERIC_MODAL_HELPER,
+ field : fieldName,
+ uniqObjectField : uniqObjectField
+ });
+ expect(globalDrawingBoardState).toBeDefined();
+ expect(globalDrawingBoardState.genericModalHelper[fieldName][uniqObjectField]).toBeUndefined();
+ });
+
+ test('#CLEAR_ALL_GENERIC_MODAL_HELPER : should clear generic modal object', ()=> {
+
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : {
+ "someFieldName" : {
+ "uniqObjectField" : true
+ }
+ }},
+ <ClearGenericModalHelper>{
+ type: GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER
+ });
+ expect(globalDrawingBoardState.genericModalHelper).toEqual({});
+ });
+
+ test('#UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER : should update table data with some values', ()=> {
+ const keyName: string = 'VPN_DATA';
+ const someValue: string = 'SOME_VALUE';
+
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : {
+
+ }},
+ <UpdateGenericModalTableDataHelper>{
+ type: GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER,
+ field : keyName,
+ values : someValue
+ });
+ expect(globalDrawingBoardState.genericModalHelper[keyName]).toEqual(someValue);
+ });
+
+ test('#DELETE_GENERIC_MODAL_TABLE_DATA_HELPER : should delete table data', ()=> {
+ const keyName: string = 'VPN_DATA';
+ const someValue: string = 'SOME_VALUE';
+
+ let globalDrawingBoardState = globalReducer(<any>{global : {},genericModalHelper : {
+ [keyName] : someValue
+ }},
+ <UpdateGenericModalTableDataHelper>{
+ type: GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER,
+ field : keyName
+ });
+ expect(globalDrawingBoardState.genericModalHelper[keyName]).toBeUndefined();
+ });
+
});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts
index f9e083414..aedcce24b 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/global/global.reducers.ts
@@ -1,16 +1,34 @@
import {Action} from 'redux';
-import {GlobalActions, UpdateFlagsAction, UpdateGlobalAction, UpdateDrawingBoardStatusAction} from "./global.actions";
+import {
+ GlobalActions,
+ UpdateFlagsAction,
+ UpdateGlobalAction,
+ UpdateDrawingBoardStatusAction,
+ UpdateGenericModalCriteria,
+ UpdateGenericModalHelper,
+ DeleteGenericModalHelper,
+ DeleteGenericModalTabelDataHelper,
+ UpdateGenericModalTableDataHelper
+} from "./global.actions";
+import * as _ from "lodash";
export interface GlobalState {
name : string;
flags : { [key: string]: boolean };
drawingBoardStatus : string;
+ genericModalCriteria : { [key: string]: any };
+ genericModalHelper : { [key: string]: any };
+
}
const initialState: GlobalState = {
name : null,
flags : null,
- drawingBoardStatus : null
+ drawingBoardStatus : null,
+ genericModalCriteria : {
+ roles : []
+ },
+ genericModalHelper : {}
};
export const globalReducer =
@@ -23,6 +41,46 @@ export const globalReducer =
return Object.assign({}, state);
case GlobalActions.UPDATE_DRAWING_BOARD_STATUS:
return Object.assign(state, state, (<UpdateDrawingBoardStatusAction>action));
+ case GlobalActions.UPDATE_GENERIC_MODAL_CRITERIA : {
+ const updateGenericModalCriteria = <UpdateGenericModalCriteria>action;
+ let newState = _.cloneDeep(state);
+ if(_.isNil(newState.genericModalCriteria)){
+ newState.genericModalCriteria = {};
+ }
+ newState.genericModalCriteria[updateGenericModalCriteria.field] = updateGenericModalCriteria.values;
+ return newState;
+ }
+ case GlobalActions.UPDATE_GENERIC_MODAL_HELPER : {
+ const updateGenericModalHelper= <UpdateGenericModalHelper>action;
+ let newState = _.cloneDeep(state);
+ if(_.isNil(newState.genericModalHelper) ){newState.genericModalHelper = {}; }
+ if(_.isNil(newState.genericModalHelper[updateGenericModalHelper.field])){
+ newState.genericModalHelper[updateGenericModalHelper.field] = {};
+ }
+ newState.genericModalHelper[updateGenericModalHelper.field][updateGenericModalHelper.values[updateGenericModalHelper.uniqObjectField]] = updateGenericModalHelper.values;
+ return newState;
+ }
+ case GlobalActions.DELETE_GENERIC_MODAL_HELPER : {
+ const deleteGenericModalHelper= <DeleteGenericModalHelper>action;
+ let newState = _.cloneDeep(state);
+ delete newState.genericModalHelper[deleteGenericModalHelper.field][deleteGenericModalHelper.uniqObjectField];
+ return newState;
+ }
+ case GlobalActions.CLEAR_ALL_GENERIC_MODAL_HELPER : {
+ let newState = _.cloneDeep(state);
+ newState.genericModalHelper = {};
+ return newState;
+ }
+ case GlobalActions.DELETE_GENERIC_MODAL_TABLE_DATA_HELPER : {
+ let newState = _.cloneDeep(state);
+ delete newState.genericModalHelper[(<DeleteGenericModalTabelDataHelper>action).field];
+ return newState;
+ }
+ case GlobalActions.UPDATE_GENERIC_MODAL_TABLE_DATA_HELPER : {
+ let newState = _.cloneDeep(state);
+ newState.genericModalHelper[(<UpdateGenericModalTableDataHelper>action).field] = (<UpdateGenericModalTableDataHelper>action).values ;
+ return newState;
+ }
default:
return state;
}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
index 2166c81a0..c02049eb9 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/main.reducer.ts
@@ -18,6 +18,12 @@ import {VnfGroupActions} from "./vnfGroup/vnfGroup.actions";
import {vnfGroupReducer} from "./vnfGroup/vnfGroup.reducers";
import {RelatedVnfActions} from "./relatedVnfMember/relatedVnfMember.actions";
import {relatedVnfMemeberReducer} from "./relatedVnfMember/relatedVnfMember.reducers";
+import {VrfActions} from "./vrf/vrf.actions";
+import {vrfReducer} from "./vrf/vrf.reducer";
+import {CrActions} from "./cr/cr.actions";
+import {crReducer} from "./cr/cr.reducer";
+import {NcfActions} from "./ncf/ncf.actions";
+import {ncfReducer} from "./ncf/ncf.reducer";
export let initialState: ServiceState = {
serviceHierarchy: {},
@@ -27,7 +33,8 @@ export let initialState: ServiceState = {
productFamilies: null,
serviceTypes: {},
aicZones: null,
- categoryParameters: new CategoryParams()
+ categoryParameters: new CategoryParams(),
+ genericModalCriteria : {}
};
@@ -40,6 +47,7 @@ export interface ServiceState {
serviceTypes: { [subscriberId: string]: ServiceType[]; };
aicZones: SelectOptionInterface[];
categoryParameters: CategoryParams;
+ genericModalCriteria : { [field: string]: any; }
}
export const MainReducer = function (state: ServiceState = initialState, action: Action): ServiceState {
@@ -58,6 +66,12 @@ export const MainReducer = function (state: ServiceState = initialState, action:
return vnfGroupReducer(state, action);
}else if(Object.values(RelatedVnfActions).includes(action.type)){
return relatedVnfMemeberReducer(state, action);
+ }else if(Object.values(VrfActions).includes(action.type)) {
+ return vrfReducer(state, action);
+ }else if(Object.values(CrActions).includes(action.type)){
+ return crReducer(state, action);
+ }else if(Object.values(NcfActions).includes(action.type)){
+ return ncfReducer(state, action);
} else {
return Object.assign({}, state);
}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.actions.ts
new file mode 100644
index 000000000..00b5d9f02
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.actions.ts
@@ -0,0 +1,33 @@
+import {Action, ActionCreator} from "redux";
+
+export enum NcfActions{
+ DELETE_ACTION_NCF_INSTANCE = "DELETE_ACTION_NCF_INSTANCE",
+ UNDO_DELETE_ACTION_NCF_INSTANCE = "UNDO_DELETE_ACTION_NCF_INSTANCE"
+
+}
+export interface DeleteActionNcfInstanceAction extends Action {
+ collectionResourceStoreKey: string,
+ ncfStoreKey : string;
+ serviceId : string;
+}
+
+export interface UndoDeleteActionNcfInstanceAction extends Action {
+ collectionResourceStoreKey: string,
+ ncfStoreKey: string;
+ serviceId?: string;
+}
+
+
+export const deleteActionNcfInstance: ActionCreator<DeleteActionNcfInstanceAction> = (collectionResourceStoreKey, ncfStoreKey, serviceId) => ({
+ type: NcfActions.DELETE_ACTION_NCF_INSTANCE,
+ collectionResourceStoreKey: collectionResourceStoreKey,
+ ncfStoreKey: ncfStoreKey,
+ serviceId: serviceId
+});
+
+export const undoDeleteActionNcfInstance: ActionCreator<UndoDeleteActionNcfInstanceAction> = (collectionResourceStoreKey, ncfStoreKey, serviceId) => ({
+ type: NcfActions.UNDO_DELETE_ACTION_NCF_INSTANCE,
+ collectionResourceStoreKey: collectionResourceStoreKey,
+ ncfStoreKey: ncfStoreKey,
+ serviceId: serviceId
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.spec.ts
new file mode 100644
index 000000000..ac7ab7419
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.spec.ts
@@ -0,0 +1,64 @@
+
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {ncfReducer} from "./ncf.reducer";
+import {DeleteActionNcfInstanceAction, NcfActions, UndoDeleteActionNcfInstanceAction} from "./ncf.actions";
+describe('ncfReducer', () => {
+
+ test('#DELETE_ACTION_NCF_INSTANCE', () => {
+ let ncfState = ncfReducer(<any>{
+ serviceInstance: {
+ 'serviceModelId': {
+ collectionResources: {
+ 'collectionResourceStoreKey': {
+ ncfs: {
+ 'ncfStoreKey': {
+ isMissingData: true,
+ action: 'None'
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ <DeleteActionNcfInstanceAction>{
+ type: NcfActions.DELETE_ACTION_NCF_INSTANCE,
+ collectionResourceStoreKey: 'collectionResourceStoreKey',
+ ncfStoreKey: 'ncfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId']['collectionResources']['collectionResourceStoreKey']['ncfs']['ncfStoreKey'];
+
+ expect(ncfState).toBeDefined();
+ expect(ncfState.action).toEqual(ServiceInstanceActions.None_Delete);
+ });
+
+ test('#UNDO_DELETE_ACTION_NCF_INSTANCE', () => {
+ let ncfState = ncfReducer(<any>{
+ serviceInstance: {
+ 'serviceModelId': {
+ collectionResources: {
+ 'collectionResourceStoreKey': {
+ ncfs: {
+ 'ncfStoreKey': {
+ isMissingData: true,
+ action: 'Update_Delete'
+ }
+ }
+ }
+
+ }
+ }
+ }
+ },
+ <UndoDeleteActionNcfInstanceAction>{
+ type: NcfActions.UNDO_DELETE_ACTION_NCF_INSTANCE,
+ collectionResourceStoreKey: 'collectionResourceStoreKey',
+ ncfStoreKey: 'ncfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId']['collectionResources']['collectionResourceStoreKey']['ncfs']['ncfStoreKey'];
+
+ expect(ncfState).toBeDefined();
+ expect(ncfState.action).toEqual(ServiceInstanceActions.Update);
+ });
+
+});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.ts
new file mode 100644
index 000000000..9bb069e0d
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/ncf/ncf.reducer.ts
@@ -0,0 +1,26 @@
+import {ServiceState} from "../main.reducer";
+import {Action} from "redux";
+import * as _ from "lodash";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {NcfActions, DeleteActionNcfInstanceAction, UndoDeleteActionNcfInstanceAction} from "./ncf.actions";
+
+export function ncfReducer(state: ServiceState, action: Action): ServiceState {
+ switch (action.type) {
+ case NcfActions.DELETE_ACTION_NCF_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let ncf = newState.serviceInstance[(<DeleteActionNcfInstanceAction>action).serviceId]['collectionResources'][(<DeleteActionNcfInstanceAction>action).collectionResourceStoreKey]['ncfs'][(<DeleteActionNcfInstanceAction>action).ncfStoreKey];
+ let oldAction = ncf.action;
+ if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ newState.serviceInstance[(<DeleteActionNcfInstanceAction>action).serviceId]['collectionResources'][(<DeleteActionNcfInstanceAction>action).collectionResourceStoreKey]['ncfs'][(<DeleteActionNcfInstanceAction>action).ncfStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ return newState;
+ }
+
+ case NcfActions.UNDO_DELETE_ACTION_NCF_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let ncf = newState.serviceInstance[(<UndoDeleteActionNcfInstanceAction>action).serviceId]['collectionResources'][(<DeleteActionNcfInstanceAction>action).collectionResourceStoreKey]['ncfs'][(<UndoDeleteActionNcfInstanceAction>action).ncfStoreKey];
+ let oldState = ncf.action;
+ newState.serviceInstance[(<UndoDeleteActionNcfInstanceAction>action).serviceId]['collectionResources'][(<DeleteActionNcfInstanceAction>action).collectionResourceStoreKey]['ncfs'][(<UndoDeleteActionNcfInstanceAction>action).ncfStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
+ return newState;
+ }
+ }
+}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.actions.ts
index c90d8eb3d..50bb98ee3 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.actions.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.actions.ts
@@ -1,5 +1,7 @@
import {Action, ActionCreator} from "redux";
import {NetworkInstance} from "../../../models/networkInstance";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
+
export enum NetworkActions {
UPDATE_NETWORK_INSTANCE = "UPDATE_NETWORK_INSTANCE",
@@ -37,15 +39,7 @@ export interface CreateNetworkInstanceAction extends Action {
networkStoreKey?:string;
}
-export interface DeleteActionNetworkInstanceAction extends Action {
- networkStoreKey: string;
- serviceId?: string;
-}
-export interface UndoDeleteActionNetworkInstanceAction extends Action {
- networkStoreKey: string;
- serviceId?: string;
-}
export const updateNetworkInstance: ActionCreator<UpdateNetworkInstanceAction> = (networkInstance, networkfModelName, serviceUuid, networkStoreKey) => ({
type: NetworkActions.UPDATE_NETWORK_INSTANCE,
@@ -71,15 +65,17 @@ export const createNetworkInstance: ActionCreator<CreateNetworkInstanceAction> =
});
-export const deleteActionNetworkInstance: ActionCreator<DeleteActionNetworkInstanceAction> = (networkStoreKey, serviceId) => ({
+export const deleteActionNetworkInstance: ActionCreator<ActionOnFirstLevel> = (networkStoreKey, serviceId) => ({
type: NetworkActions.DELETE_ACTION_NETWORK_INSTANCE,
- networkStoreKey: networkStoreKey,
+ firstLevelName: 'networks',
+ storeKey: networkStoreKey,
serviceId: serviceId
});
-export const undoDeleteActionNetworkInstance: ActionCreator<UndoDeleteActionNetworkInstanceAction> = (networkStoreKey, serviceId) => ({
+export const undoDeleteActionNetworkInstance: ActionCreator<ActionOnFirstLevel> = (networkStoreKey, serviceId) => ({
type: NetworkActions.UNDO_DELETE_ACTION_NETWORK_INSTANCE,
- networkStoreKey: networkStoreKey,
+ firstLevelName: 'networks',
+ storeKey: networkStoreKey,
serviceId: serviceId
});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.spec.ts
index ba41ad6e6..7bf37fa0e 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/network/network.reducers.spec.ts
@@ -1,12 +1,13 @@
import {networkReducer} from "./network.reducers";
import {
- CreateNetworkInstanceAction, DeleteActionNetworkInstanceAction,
- NetworkActions, UndoDeleteActionNetworkInstanceAction,
+ CreateNetworkInstanceAction,
+ NetworkActions,
UpdateNetworkCollectionFunction,
UpdateNetworkInstanceAction
} from "./network.actions";
import {NetworkInstance} from "../../../models/networkInstance";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {ActionOnFirstLevel} from "../firstLevel/firstLevel.actions";
describe('networkReducer', () => {
@@ -78,9 +79,10 @@ describe('networkReducer', () => {
}
}
}},
- <DeleteActionNetworkInstanceAction>{
+ <ActionOnFirstLevel>{
type: NetworkActions.DELETE_ACTION_NETWORK_INSTANCE,
- networkStoreKey: 'networkStoreKey',
+ firstLevelName: 'networks',
+ storeKey: 'networkStoreKey',
serviceId: 'serviceModelId'
}).serviceInstance['serviceModelId'].networks['networkStoreKey'];
@@ -99,9 +101,9 @@ describe('networkReducer', () => {
}
}
}},
- <UndoDeleteActionNetworkInstanceAction>{
+ <ActionOnFirstLevel>{
type: NetworkActions.UNDO_DELETE_ACTION_NETWORK_INSTANCE,
- networkStoreKey: 'networkStoreKey',
+ storeKey: 'networkStoreKey',
serviceId: 'serviceModelId'
}).serviceInstance['serviceModelId'].networks['networkStoreKey'];
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++;
- }
-};
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
new file mode 100644
index 000000000..5722811ce
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/reducersHelper.ts
@@ -0,0 +1,25 @@
+import * as _ from "lodash";
+import {ActionOnFirstLevel} from "./firstLevel/firstLevel.actions";
+import {ServiceInstanceActions} from "../../models/serviceInstanceActions";
+import {ServiceState} from "./main.reducer";
+
+export function deleteFirstLevel(state: ServiceState, action: ActionOnFirstLevel,shouldUpdateServiceValidationCounter: boolean)
+{
+ let newState = _.cloneDeep(state);
+ let firstLevel = newState.serviceInstance[action.serviceId][action.firstLevelName][action.storeKey];
+ let oldAction = firstLevel.action;
+ if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ if (shouldUpdateServiceValidationCounter){
+ updateServiceValidationCounter(newState, firstLevel['isMissingData'], false, action.serviceId);
+ }
+ newState.serviceInstance[action.serviceId][action.firstLevelName][action.storeKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ return newState;
+}
+
+export function updateServiceValidationCounter(newState: any, oldValidationState: boolean, newValidationState: boolean, serviceUuid: string) {
+ if (oldValidationState && !newValidationState) {
+ newState.serviceInstance[serviceUuid].validationCounter--;
+ } else if (!oldValidationState && newValidationState) {
+ newState.serviceInstance[serviceUuid].validationCounter++;
+ }
+};
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
index 347957480..30ad016f7 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/relatedVnfMember/relatedVnfMember.reducers.spec.ts
@@ -105,7 +105,7 @@ describe('relatedVnfMemberReducer', () => {
"instanceId":"VNF1_INSTANCE_ID",
"orchStatus":null,
"productFamilyId":null,
- "lcpCloudRegionId":"mtn23b",
+ "lcpCloudRegionId":"hvf23b",
"tenantId":"3e9a20a3e89e45f884e09df0cc2d2d2a",
"tenantName":"APPC-24595-T-IST-02C",
"modelInfo":{
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.spec.ts
index 05fc008ad..cff944563 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.spec.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.spec.ts
@@ -1,13 +1,16 @@
import {ServiceInstance} from "../../../models/serviceInstance";
import {
- AddServiceAction, ChangeServiceDirty,
+ AddServiceAction,
+ ChangeServiceDirty,
+ CreateServiceInstanceAction,
DeleteServiceInstanceAction,
ServiceActions,
- CreateServiceInstanceAction,
- UpdateServiceModelAction, UpdateServiceInstanceAction
+ UpdateServiceInstanceAction,
+ UpdateServiceModelAction
} from "./service.actions";
import {serviceReducer} from "./service.reducers";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {VidNotions} from "../../../models/vidNotions";
describe('serviceReducer', () => {
@@ -17,32 +20,32 @@ describe('serviceReducer', () => {
const elemntThatShouldNotOverideOnUpdateService = {
vnfs: {
- "2017-388_ADIOD-vPE 0": {
+ "2017-388_PASQUALE-vPE 0": {
"action": "Create",
"inMaint": false,
"rollbackOnFailure": "true",
- "originalName": "2017-388_ADIOD-vPE 0",
+ "originalName": "2017-388_PASQUALE-vPE 0",
"isMissingData": false,
"trackById": "eymgwlevh54",
"vfModules": {},
- "vnfStoreKey": "2017-388_ADIOD-vPE 0",
+ "vnfStoreKey": "2017-388_PASQUALE-vPE 0",
"uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
"productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
- "lcpCloudRegionId": "JANET25",
+ "lcpCloudRegionId": "AAIAIC25",
"tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
"lineOfBusiness": "ONAP",
"platformName": "platform",
"modelInfo": {
"modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
"modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168",
- "modelName": "2017-388_ADIOD-vPE",
+ "modelName": "2017-388_PASQUALE-vPE",
"modelVersion": "4.0",
"modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c",
- "modelCustomizationName": "2017-388_ADIOD-vPE 0",
+ "modelCustomizationName": "2017-388_PASQUALE-vPE 0",
"uuid": "afacccf6-397d-45d6-b5ae-94c39734b168",
"modelUniqueId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c"
},
- "instanceName": "2017-388_ADIOD-vPEAjXzainstanceName",
+ "instanceName": "2017-388_PASQUALE-vPEAjXzainstanceName",
"legacyRegion": "some legacy region",
"instanceParams": [
{
@@ -55,26 +58,26 @@ describe('serviceReducer', () => {
}
]
},
- "2017-488_ADIOD-vPE 0": {
+ "2017-488_PASQUALE-vPE 0": {
"action": "Create",
"inMaint": false,
"rollbackOnFailure": "true",
- "originalName": "2017-488_ADIOD-vPE 0",
+ "originalName": "2017-488_PASQUALE-vPE 0",
"isMissingData": false,
"trackById": "xr6o2782z7",
"vfModules": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0": {
- "2017488_adiodvpe0..2017488AdiodVpe..ADIOD_base_vPE_BV..module-0wmkjw": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
+ "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0wmkjw": {
"isMissingData": true,
"sdncPreReload": null,
"modelInfo": {
"modelType": "VFmodule",
"modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091",
"modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db",
- "modelName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"modelVersion": "5",
"modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3",
- "modelCustomizationName": "2017488AdiodVpe..ADIOD_base_vPE_BV..module-0",
+ "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0",
"modelUniqueId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3"
},
"instanceParams": [
@@ -84,24 +87,24 @@ describe('serviceReducer', () => {
}
}
},
- "vnfStoreKey": "2017-488_ADIOD-vPE 0",
+ "vnfStoreKey": "2017-488_PASQUALE-vPE 0",
"uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
"productFamilyId": "e433710f-9217-458d-a79d-1c7aff376d89",
- "lcpCloudRegionId": "JANET25",
+ "lcpCloudRegionId": "AAIAIC25",
"tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
"lineOfBusiness": "ONAP",
"platformName": "platform",
"modelInfo": {
"modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8",
"modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
- "modelName": "2017-488_ADIOD-vPE",
+ "modelName": "2017-488_PASQUALE-vPE",
"modelVersion": "5.0",
"modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45",
- "modelCustomizationName": "2017-488_ADIOD-vPE 0",
+ "modelCustomizationName": "2017-488_PASQUALE-vPE 0",
"uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09",
"modelUniqueId": "1da7b585-5e61-4993-b95e-8e6606c81e45"
},
- "instanceName": "2017-488_ADIOD-vPEVNFinstancename",
+ "instanceName": "2017-488_PASQUALE-vPEVNFinstancename",
"legacyRegion": "some legacy region",
"instanceParams": [
{
@@ -135,14 +138,14 @@ describe('serviceReducer', () => {
"vnfs": elemntThatShouldNotOverideOnUpdateService.vnfs,
"instanceParams": [
{
- "2017488_adiodvpe0_ASN": "AV_vPE"
+ "2017488_pasqualevpe0_ASN": "AV_vPE"
}
],
"validationCounter": 1,
"existingNames": {
"ajxzainstancename": "",
- "2017-488_adiod-vpevnfinstancename": "",
- "2017-388_adiod-vpeajxzainstancename": ""
+ "2017-488_pasquale-vpevnfinstancename": "",
+ "2017-388_pasquale-vpeajxzainstancename": ""
},
"existingVNFCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVNFCounterMap,
"existingVnfGroupCounterMap": elemntThatShouldNotOverideOnUpdateService.existingVnfGroupCounterMap,
@@ -207,7 +210,7 @@ describe('serviceReducer', () => {
isALaCarte: false,
isEcompGeneratedNaming: false,
isMultiStepDesign: false,
- lcpCloudRegionId: "JANET25",
+ lcpCloudRegionId: "AAIAIC25",
modelInfo: {
modelInvariantId: "e49fbd11-e60c-4a8e-b4bf-30fbe8f4fcc0",
modelVersionId: "6b528779-44a3-4472-bdff-9cd15ec93450",
@@ -264,8 +267,14 @@ describe('serviceReducer', () => {
expect(service.serviceInstance[serviceUuid]['action']).toEqual(actionName);
});
- test('#UPDATE_SERVICE_INSTANCE', () => {
+ test('#CREATE_SERVICE_INSTANCE shall put the instance on state with all its values ', () => {
const serviceUuid: string = 'serviceUuid';
+ const vidNotions:VidNotions = {
+ instantiationUI: "some5G",
+ modelCategory: "5G Provider Network",
+ viewEditUI: "legacy",
+ instantiationType: "ALaCarte"
+ };
let serviceInstanceObject: ServiceInstance = <any>{
isDirty: false,
@@ -298,7 +307,17 @@ describe('serviceReducer', () => {
action: ServiceInstanceActions.Create
};
- let serviceState = serviceReducer(<any>{serviceInstance: {}},
+ let serviceState = serviceReducer(
+ <any>{
+ serviceInstance: {},
+ serviceHierarchy: {
+ [serviceUuid]: {
+ service: {
+ vidNotions: vidNotions
+ }
+ }
+ }
+ },
<CreateServiceInstanceAction>{
type: ServiceActions.CREATE_SERVICE_INSTANCE,
serviceUuid: serviceUuid,
@@ -324,6 +343,7 @@ describe('serviceReducer', () => {
expect(serviceState.instanceParams).toEqual(serviceInstanceObject.instanceParams);
expect(serviceState.rollbackOnFailure).toEqual(serviceInstanceObject.rollbackOnFailure);
expect(serviceState.subscriberName).toEqual(serviceInstanceObject.subscriberName);
+ expect(serviceState.vidNotions).toEqual(vidNotions);
});
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.ts
index 9d21d359c..c6d3da52a 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/service/service.reducers.ts
@@ -2,9 +2,10 @@ import {Action} from "redux";
import {
AddServiceAction,
ChangeServiceDirty,
- ServiceActions,
CreateServiceInstanceAction,
- UpdateServiceModelAction, UpdateServiceInstanceAction
+ ServiceActions,
+ UpdateServiceInstanceAction,
+ UpdateServiceModelAction
} from "./service.actions";
import {ServiceInstance} from "../../../models/serviceInstance";
import {ServiceState} from "../main.reducer";
@@ -34,6 +35,7 @@ export function serviceReducer(state: ServiceState, action: Action) : ServiceSta
const currentInstaceName = state.serviceInstance[uuid] ? serviceInstance.instanceName : null;
newState.serviceInstance[uuid] = Object.assign(serviceInstance, updateServiceInstanceAction.serviceInstance);
+ newState.serviceInstance[uuid].vidNotions = _.get(state,`serviceHierarchy[${uuid}].service.vidNotions`);
if (!_.isNil(updateServiceInstanceAction.serviceInstance)) {
updateUniqueNames(currentInstaceName, updateServiceInstanceAction.serviceInstance.instanceName, newState.serviceInstance[uuid]);
}
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
index f3636ff41..05319c0fb 100644
--- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.ts
@@ -10,6 +10,7 @@ import {ServiceInstance} from "../../../models/serviceInstance";
import {VfModuleMap} from "../../../models/vfModulesMap";
import {ServiceState} from "../main.reducer";
import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+import {updateServiceValidationCounter} from "../reducersHelper";
export function vfModuleReducer(state: ServiceState , action: Action) : ServiceState{
@@ -132,13 +133,6 @@ 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++;
- }
-};
const generateId = () => {
return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
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 => {
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.actions.ts
new file mode 100644
index 000000000..a95a266c1
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.actions.ts
@@ -0,0 +1,84 @@
+import {Action, ActionCreator} from "redux";
+
+export enum VrfActions {
+ CREATE_VRF_INSTANCE = "CREATE_VRF_INSTANCE",
+ EDIT_VRF_INSTANCE = "EDIT_VRF_INSTANCE",
+ DELETE_VRF_INSTANCE = "DELETE_VRF_INSTANCE",
+ VRF_ASSOCIATE_MEMBER = "VRF_ASSOCIATE_MEMBER",
+ CLAER_ASSOCIATE__VRF_MEMBERS = "CLAER_ASSOCIATE__VRF_MEMBERS",
+ DELETE_ACTION_VRF_INSTANCE = "DELETE_ACTION_VRF_INSTANCE",
+ UNDO_DELETE_ACTION_VRF_INSTANCE = "UNDO_DELETE_ACTION_VRF_INSTANCE"
+}
+
+
+export interface CreateVRFInstanceAction extends Action {
+ vrfModel : any;
+ serviceModelId : string;
+ vrfStoreKey : string;
+}
+
+export interface AssociateVRFMemberInstanceAction extends Action {
+ vrfStoreKey : string;
+ serviceModelId : string;
+ memberType : string;
+ member : any;
+}
+
+export interface ClearAssociateVRFMemberInstanceAction extends Action {
+ vrfStoreKey : string;
+ serviceModelId : string;
+ memberType : string;
+}
+
+export interface DeleteActionVrfInstanceAction extends Action {
+ vrfStoreKey : string;
+ serviceId : string;
+}
+
+export interface UndoDeleteActionVrfInstanceAction extends Action {
+ vrfStoreKey: string;
+ serviceId?: string;
+}
+
+export const createVrfInstance: ActionCreator<CreateVRFInstanceAction> = (vrfModel, serviceModelId, vrfStoreKey) => ({
+ type: VrfActions.CREATE_VRF_INSTANCE,
+ vrfModel : vrfModel,
+ serviceModelId : serviceModelId,
+ vrfStoreKey : vrfStoreKey
+});
+
+
+export const associateVRFMember: ActionCreator<AssociateVRFMemberInstanceAction> = (vrfStoreKey, serviceModelId, member, memberType) => ({
+ type: VrfActions.VRF_ASSOCIATE_MEMBER,
+ vrfStoreKey : vrfStoreKey,
+ serviceModelId : serviceModelId,
+ member : member,
+ memberType : memberType
+});
+
+export const clearAssociateVRFMemberInstance: ActionCreator<ClearAssociateVRFMemberInstanceAction> = (vrfStoreKey, serviceModelId, memberType) => ({
+ type: VrfActions.CLAER_ASSOCIATE__VRF_MEMBERS,
+ vrfStoreKey : vrfStoreKey,
+ serviceModelId : serviceModelId,
+ memberType : memberType
+});
+
+export const deleteActionVrfInstance: ActionCreator<DeleteActionVrfInstanceAction> = (vrfStoreKey, serviceId) => ({
+ type: VrfActions.DELETE_ACTION_VRF_INSTANCE,
+ vrfStoreKey : vrfStoreKey,
+ serviceId : serviceId
+});
+
+export const undoDeleteActionVrfInstance: ActionCreator<UndoDeleteActionVrfInstanceAction> = (vrfStoreKey, serviceId) => ({
+ type: VrfActions.UNDO_DELETE_ACTION_VRF_INSTANCE,
+ vrfStoreKey: vrfStoreKey,
+ serviceId: serviceId
+});
+
+
+
+
+
+
+
+
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.spec.ts
new file mode 100644
index 000000000..607fa057d
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.spec.ts
@@ -0,0 +1,152 @@
+import {vrfReducer} from "./vrf.reducer";
+import {
+ AssociateVRFMemberInstanceAction,
+ ClearAssociateVRFMemberInstanceAction,
+ CreateVRFInstanceAction, DeleteActionVrfInstanceAction, UndoDeleteActionVrfInstanceAction,
+ VrfActions
+} from "./vrf.actions";
+import {vnfReducer} from "../vnf/vnf.reducers";
+import {DeleteActionVnfInstanceAction, UndoDeleteActionVnfInstanceAction, VNFActions} from "../vnf/vnf.actions";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+
+
+describe('vrfReducer', () => {
+ test('#VRF_ASSOCIATE_MEMBER ', () => {
+
+ const serviceModelId: string = 'serviceModelID';
+ const vrfStoreKey : string = 'vrfStoreKey';
+ const memberType : string = 'networks';
+ const member = {a : 1 , b : 2};
+ let vrfState = vrfReducer(<any>{
+ serviceInstance : {
+ [serviceModelId] : {
+ vrfs : {
+ [vrfStoreKey] : {
+ [memberType] : {
+
+ }
+ }
+
+ }
+ }
+ }},
+ <AssociateVRFMemberInstanceAction>{
+ type: VrfActions.VRF_ASSOCIATE_MEMBER,
+ vrfStoreKey : vrfStoreKey,
+ serviceModelId : serviceModelId,
+ memberType : memberType,
+ member : member
+ });
+
+ expect(vrfState).toBeDefined();
+ expect(vrfState.serviceInstance[serviceModelId].vrfs[vrfStoreKey][memberType][`${vrfStoreKey} ${memberType} 1`]).toBeDefined();
+ expect(vrfState.serviceInstance[serviceModelId].vrfs[vrfStoreKey][memberType][`${vrfStoreKey} ${memberType} 1`]).toEqual(member);
+ });
+
+ test('#CLAER_ASSOCIATE__VRF_MEMBERS ', () => {
+
+ const serviceModelId: string = 'serviceModelID';
+ const vrfStoreKey : string = 'vrfStoreKey';
+ const memberType : string = 'networks';
+ let vrfState = vrfReducer(<any>{
+ serviceInstance : {
+ [serviceModelId] : {
+ vrfs : {
+ [vrfStoreKey] : {
+ [memberType] : {
+ a : 1,
+ b : 2
+ }
+ }
+
+ }
+ }
+ }},
+ <ClearAssociateVRFMemberInstanceAction>{
+ type: VrfActions.CLAER_ASSOCIATE__VRF_MEMBERS,
+ vrfStoreKey : vrfStoreKey,
+ serviceModelId : serviceModelId,
+ memberType : memberType
+ }).serviceInstance[serviceModelId].vrfs[vrfStoreKey];
+
+ expect(vrfState).toBeDefined();
+ expect(vrfState[memberType]).toBeDefined();
+ expect(vrfState[memberType]).toEqual({});
+ });
+
+ test('#CREATE_VRF_INSTANCE ', () => {
+
+ const serviceModelId: string = 'serviceModelID';
+ const vrfStoreKey : string = 'vrfStoreKey';
+ const vrfModelName : string = 'vrfModelName';
+ const memberType : string = 'networks';
+ let vrfState = vrfReducer(<any>{
+ serviceInstance : {
+ [serviceModelId] : {
+ vrfs : {
+ [vrfStoreKey] : {
+ [memberType] : {
+
+ }
+ }
+
+ }
+ }
+ }},
+ <CreateVRFInstanceAction>{
+ type: VrfActions.CREATE_VRF_INSTANCE,
+ vrfModel : {
+ name : vrfModelName
+ },
+ serviceModelId : serviceModelId,
+ vrfStoreKey : vrfStoreKey
+ }).serviceInstance[serviceModelId].vrfs;
+
+ expect(vrfState).toBeDefined();
+ expect(vrfState[vrfModelName]).toBeDefined();
+ });
+
+ test('#DELETE_ACTION_VRF_INSTANCE', () => {
+ let vnfState = vrfReducer(<any>{serviceInstance : {
+ 'serviceModelId' : {
+ vrfs : {
+ 'vrfStoreKey' : {
+ isMissingData : true,
+ action : 'None'
+ }
+ }
+ }
+ }},
+ <DeleteActionVrfInstanceAction>{
+ type: VrfActions.DELETE_ACTION_VRF_INSTANCE,
+ vrfStoreKey: 'vrfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId'].vrfs['vrfStoreKey'];
+
+ expect(vnfState).toBeDefined();
+ expect(vnfState.action).toEqual(ServiceInstanceActions.None_Delete);
+ });
+
+ test('#UNDO_DELETE_ACTION_VRF_INSTANCE', () => {
+ let vnfState = vrfReducer(<any>{serviceInstance : {
+ 'serviceModelId' : {
+ vrfs : {
+ 'vrfStoreKey' : {
+ isMissingData : true,
+ action : 'Update_Delete'
+ }
+ }
+ }
+ }},
+ <UndoDeleteActionVrfInstanceAction>{
+ type: VrfActions.UNDO_DELETE_ACTION_VRF_INSTANCE,
+ vrfStoreKey: 'vrfStoreKey',
+ serviceId: 'serviceModelId'
+ }).serviceInstance['serviceModelId'].vrfs['vrfStoreKey'];
+
+ expect(vnfState).toBeDefined();
+ expect(vnfState.action).toEqual(ServiceInstanceActions.Update);
+ });
+});
+
+
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.ts
new file mode 100644
index 000000000..f3d81209e
--- /dev/null
+++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vrf/vrf.reducer.ts
@@ -0,0 +1,90 @@
+import {ServiceState} from "../main.reducer";
+import {Action} from "redux";
+import * as _ from "lodash";
+import {
+ AssociateVRFMemberInstanceAction,
+ ClearAssociateVRFMemberInstanceAction,
+ CreateVRFInstanceAction, DeleteActionVrfInstanceAction, UndoDeleteActionVrfInstanceAction,
+ VrfActions
+} from "./vrf.actions";
+import {calculateNextUniqueModelName} from "../vnf/vnf.reducers";
+import {ServiceInstanceActions} from "../../../models/serviceInstanceActions";
+
+export function vrfReducer(state: ServiceState, action: Action): ServiceState {
+ switch (action.type) {
+ case VrfActions.CREATE_VRF_INSTANCE: {
+ const createVRFInstanceAction = <CreateVRFInstanceAction>action;
+ const serviceUuid = createVRFInstanceAction.serviceModelId;
+
+ let newState = _.cloneDeep(state);
+
+ const vrfModelName = calculateNextUniqueModelName(createVRFInstanceAction.vrfModel['name'], serviceUuid, newState, 'vrfs');
+ newState.serviceInstance[serviceUuid].vrfs[vrfModelName] = <any>{
+ ...createVRFInstanceAction.vrfModel
+ };
+ return newState;
+ }
+ case VrfActions.VRF_ASSOCIATE_MEMBER: {
+ const associateVRFMemberInstanceAction = <AssociateVRFMemberInstanceAction>action;
+ const serviceUuid = associateVRFMemberInstanceAction.serviceModelId;
+ const member = associateVRFMemberInstanceAction.member;
+ const vrfStoreKey = associateVRFMemberInstanceAction.vrfStoreKey;
+ const memberType = associateVRFMemberInstanceAction.memberType;
+
+ let newState = _.cloneDeep(state);
+
+ if(_.isNil(newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType])){
+ newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType] = {};
+ }
+
+ const numberOfKeys = Object.keys(newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType]).length;
+ newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType][`${vrfStoreKey} ${memberType} ${numberOfKeys+1}`] = member;
+
+ return newState;
+ }
+ case VrfActions.VRF_ASSOCIATE_MEMBER: {
+ const associateVRFMemberInstanceAction = <AssociateVRFMemberInstanceAction>action;
+ const serviceUuid = associateVRFMemberInstanceAction.serviceModelId;
+ const member = associateVRFMemberInstanceAction.member;
+ const vrfStoreKey = associateVRFMemberInstanceAction.vrfStoreKey;
+ const memberType = associateVRFMemberInstanceAction.memberType;
+
+ let newState = _.cloneDeep(state);
+
+ if(_.isNil(newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType])){
+ newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType] = {};
+ }
+
+ const numberOfKeys = Object.keys(newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType]).length;
+ newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType][`${vrfStoreKey} ${memberType} ${numberOfKeys+1}`] = member;
+
+ return newState;
+ }
+ case VrfActions.CLAER_ASSOCIATE__VRF_MEMBERS: {
+ const clearAssociateVRFMemberInstanceAction = <ClearAssociateVRFMemberInstanceAction>action;
+ const serviceUuid = clearAssociateVRFMemberInstanceAction.serviceModelId;
+ const vrfStoreKey = clearAssociateVRFMemberInstanceAction.vrfStoreKey;
+ const memberType = clearAssociateVRFMemberInstanceAction.memberType;
+
+ let newState = _.cloneDeep(state);
+ newState.serviceInstance[serviceUuid].vrfs[vrfStoreKey][memberType] = {};
+ return newState;
+ }
+ case VrfActions.DELETE_ACTION_VRF_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let vrf = newState.serviceInstance[(<DeleteActionVrfInstanceAction>action).serviceId].vrfs[(<DeleteActionVrfInstanceAction>action).vrfStoreKey];
+ let oldAction = vrf.action;
+ if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState;
+ newState.serviceInstance[(<DeleteActionVrfInstanceAction>action).serviceId].vrfs[(<DeleteActionVrfInstanceAction>action).vrfStoreKey].action = (oldAction + '_Delete') as ServiceInstanceActions;
+ return newState;
+ }
+
+ case VrfActions.UNDO_DELETE_ACTION_VRF_INSTANCE : {
+ let newState = _.cloneDeep(state);
+ let vnf = newState.serviceInstance[(<UndoDeleteActionVrfInstanceAction>action).serviceId].vrfs[(<UndoDeleteActionVrfInstanceAction>action).vrfStoreKey];
+ let oldState = vnf.action;
+ newState.serviceInstance[(<UndoDeleteActionVrfInstanceAction>action).serviceId].vrfs[(<UndoDeleteActionVrfInstanceAction>action).vrfStoreKey].action = (oldState.split('_')[0]) as ServiceInstanceActions;
+ return newState;
+ }
+ }
+}