diff options
author | Alexey Sandler <alexey.sandler@intl.att.com> | 2020-04-26 16:23:57 +0300 |
---|---|---|
committer | Alexey Sandler <alexey.sandler@intl.att.com> | 2020-04-27 19:47:26 +0300 |
commit | b4af2036941854aa45aa9d53e06bd92de5a842d3 (patch) | |
tree | 4de5e11bf56de9dce69e74c88fd05589397b4f2b /vid-webpack-master/src/app | |
parent | 87be3e57618838a5284303759c5ec432a319c5c6 (diff) |
Can't delete the second vfModule in drawing board - fix.
Given two vfModules created under the same vnf,
when try to delete the second vfModule its status not updated to deleted.
Issue-ID: VID-819
Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com>
Change-Id: Ie0c349d78940161d66a125782d917d28988e3c9d
Signed-off-by: Alexey Sandler <alexey.sandler@intl.att.com>
Diffstat (limited to 'vid-webpack-master/src/app')
4 files changed, 45 insertions, 35 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts index f442e1504..b1a67a5bc 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vfModule/vfModule.model.info.ts @@ -351,7 +351,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { }, delete: { method: (node, serviceModelId) => { - this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId)) + this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.modelName)) }, visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) 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 1b80452cb..ac26ba936 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 @@ -49,6 +49,7 @@ export interface DeleteActionVfModuleInstanceAction extends Action { dynamicModelName: string; vnfStoreKey : string; serviceId?: string; + vfModuleModelName: string; } export interface UpgradeVfModuleInstanceAction extends Action { @@ -115,11 +116,12 @@ export const updateVFModuleInstance: ActionCreator<UpdateVFModuleInstanceAction> vnfStoreKey : vnfStoreKey }); -export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({ +export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId, vfModuleModelName) => ({ type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, dynamicModelName: dynamicModelName, vnfStoreKey : vnfStoreKey, - serviceId: serviceId + serviceId: serviceId, + vfModuleModelName }); export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({ 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 9ef440fc5..9bbcf46f7 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,15 +1,18 @@ import { CreateVFModuleInstanceAction, - DeleteActionVfModuleInstanceAction, DeleteVFModuleField, + DeleteActionVfModuleInstanceAction, + DeleteVFModuleField, DeleteVfModuleInstanceAction, UndoDeleteActionVfModuleInstanceAction, - UpdateVFModluePosition, UpdateVFModuleField, + UpdateVFModluePosition, + UpdateVFModuleField, UpgradeVfModuleInstanceAction, VfModuleActions } from "./vfModule.actions"; import {vfModuleReducer} from "./vfModule.reducers"; import {VfModuleInstance} from "../../../models/vfModuleInstance"; import {ServiceInstanceActions} from "../../../models/serviceInstanceActions"; +import each from "jest-each"; describe('vfModuleReducer', () => { @@ -114,12 +117,12 @@ describe('vfModuleReducer', () => { dynamicModelName: 'dynamicModelName1', vnfStoreKey: 'vnfStoreKey', serviceId: 'serviceModelId', - modelName: 'modelName', + modelName: 'vfModuleModelName', fieldName: newFieldName, fieldValue: newFieldValue }); - let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + let vfModule = newState.serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1']; expect(vfModule[newFieldName]).toEqual(newFieldValue); }); @@ -200,18 +203,22 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => { expect(vfModule.position).toEqual(1); }); -test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => { - let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule()) - .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + each([ + ['for the first vfModule', 'dynamicModelName1', true], + ['for the second vfModule', 'dynamicModelName2', true], + ]). +test('#DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName: string, isMissingData: boolean) => { + let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule(dynamicModelName)) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName'][dynamicModelName]; - expect(vfModule).toBeDefined(); - expect(vfModule.isMissingData).toBeTruthy(); - expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); -}); + expect(vfModule).toBeDefined(); + expect(vfModule.isMissingData).toBeTruthy(); + expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); + }); test('#DELETE_ACTION_VF_MODULE_INSTANCE set tenantId and lcpCloudRegion to VFM', () => { - let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule()) - .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule('dynamicModelName1')) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1']; expect(vfModule).toBeDefined(); expect(vfModule.tenantId).toEqual('tenantId'); @@ -260,8 +267,8 @@ test('#UPGRADE_VFMODULE', () => { dynamicModelName: 'dynamicModelName1', vnfStoreKey: 'vnfStoreKey', serviceId: 'serviceModelId', - modelName: 'modelName' - }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; + modelName: 'vfModuleModelName' + }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName']['dynamicModelName1']; expect(vfModule.action).toEqual(ServiceInstanceActions.None_Upgrade); }); @@ -312,12 +319,15 @@ function getReduxState() { tenantId: 'tenantId', lcpCloudRegionId: 'lcpCloudRegionId', vfModules: { - 'modelName': { + 'vfModuleModelName': { 'dynamicModelName1': { isMissingData: true, action: 'None', }, - 'dynamicModelName2': {}, + 'dynamicModelName2': { + action: 'None', + isMissingData: true, + }, } } } @@ -327,12 +337,13 @@ function getReduxState() { } } -function getDeleteActionVfModule() { +function getDeleteActionVfModule(dynamicModelName?: string) { return <DeleteActionVfModuleInstanceAction>{ type: VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE, - dynamicModelName: 'dynamicModelName1', + dynamicModelName: dynamicModelName, vnfStoreKey: 'vnfStoreKey', - serviceId: 'serviceModelId' + serviceId: 'serviceModelId', + vfModuleModelName: 'vfModuleModelName', } } }); 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 1ab275e05..9c624b055 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 @@ -70,20 +70,17 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS return Object.assign({}, state); } case VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE : { + let deleteAction = (<DeleteActionVfModuleInstanceAction>action); let newState = _.cloneDeep(state); - let vfModules = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules; + let vfModule = newState.serviceInstance[deleteAction.serviceId].vnfs[deleteAction.vnfStoreKey] + .vfModules[deleteAction.vfModuleModelName][deleteAction.dynamicModelName]; + let oldAction = vfModule.action; + if (oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState; + newState.serviceInstance[deleteAction.serviceId].vnfs[deleteAction.vnfStoreKey] + .vfModules[deleteAction.vfModuleModelName][deleteAction.dynamicModelName].action = (oldAction + '_Delete') as ServiceInstanceActions; + setLcpCloudRegionIdAndTenantIdFromVnf(newState, deleteAction.serviceId, deleteAction.vnfStoreKey, deleteAction.vfModuleModelName, deleteAction.dynamicModelName); + updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, deleteAction.vfModuleModelName); - for(let key in vfModules){ - let firstKey = Object.keys(vfModules[key])[0]; - if(firstKey === (<DeleteActionVfModuleInstanceAction>action).dynamicModelName){ - let oldAction = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action; - if(oldAction === ServiceInstanceActions.None_Delete || oldAction === ServiceInstanceActions.Update_Delete) return newState; - newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction + '_Delete') as ServiceInstanceActions; - setLcpCloudRegionIdAndTenantIdFromVnf(newState, (<DeleteActionVfModuleInstanceAction>action).serviceId, (<DeleteActionVfModuleInstanceAction>action).vnfStoreKey, key, firstKey); - updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key); - return newState; - } - } return newState; } case VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE : { |