diff options
author | Yoav Schneiderman <yoav.schneiderman@intl.att.com> | 2019-11-21 16:17:55 +0200 |
---|---|---|
committer | Yoav Schneiderman <yoav.schneiderman@intl.att.com> | 2019-11-25 12:42:52 +0200 |
commit | bda996b9faf9d5d443d2256c0626620bd8104269 (patch) | |
tree | 41d86b08efdc5291404f0c672cc98328c6a2aaf3 /vid-webpack-master/src/app/shared/storeUtil | |
parent | d8f8033a6e6f5a8d724d4b94c4056d2660cc34f1 (diff) |
VfModule upgrade: popup with retain-assignments checkbox
Also:
- undo upgrade -> remove field
- cancel on popup works
Issue-ID: VID-603
Change-Id: I47106ce4d042c777b56699d8c5c5e1e99f856a5e
Signed-off-by: Yoav Schneiderman <yoav.schneiderman@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil')
3 files changed, 320 insertions, 212 deletions
diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts index 59e5ee1fa..70c10c429 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.actions.ts @@ -9,6 +9,8 @@ export enum VfModuleActions { UPDATE_VFMODULE_POSITION = "UPDATE_VFMODULE_POSITION", UPGRADE_VFMODULE = "UPGRADE_VFMODULE", UNDO_UPGRADE_VFMODULE_ACTION = "UNDO_UPGRADE_VFMODULE_ACTION", + UPDATE_VFMODULE_FEILD = "UPDATE_VFMODULE_FEILD", + DELETE_VFMODULE_FEILD = "DELETE_VFMODULE_FEILD", } @@ -62,6 +64,23 @@ export interface UndoUpgradeVfModuleInstanceAction extends Action { dynamicModelName: string; } +export interface UpdateVFModuleField extends Action { + modelName : string; + vnfStoreKey : string; + serviceId: string; + dynamicModelName: string; + fieldName: string; + fieldValue : any; +} + +export interface DeleteVFModuleField extends Action { + modelName : string; + vnfStoreKey : string; + serviceId: string; + dynamicModelName: string; + deleteFieldName: string; +} + export interface UndoDeleteActionVfModuleInstanceAction extends Action { dynamicModelName: string; vnfStoreKey : string; @@ -132,3 +151,22 @@ export const undoUgradeVFModule: ActionCreator<UndoUpgradeVfModuleInstanceAction vnfStoreKey, serviceId }); + +export const updateVFModuleField: ActionCreator<UpdateVFModuleField> = (modelName, vnfStoreKey, serviceId, dynamicModelName, fieldName, fieldValue) => ({ + type: VfModuleActions.UPDATE_VFMODULE_FEILD, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId, + fieldName, + fieldValue +}); + +export const deleteVFModuleField: ActionCreator<DeleteVFModuleField> = (modelName, vnfStoreKey, serviceId, dynamicModelName, deleteFieldName) => ({ + type: VfModuleActions.DELETE_VFMODULE_FEILD, + dynamicModelName, + modelName, + vnfStoreKey, + serviceId, + deleteFieldName +}); diff --git a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts index ee0edb0a7..7b890b715 100644 --- a/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts +++ b/vid-webpack-master/src/app/shared/storeUtil/utils/vfModule/vfModule.reducers.spec.ts @@ -1,9 +1,9 @@ import { CreateVFModuleInstanceAction, - DeleteActionVfModuleInstanceAction, + DeleteActionVfModuleInstanceAction, DeleteVFModuleField, DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, - UpdateVFModluePosition, + UpdateVFModluePosition, UpdateVFModuleField, UpgradeVfModuleInstanceAction, VfModuleActions } from "./vfModule.actions"; @@ -14,12 +14,13 @@ import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; describe('vfModuleReducer', () => { test('#REMOVE_VNF_MODULE_INSTANCE : should delete existing vnf module by dynamicModelName', () => { - let state = vfModuleReducer(<any>{serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { + let state = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { 'dynamicModelName1': {}, 'dynamicModelName2': {}, } @@ -27,13 +28,14 @@ describe('vfModuleReducer', () => { } } } - }}, + } + }, <DeleteVfModuleInstanceAction>{ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE, - modelName : 'modelName', - vfName : 'vfName', - vnfStoreKey : 'vfName', - serviceModelId : 'serviceModelId', + modelName: 'modelName', + vfName: 'vfName', + vnfStoreKey: 'vfName', + serviceModelId: 'serviceModelId', dynamicModelName: 'dynamicModelName1' }); @@ -43,26 +45,27 @@ describe('vfModuleReducer', () => { }); test('#DELETE_LAST_VNF_MODULE_INSTANCE : should delete existing vnf module', () => { - let state = vfModuleReducer(<any>{serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { - 'dynamicModelName': { - } + let state = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { + 'dynamicModelName': {} } } } } } - }}, + } + }, <DeleteVfModuleInstanceAction>{ type: VfModuleActions.REMOVE_VNF_MODULE_INSTANCE, - modelName : 'modelName', - vfName : 'vfName', - vnfStoreKey : 'vfName', - serviceModelId : 'serviceModelId', + modelName: 'modelName', + vfName: 'vfName', + vnfStoreKey: 'vfName', + serviceModelId: 'serviceModelId', dynamicModelName: 'dynamicModelName' }); @@ -70,28 +73,29 @@ describe('vfModuleReducer', () => { expect(state.serviceInstance['serviceModelId'].vnfs['vfName'].vfModules['modelName']).not.toBeDefined(); }); - test('#CREATE_VF_MODULE: should create new vfModule to existing VNF', ()=>{ - let vfModuleInstance : VfModuleInstance = new VfModuleInstance(); + test('#CREATE_VF_MODULE: should create new vfModule to existing VNF', () => { + let vfModuleInstance: VfModuleInstance = new VfModuleInstance(); vfModuleInstance.instanceName = 'instanceName'; vfModuleInstance.isMissingData = false; vfModuleInstance.volumeGroupName = 'volumeGroupName'; - let vfModule = vfModuleReducer(<any>{serviceInstance : { - 'serviceUuid' : { - vnfs : { - 'vnfStoreKey' : { - 'vfModules' : { - } + let vfModule = vfModuleReducer(<any>{ + serviceInstance: { + 'serviceUuid': { + vnfs: { + 'vnfStoreKey': { + 'vfModules': {} } } } - }}, + } + }, <CreateVFModuleInstanceAction>{ type: VfModuleActions.CREATE_VF_MODULE, - vfId : 'vfId', - vfInstance : new VfModuleInstance(), - vnfStoreKey : 'vnfStoreKey', - serviceUuid : 'serviceUuid', - index : 1 + vfId: 'vfId', + vfInstance: new VfModuleInstance(), + vnfStoreKey: 'vnfStoreKey', + serviceUuid: 'serviceUuid', + index: 1 }).serviceInstance['serviceUuid'].vnfs['vnfStoreKey'].vfModules; let firstVfModuleName = Object.keys(vfModule)[0]; @@ -99,23 +103,64 @@ describe('vfModuleReducer', () => { expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy(); }); - test('#UPDATE_VF_MODULE: should update existing VFModule', ()=>{ - let vfModuleInstance : VfModuleInstance = new VfModuleInstance(); - vfModuleInstance.instanceName = 'instanceName'; - vfModuleInstance.isMissingData = false; - vfModuleInstance.volumeGroupName = 'volumeGroupName'; - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} + test('#UPDATE_VFMODULE_FEILD: should update field with some value', () => { + const newFieldName = 'newFieldName'; + const newFieldValue = 'newFieldValue'; + let oldState = { + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, + } + } + } + } + } + } + }; + + let newState = vfModuleReducer(<any>oldState, + <UpdateVFModuleField>{ + type: VfModuleActions.UPDATE_VFMODULE_FEILD, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName', + fieldName: newFieldName, + fieldValue: newFieldValue + }); + + let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + + expect(vfModule[newFieldName]).toEqual(newFieldValue); + }); + + test('#DELETE_VFMODULE_FEILD: should update field with some value', () => { + const deleteFieldName = 'deleteFieldName'; + let oldState = { + serviceHierarchy: { + 'serviceModelId': {} }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { 'dynamicModelName1': { - isMissingData : true + isMissingData: true, + [deleteFieldName]: true, + action: 'None' }, 'dynamicModelName2': {}, } @@ -123,192 +168,197 @@ describe('vfModuleReducer', () => { } } } - }}, - <CreateVFModuleInstanceAction>{ - type: VfModuleActions.UPDATE_VF_MODULE, - vfId : 'modelName', - vfInstance : new VfModuleInstance(), - vnfStoreKey : 'vfName', - dynamicModelName : 'dynamicModelName1', - serviceUuid : 'serviceModelId', - index : 1 - }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules; + } + }; + let newState = vfModuleReducer(<any>oldState, + <DeleteVFModuleField>{ + type: VfModuleActions.DELETE_VFMODULE_FEILD, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName', + deleteFieldName: deleteFieldName, + }); - let firstVfModuleName = Object.keys(vfModule)[0]; - expect(vfModule[firstVfModuleName]).toBeDefined(); - expect(vfModule[firstVfModuleName].isMissingData).toBeFalsy(); - }); + let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + expect(vfModule[deleteFieldName]).toBeUndefined(); +}); - test('#UPDATE_VFMODULE_POSITION: should update position', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vfName' : { - vfModules : { - 'modelName' : { - 'dynamicModelName': { - isMissingData : true - } +test('#UPDATE_VFMODULE_POSITION: should update position', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vfName': { + vfModules: { + 'modelName': { + 'dynamicModelName': { + isMissingData: true } } } } } - }}, - <UpdateVFModluePosition>{ - type: VfModuleActions.UPDATE_VFMODULE_POSITION, - node: { - position : 1, - dynamicModelName : "dynamicModelName", - modelName : "modelName" - }, - instanceId : "serviceModelId", - vnfStoreKey : "vfName" + } + } + }, + <UpdateVFModluePosition>{ + type: VfModuleActions.UPDATE_VFMODULE_POSITION, + node: { + position: 1, + dynamicModelName: "dynamicModelName", + modelName: "modelName" + }, + instanceId: "serviceModelId", + vnfStoreKey: "vfName" - }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"]; - - expect(vfModule.position).toEqual(1); - }); + }).serviceInstance['serviceModelId'].vnfs['vfName'].vfModules["modelName"]["dynamicModelName"]; + expect(vfModule.position).toEqual(1); +}); - test('#DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None' - }, - 'dynamicModelName2': {}, - } +test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, } } } } - }}, - <DeleteActionVfModuleInstanceAction>{ - type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <DeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); - expect(vfModule).toBeDefined(); - expect(vfModule.isMissingData).toBeTruthy(); - expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); - }); + console.log(vfModule.action); + expect(vfModule).toBeDefined(); + expect(vfModule.isMissingData).toBeTruthy(); + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); +}); - test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None_Delete' - }, - 'dynamicModelName2': {}, - } +test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None_Delete' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UndoDeleteActionVfModuleInstanceAction>{ - type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <UndoDeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); - expect(vfModule).toBeDefined(); - expect(vfModule.action).toEqual(ServiceInstanceActions.None); - }); + console.log(vfModule.action); + expect(vfModule).toBeDefined(); + expect(vfModule.action).toEqual(ServiceInstanceActions.None); +}); - test('#UPGRADE_VFMODULE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None' - }, - 'dynamicModelName2': {}, - } +test('#UPGRADE_VFMODULE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UpgradeVfModuleInstanceAction>{ - type: VfModuleActions.UPGRADE_VFMODULE, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId', - modelName: 'modelName' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + } + } + }, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UPGRADE_VFMODULE, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); - }); + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); +}); - test('#UNDO_UPGRADE_VFMODULE', ()=>{ - let vfModule = vfModuleReducer(<any>{ - serviceHierarchy : { - 'serviceModelId' : {} - }, - serviceInstance : { - 'serviceModelId' : { - vnfs : { - 'vnfStoreKey' : { - vfModules : { - 'modelName' : { - 'dynamicModelName1': { - isMissingData : true, - action : 'None_Upgrade' - }, - 'dynamicModelName2': {}, - } +test('#UNDO_UPGRADE_VFMODULE', () => { + let vfModule = vfModuleReducer(<any>{ + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'modelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None_Upgrade' + }, + 'dynamicModelName2': {}, } } } } - }}, - <UpgradeVfModuleInstanceAction>{ - type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, - dynamicModelName: 'dynamicModelName1', - vnfStoreKey : 'vnfStoreKey', - serviceId: 'serviceModelId', - modelName: 'modelName' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - - expect(vfModule.action).toEqual(ServiceInstanceActions.None); - }); + } + } + }, + <UpgradeVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_UPGRADE_VFMODULE_ACTION, + dynamicModelName: 'dynamicModelName1', + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + modelName: 'modelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); + +}) +; 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 a7aadba41..1bb2b15fd 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 @@ -1,10 +1,10 @@ import {Action} from "redux"; import * as _ from "lodash"; import { - CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, - DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, + CreateVFModuleInstanceAction, DeleteActionVfModuleInstanceAction, DeleteVFModuleField, + DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, UpdateVFModluePosition, UpdateVFModuleField, UpdateVFModuleInstanceAction, UpgradeVfModuleInstanceAction, - VfModuleActions + VfModuleActions, } from "./vfModule.actions"; import {ServiceInstance} from "../../../models/serviceInstance"; import {VfModuleMap} from "../../../models/vfModulesMap"; @@ -145,6 +145,26 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS } return clonedState; } + case VfModuleActions.UPDATE_VFMODULE_FEILD : { + let clonedState = _.cloneDeep(state); + let updateFieldAction = <UpdateVFModuleField> action; + + clonedState.serviceInstance[updateFieldAction.serviceId] + .vnfs[updateFieldAction.vnfStoreKey] + .vfModules[updateFieldAction.modelName][updateFieldAction.dynamicModelName][updateFieldAction.fieldName] = updateFieldAction.fieldValue; + + return clonedState; + } + case VfModuleActions.DELETE_VFMODULE_FEILD : { + let clonedState = _.cloneDeep(state); + let deleteAction = <DeleteVFModuleField> action; + + delete clonedState.serviceInstance[deleteAction.serviceId] + .vnfs[deleteAction.vnfStoreKey] + .vfModules[deleteAction.modelName][deleteAction.dynamicModelName][deleteAction.deleteFieldName]; + + return clonedState; + } } } |