diff options
author | Alexey Sandler <alexey.sandler@intl.att.com> | 2020-04-30 11:26:40 +0300 |
---|---|---|
committer | Alexey Sandler <alexey.sandler@intl.att.com> | 2020-04-30 11:26:40 +0300 |
commit | 4464942ccab08ce2c562c7b27451d0f2c48cc1ff (patch) | |
tree | d02958cf615092d6371ab9202355edc6bcb5f307 /vid-webpack-master/src/app/shared/storeUtil/utils | |
parent | b4af2036941854aa45aa9d53e06bd92de5a842d3 (diff) |
Can't undo delete the second vfModule in drawing board - fix.
Given two vfModules created under the same vnf,
when try to undo delete action 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: I8b14896be68a3aa132027f007ec0695ff706339c
Diffstat (limited to 'vid-webpack-master/src/app/shared/storeUtil/utils')
3 files changed, 62 insertions, 47 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 ac26ba936..40c1ea9e4 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 @@ -86,6 +86,7 @@ export interface UndoDeleteActionVfModuleInstanceAction extends Action { dynamicModelName: string; vnfStoreKey : string; serviceId?: string; + vfModuleModelName: string; } export const removeVfModuleInstance: ActionCreator<DeleteVfModuleInstanceAction> = (modelName, serviceModelId, vfName, vnfStoreKey, dynamicModelName) => ({ @@ -124,11 +125,12 @@ export const deleteActionVfModuleInstance: ActionCreator<DeleteActionVfModuleIns vfModuleModelName }); -export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId) => ({ +export const undoDeleteVfModuleInstance: ActionCreator<UndoDeleteActionVfModuleInstanceAction> = (dynamicModelName, vnfStoreKey, serviceId, vfModuleModelName) => ({ type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, dynamicModelName: dynamicModelName, vnfStoreKey : vnfStoreKey, - serviceId: serviceId + serviceId: serviceId, + vfModuleModelName }); export const updateVFModulePosition: ActionCreator<UpdateVFModluePosition> = (node, instanceId, vnfStoreKey) => ({ 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 9bbcf46f7..7ec221a02 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 @@ -204,10 +204,10 @@ test('#UPDATE_VFMODULE_POSITION: should update position', () => { }); each([ - ['for the first vfModule', 'dynamicModelName1', true], - ['for the second vfModule', 'dynamicModelName2', true], + ['for the first vfModule', 'dynamicModelName1'], + ['for the second vfModule', 'dynamicModelName2'], ]). -test('#DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName: string, isMissingData: boolean) => { +test('#DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName: string) => { let vfModule = vfModuleReducer(<any>getReduxState(), getDeleteActionVfModule(dynamicModelName)) .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName'][dynamicModelName]; @@ -226,35 +226,13 @@ test('#DELETE_ACTION_VF_MODULE_INSTANCE set tenantId and lcpCloudRegion to VFM', }); -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']; + each([ + ['for the first vfModule', 'dynamicModelName1', true], + ['for the second vfModule', 'dynamicModelName2', true], + ]). +test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE %s', (description, dynamicModelName: string) => { + let vfModule = vfModuleReducer(<any>getDeleteRedux(), getUndoDeleteActionVfModule(dynamicModelName)) + .serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['vfModuleModelName'][dynamicModelName]; expect(vfModule).toBeDefined(); expect(vfModule.action).toEqual(ServiceInstanceActions.None); @@ -346,4 +324,42 @@ function getDeleteActionVfModule(dynamicModelName?: string) { vfModuleModelName: 'vfModuleModelName', } } + +function getUndoDeleteActionVfModule(dynamicModelName?: string) { + return <UndoDeleteActionVfModuleInstanceAction>{ + type: VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE, + dynamicModelName: dynamicModelName, + vnfStoreKey: 'vnfStoreKey', + serviceId: 'serviceModelId', + vfModuleModelName: 'vfModuleModelName', + } +} + +function getDeleteRedux() { + return { + serviceHierarchy: { + 'serviceModelId': {} + }, + serviceInstance: { + 'serviceModelId': { + vnfs: { + 'vnfStoreKey': { + vfModules: { + 'vfModuleModelName': { + 'dynamicModelName1': { + isMissingData: true, + action: 'None_Delete' + }, + 'dynamicModelName2': { + isMissingData: true, + action: 'None_Delete' + }, + } + } + } + } + } + } + } +} }); 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 9c624b055..8efecf2ca 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,7 +70,7 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS return Object.assign({}, state); } case VfModuleActions.DELETE_ACTION_VF_MODULE_INSTANCE : { - let deleteAction = (<DeleteActionVfModuleInstanceAction>action); + const deleteAction = (<DeleteActionVfModuleInstanceAction>action); let newState = _.cloneDeep(state); let vfModule = newState.serviceInstance[deleteAction.serviceId].vnfs[deleteAction.vnfStoreKey] .vfModules[deleteAction.vfModuleModelName][deleteAction.dynamicModelName]; @@ -79,23 +79,20 @@ export function vfModuleReducer(state: ServiceState , action: Action) : ServiceS 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); + updateIsMissingDataOnDeleteVFModule(newState, deleteAction.serviceId, deleteAction.vnfStoreKey, deleteAction.vfModuleModelName); return newState; } case VfModuleActions.UNDO_DELETE_ACTION_VF_MODULE_INSTANCE : { + const undoDeleteAction = (<UndoDeleteActionVfModuleInstanceAction>action); let newState = _.cloneDeep(state); - let vfModules = newState.serviceInstance[(<DeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<DeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules; - - for(let key in vfModules){ - let firstKey = Object.keys(vfModules[key])[0]; - if(firstKey === (<UndoDeleteActionVfModuleInstanceAction>action).dynamicModelName){ - let oldAction = newState.serviceInstance[(<UndoDeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action; - newState.serviceInstance[(<UndoDeleteActionVfModuleInstanceAction>action).serviceId].vnfs[(<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey].vfModules[key][firstKey].action = (oldAction.split('_')[0]) as ServiceInstanceActions; - updateIsMissingDataOnDeleteVFModule(newState, (<UndoDeleteActionVfModuleInstanceAction>action).serviceId, (<UndoDeleteActionVfModuleInstanceAction>action).vnfStoreKey, key); - return newState; - } - } + let vfModule = newState.serviceInstance[undoDeleteAction.serviceId].vnfs[undoDeleteAction.vnfStoreKey] + .vfModules[undoDeleteAction.vfModuleModelName][undoDeleteAction.dynamicModelName]; + + let oldAction = vfModule.action; + newState.serviceInstance[undoDeleteAction.serviceId].vnfs[undoDeleteAction.vnfStoreKey] + .vfModules[undoDeleteAction.vfModuleModelName][undoDeleteAction.dynamicModelName].action = (oldAction.split('_')[0]) as ServiceInstanceActions; + updateIsMissingDataOnDeleteVFModule(newState, undoDeleteAction.serviceId, undoDeleteAction.vnfStoreKey, undoDeleteAction.vfModuleModelName); return newState; } |