diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2020-01-29 15:11:47 +0200 |
---|---|---|
committer | Eylon Malin <eylon.malin@intl.att.com> | 2020-01-30 23:23:36 +0200 |
commit | aefc6a0e43b8ce36134dbbed71cf2b4cb9745a9f (patch) | |
tree | 82e6a44cdb477657796d3280aa0a9ef91aea1fe3 | |
parent | 714c28d14b53b91eac1a5ffa3ebdf63650028918 (diff) |
don't show delete in menu action while edit a macro service
Issue-ID: VID-760
Change-Id: Ieed2b7430cc1584681b1143d8b7244801dd8a1c4
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
20 files changed, 144 insertions, 290 deletions
diff --git a/vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json b/vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json index cf805b7ba..2fdda8fa0 100644 --- a/vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json +++ b/vid-automation/src/test/resources/viewEdit/ServiceTreeWithMultipleChildren_serviceInstance_withUpdatedLatestVersion.json @@ -15,7 +15,7 @@ "aicZoneName":null, "projectName":null, "rollbackOnFailure":null, - "isALaCarte":false, + "isALaCarte":true, "modelInfo":{ "modelInvariantId":"d27e42cf-087e-4d31-88ac-6c4b7585f800", "modelVersionId": "6e59c5de-f052-46fa-aa7e-2fca9d674c44", diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts index 87875f1ba..ac5790ddf 100644 --- a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts @@ -16,6 +16,8 @@ export const initServicePlanning = function (viewOrEdit: string, customModelFile } cy.readFile('../vid-automation/src/test/resources/aaiGetInstanceTopology/ServiceTreeWithMultipleChildren_serviceModel.json').then((res) => { + res.service.instantiationType = "A-La-Carte"; + res.service.vidNotions.instantiationType = "ALaCarte"; jsonBuilderAndMock.basicJson( res, Cypress.config('baseUrl') + "/rest/models/services/6e59c5de-f052-46fa-aa7e-2fca9d674c44", diff --git a/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts index 60fbfeaba..a0882f5bf 100644 --- a/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/vnfGroups.e2e.ts @@ -20,6 +20,42 @@ describe('Vnf Groups', function () { cy.screenshot(); }); + function updateObject(obj: any, key: string, val: any, value:any) { + return JSON.parse(JSON.stringify(obj) + .replace(new RegExp(`"${key}":"${val}"`), `"${key}":"${value}"`)) + } + + function buildReduxStateWithServiceRespone(res: any, serviceId:string, isEcompGeneratedNaming:boolean) :void { + res = updateObject(res, "ecomp_generated_naming", !isEcompGeneratedNaming, isEcompGeneratedNaming); + cy.window().then((win) => { + win.sessionStorage.setItem('reduxState', JSON.stringify({ + "global": { + "name": null + }, + "service": { + "serviceHierarchy": { + [serviceId] : res + }, + "serviceInstance": { + [serviceId]: { + "modelInfo" : { + "modelVersionId" : serviceId + }, + "existingVNFCounterMap": {}, + "existingVnfGroupCounterMap": {}, + "existingNetworksCounterMap": {}, + "vnfs": {}, + "vnfGroups": {}, + "isEcompGeneratedNaming": isEcompGeneratedNaming, + "existingNames": {}, + "vidNotions": res.service.vidNotions + } + } + } + })); + }); + } + describe('Vnf Group model basic view', function () { it('Vnf group open new view edit', function () { @@ -36,7 +72,7 @@ describe('Vnf Groups', function () { "ServiceWithVnfGroup", ); - cy.buildReduxStateWithServiceRespone(res, serviceId, false); + buildReduxStateWithServiceRespone(res, serviceId, false); cy.openIframe('app/ui/#/servicePlanning?serviceModelId=' + serviceId); cy.getElementByDataTestsId('node-' + groupName).find(`[data-tests-id='node-type-indicator']`).contains('G'); cy.getElementByDataTestsId('node-' + groupName).contains('' + groupName); diff --git a/vid-webpack-master/cypress/support/application/application.session.actions.ts b/vid-webpack-master/cypress/support/application/application.session.actions.ts index c054b2640..9126ae1a4 100644 --- a/vid-webpack-master/cypress/support/application/application.session.actions.ts +++ b/vid-webpack-master/cypress/support/application/application.session.actions.ts @@ -5,7 +5,6 @@ declare namespace Cypress { clearSessionStorage: typeof clearSessionStorage; setTestApiParamToGR: typeof setTestApiParamToGR; setTestApiParamToVNF: typeof setTestApiParamToVNF; - buildReduxStateWithServiceRespone: typeof buildReduxStateWithServiceRespone; } } @@ -44,42 +43,8 @@ function setTestApiParamToVNF() : void { }); } -function updateObject(obj: any, key: string, val: any, value:any) { - return JSON.parse(JSON.stringify(obj) - .replace(new RegExp(`"${key}":"${val}"`), `"${key}":"${value}"`)) -} - -function buildReduxStateWithServiceRespone(res: any, serviceId:string, isEcompGeneratedNaming:boolean) :void { - res = updateObject(res, "ecomp_generated_naming", !isEcompGeneratedNaming, isEcompGeneratedNaming); - cy.window().then((win) => { - win.sessionStorage.setItem('reduxState', JSON.stringify({ - "global": { - "name": null - }, - "service": { - "serviceHierarchy": { - [serviceId] : res - }, - "serviceInstance": { - [serviceId]: { - "existingVNFCounterMap": {}, - "existingVnfGroupCounterMap": {}, - "existingNetworksCounterMap": {}, - "vnfs": {}, - "vnfGroups": {}, - "isEcompGeneratedNaming": isEcompGeneratedNaming, - "existingNames": {}, - "vidNotions": res.service.vidNotions - } - } - } - })); - }); -} - Cypress.Commands.add('setReduxState', setReduxState); Cypress.Commands.add('getReduxState', getReduxState); Cypress.Commands.add('clearSessionStorage', clearSessionStorage); Cypress.Commands.add('setTestApiParamToGR', setTestApiParamToGR); Cypress.Commands.add('setTestApiParamToVNF',setTestApiParamToVNF); -Cypress.Commands.add('buildReduxStateWithServiceRespone', buildReduxStateWithServiceRespone); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts index 5ae64376a..9c102069b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/basic.model.info.ts @@ -63,8 +63,9 @@ export interface ILevelNodeInfo { * @param model - The model of current object * @param parentModel * @param storeKey - instance storeKey if exist (for duplicate) + * @param serviceModelId ************************************************************/ - createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string): any + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any /*********************************************************** * return if instance has some missing data diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts index 339951de5..c469be501 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.ts @@ -34,11 +34,11 @@ export class CollectionResourceModelInfo implements ILevelNodeInfo{ }; - createInstanceTreeNode = (instance: CollectionResourceInstance, model: CollectionResourceModel, parentModel, storeKey: string): CollectionResourceTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new CollectionResourceTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; return node; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts index d9702b4c4..f7b7df75c 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/configuration/configuration.model.info.ts @@ -38,7 +38,7 @@ export class ConfigurationModelInfo implements ILevelNodeInfo{ return {}; }; - createInstanceTreeNode(instance: any, model: any, storeKey: string): any {return null;} + createInstanceTreeNode(instance: any, model: any, storeKey: string, serviceModelId: string): any {return null;} childNames: string[]; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts index 6c8382808..951145870 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.spec.ts @@ -69,7 +69,7 @@ describe('NCF Model Info', () => { typeName: "NCF" }; - const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923"); + const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923", "dd182d7d-6949-4b90-b3cc-5befe400742e"); expect(ncfTreeNode).toMatchObject(expected); }); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts index 4db41c0d1..5c03b379b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/ncf/ncf.model.info.ts @@ -37,7 +37,7 @@ export class NcfModelInfo implements ILevelNodeInfo { }; - createInstanceTreeNode = (instance: Level1Instance, model: Level1Model, parentModel, storeKey: string): NcfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let modelVersion: string = null; if (parentModel.networksCollection && instance.originalName) { const ncfRealModel: NcfModelInterface = parentModel.networksCollection[instance.originalName]; @@ -47,7 +47,7 @@ export class NcfModelInfo implements ILevelNodeInfo { } let node = new NcfTreeNode(instance, model, storeKey, modelVersion); - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.typeName = this.typeName; return node; }; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts index 7c240a9b9..7979b5af4 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/network/network.model.info.ts @@ -85,11 +85,11 @@ export class NetworkModelInfo implements ILevelNodeInfo { * @param parentModel * @param storeKey - store key if exist ************************************************************/ - createInstanceTreeNode = (instance: NetworkInstance, model: NetworkModel, parentModel, storeKey: string): NetworkTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new NetworkTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -234,8 +234,8 @@ export class NetworkModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node), - enable: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node) + visible: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => node.data.parentType !== 'VRF' && this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts index 05e05a744..6debcd6a5 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/pnf/pnf.model.info.ts @@ -21,7 +21,7 @@ export class PnfModelInfo implements ILevelNodeInfo{ childNames: string[]; componentInfoType = ComponentInfoType.PNF; - createInstanceTreeNode = (instance: PnfInstance, model: PNFModel, parentModel: any, storeKey: string): PnfTreeNode => null; + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => null; getInfo(model, instance): ModelInformationItem[] { return []; diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts index 86455ce60..20d1f5949 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/relatedVnfMember/relatedVnfMember.info.model.ts @@ -65,12 +65,13 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { * @param model - vnf model * @param parentModel * @param storeKey - store key if exist + * @param serviceModelId ************************************************************/ - createInstanceTreeNode = (instance: VnfInstance, model: VNFModel, parentModel, storeKey: string): VnfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VnfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage: ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -128,8 +129,8 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { method : (node, serviceModelId) => { this._store.dispatch(deleteActionRelatedVnfMemberInstance(node.parent.data.vnfGroupStoreKey, node.data.vnfStoreKey, serviceModelId)); }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete : { method : (node, serviceModelId) => { @@ -137,7 +138,7 @@ export class RelatedVnfMemberInfoModel implements ILevelNodeInfo { }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), - enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) + enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent, serviceModelId) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) } } } 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 1b92eb81b..9886176be 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 @@ -86,7 +86,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { return {}; }; - createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number): VfModuleTreeNode { + createNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string, index: number, serviceModelId: string): VfModuleTreeNode { let dynamicModelName = Object.keys(instance)[index]; instance = instance[Object.keys(instance)[index]]; const isEcompGeneratedNaming: boolean = this.isEcompGeneratedNaming(currentModel, parentModel); @@ -96,7 +96,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { newVfModule.missingData = this._sharedTreeService.hasMissingData(instance, newVfModule.dynamicInputs, isEcompGeneratedNaming, []); newVfModule.typeName = this.typeName; - newVfModule.menuActions = this.getMenuAction(<any>newVfModule, currentModel.uuid); + newVfModule.menuActions = this.getMenuAction(<any>newVfModule, serviceModelId); newVfModule.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; newVfModule.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; @@ -104,16 +104,16 @@ export class VFModuleModelInfo implements ILevelNodeInfo { return newVfModule; } - createInstanceTreeNode(instance: VfModuleInstance, currentModel: VfModule, parentModel: VNFModel, modelName: string): VfModuleTreeNode | VfModuleTreeNode[] { + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any { let numberOfChilds = Object.keys(instance).length; if (numberOfChilds > 1) { let result: VfModuleTreeNode[] = []; for (let i = 0; i < numberOfChilds; i++) { - result.push(this.createNode(instance, currentModel, parentModel, modelName, i)); + result.push(this.createNode(instance, model, parentModel, storeKey, i, serviceModelId)); } return result; } else { - return this.createNode(instance, currentModel, parentModel, modelName, 0); + return this.createNode(instance, model, parentModel, storeKey, 0, serviceModelId); } } @@ -355,8 +355,8 @@ export class VFModuleModelInfo implements ILevelNodeInfo { method: (node, serviceModelId) => { this._store.dispatch(deleteActionVfModuleInstance(node.data.dynamicModelName, node.parent.data.vnfStoreKey, serviceModelId)) }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { @@ -364,7 +364,7 @@ export class VFModuleModelInfo implements ILevelNodeInfo { this._store.dispatch(deleteVFModuleField(node.data.modelName, node.parent.data.vnfStoreKey, node.data.servicedId ,node.data.dynamicModelName, 'retainAssignments')); }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), - enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) + enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent, serviceModelId) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) }, upgrade: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts index 1215bb80e..950e3628c 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnf/vnf.model.info.ts @@ -101,12 +101,13 @@ export class VnfModelInfo implements ILevelNodeInfo { * @param model - vnf model * @param parentModel * @param storeKey - store key if exist + * @param serviceModelId ************************************************************/ - createInstanceTreeNode = (instance: VnfInstance, model: VNFModel, parentModel, storeKey: string): VnfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VnfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); @@ -271,8 +272,8 @@ export class VnfModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts index fa785bc73..2447a063c 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vnfGrouping/vnfGrouping.model.info.ts @@ -83,12 +83,12 @@ export class VnfGroupingModelInfo implements ILevelNodeInfo { getType = (): string => 'VnfGroup'; - createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string): any { + createInstanceTreeNode(instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any { let node = new VnfGroupTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node = this._sharedTreeService.addingStatusProperty(node); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node.limitMembers = (!_.isNil(model.properties.quantity)) ? model.properties.quantity : null; @@ -275,8 +275,8 @@ export class VnfGroupingModelInfo implements ILevelNodeInfo { }); } }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts index b951162f8..0fbbc4a2d 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vpn/vpn.model.info.ts @@ -34,12 +34,12 @@ export class VpnModelInfo implements ILevelNodeInfo { }; - createInstanceTreeNode = (instance: NetworkInstance, model: any, parentModel, storeKey: string): VpnTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VpnTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node = this._sharedTreeService.addingStatusProperty(node); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; node = this._sharedTreeService.addingStatusProperty(node); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts index 03f60211c..dacde73f8 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrf.model.info.ts @@ -56,11 +56,11 @@ export class VrfModelInfo implements ILevelNodeInfo { }; - createInstanceTreeNode = (instance: VrfInstance, model: VrfModel, parentModel, storeKey: string): VrfTreeNode => { + createInstanceTreeNode = (instance: any, model: any, parentModel: any, storeKey: string, serviceModelId: string): any => { let node = new VrfTreeNode(instance, model, storeKey); node.missingData = this.hasMissingData(instance, node, model.isEcompGeneratedNaming); node.typeName = this.typeName; - node.menuActions = this.getMenuAction(<any>node, model.uuid); + node.menuActions = this.getMenuAction(<any>node, serviceModelId); node.isFailed = _.isNil(instance.isFailed) ? false : instance.isFailed; node.statusMessage = !_.isNil(instance.statusMessage) ? instance.statusMessage : ""; return node; @@ -157,8 +157,8 @@ export class VrfModelInfo implements ILevelNodeInfo { method: (node, serviceModelId) => { this._store.dispatch(deleteActionVrfInstance(node.data.vrfStoreKey, serviceModelId)); }, - visible: (node) => this._sharedTreeService.shouldShowDelete(node), - enable: (node) => this._sharedTreeService.shouldShowDelete(node) + visible: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId), + enable: (node) => this._sharedTreeService.shouldShowDelete(node, serviceModelId) }, undoDelete: { method: (node, serviceModelId) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts index 8ddb4ba2d..89d901f55 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToInstanceTree/objectToInstanceTree.service.ts @@ -34,10 +34,11 @@ export class ObjectToInstanceTreeService { this.numberOfFailed = 0; this.numberOfElements = 0; let _this = this; + const serviceModelId:string = serviceInstance.modelInfo.modelVersionId; const firstLevelOptions: ILevelNodeInfo[] = _this._objectToTreeService.getFirstLevelOptions(); for (let option of firstLevelOptions) { _.forOwn(serviceInstance[option.name], function (instance, modelName) { - nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option)); + nodes.push(_this.getNodeInstance(modelName, null, instance, serviceHierarchy, option, serviceModelId)); }); } return this.sortElementsByPosition(nodes); @@ -71,18 +72,19 @@ export class ObjectToInstanceTreeService { * @param instance * @param serviceHierarchy - The service Hierarchy store * @param option + * @param serviceModelId * @param parentType ****************************************************************/ - getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, parentType ?: string) { + getNodeInstance(modelName: string, parentModel: any, instance: any, serviceHierarchy, option: ILevelNodeInfo, serviceModelId: string, parentType ?: string) { const model = option.getModel(modelName, instance, serviceHierarchy); - let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName); + let optionalNodes = option.createInstanceTreeNode(instance, model, parentModel, modelName, serviceModelId); this.increaseNumberOfFailed(optionalNodes); this.increaseNumberOfExcitingElements(); let nodes: any[] = _.isArray(optionalNodes) ? optionalNodes : [optionalNodes]; for (let node of nodes) { node = this.addingExtraDataToNode(node, modelName, parentModel, instance, serviceHierarchy, option, parentType); - let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy); + let children = this.addNextInstanceTreeNode(instance, model, option, node, serviceHierarchy, serviceModelId); if (!_.isNil(children) && children.length > 0) { node.children = this.sortElementsByPosition(children); } @@ -119,8 +121,9 @@ export class ObjectToInstanceTreeService { * @param levelNodeInfo * @param parentNode * @param serviceHierarchy - The service Hierarchy store + * @param serviceModelId ****************************************************************/ - addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy): any[] { + addNextInstanceTreeNode(parentInstance, parentModel, levelNodeInfo: ILevelNodeInfo, parentNode, serviceHierarchy, serviceModelId: string): any[] { if (!_.isNil(levelNodeInfo.childNames)&& levelNodeInfo.childNames.length > 0) { const that = this; parentNode.children = []; @@ -130,7 +133,7 @@ export class ObjectToInstanceTreeService { let nextLevelNodeInfo = levelNodeInfo.getNextLevelObject.apply(that, [childName]); Object.keys(parentInstance[childName]).map((modelName) => { let nextLevelInstance = parentInstance[childName][modelName]; - let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, parentType); + let nodes: any[] | any = that.getNodeInstance(modelName, parentModel, nextLevelInstance, serviceHierarchy, nextLevelNodeInfo, serviceModelId, parentType); if (_.isArray(nodes)) { parentNode.children = parentNode.children.concat(nodes); } else { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts index 87094e3bb..d7697d61b 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.spec.ts @@ -63,7 +63,7 @@ function getNodeWithData(menuAction:string){ }; nodeData['menuActions'][menuAction] = { method: (node, serviceModelId) => {} - } + }; const node = { parent: { data: nodeData, @@ -134,7 +134,7 @@ describe('Shared Tree Service', () => { test('SharedTreeService upgradeBottomUp should call redux actions', () => { const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; - const node = getNodeWithData("upgrade") + const node = getNodeWithData("upgrade"); spyOn(node.parent.data.menuActions['upgrade'], 'method'); service.upgradeBottomUp(node, serviceModelId); expect(node.parent.data.menuActions['upgrade'].method).toBeCalledWith(node.parent, serviceModelId); @@ -144,7 +144,7 @@ describe('Shared Tree Service', () => { test('SharedTreeService undoUpgradeBottomUp should call redux actions', () => { const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; - const node = getNodeWithData("undoUpgrade") + const node = getNodeWithData("undoUpgrade"); spyOn(node.parent.data.menuActions['undoUpgrade'], 'method'); service.undoUpgradeBottomUp(node, serviceModelId); expect(node.parent.data.menuActions['undoUpgrade'].method).toBeCalledWith(node.parent, serviceModelId); @@ -264,7 +264,6 @@ describe('Shared Tree Service', () => { }); - test('statusProperties should be prop on node according to node properties', () => { let node = service.addingStatusProperty({orchStatus: 'completed', provStatus: 'inProgress', inMaint: false}); expect(node.statusProperties).toBeDefined(); @@ -284,6 +283,39 @@ describe('Shared Tree Service', () => { testId: 'inMaint' })]); }); + + each([ + [false, 'method is not in menu actions', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {}, true], + [false, 'there is no action in node', null, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [true, 'edit mode, action is none, method in menu action', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [false, 'edit mode, action is none, method in menu action, macro service', ServiceInstanceActions.None, DrawingBoardModes.EDIT, {someMethod: "someValue"}, false], + [false, 'edit mode, action is not none, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true], + [false, 'edit mode, action is CREATE, method in menu action', ServiceInstanceActions.Resume, DrawingBoardModes.EDIT, {someMethod: "someValue"}, true] + ]).test('shouldShowButtonGeneric return %s if %s ', (expected, description, action, mode, menuActions, isALaCarte) => { + jest.spyOn(store, 'getState').mockReturnValue(<any>{ + global: { + drawingBoardStatus: mode + }, + service : { + serviceInstance: { + someModelId : { + isALaCarte + } + } + + } + }); + let node = <any>{ + data:{ + action: action, + menuActions: menuActions + }, + }; + + let res = service.shouldShowButtonGeneric(node, "someMethod", "someModelId"); + expect(res).toBe(expected); + }); + const enableRemoveAndEditItemsDataProvider = [ ['Create action CREATE mode', DrawingBoardModes.CREATE ,ServiceInstanceActions.Create, true], ['Create action VIEW mode',DrawingBoardModes.VIEW , ServiceInstanceActions.Create,false], @@ -306,205 +338,8 @@ describe('Shared Tree Service', () => { let res = service.shouldShowRemoveAndEdit(node); expect(res).toBe(enabled); }); + }); -function generateService() { - return { - "vnfs": { - "2017-488_PASQUALE-vPE 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-488_PASQUALE-vPE 0", - "isMissingData": false, - "trackById": "stigekyxrqi", - "vfModules": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": { - "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0gytfi": { - "isMissingData": false, - "sdncPreReload": null, - "modelInfo": { - "modelType": "VFmodule", - "modelInvariantId": "b34833bb-6aa9-4ad6-a831-70b06367a091", - "modelVersionId": "f8360508-3f17-4414-a2ed-6bc71161e8db", - "modelName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0", - "modelVersion": "5", - "modelCustomizationId": "a55961b2-2065-4ab0-a5b7-2fcee1c227e3", - "modelCustomizationName": "2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0" - }, - "instanceParams": [{}], - "trackById": "3oj23o7nupo" - } - } - }, - "vnfStoreKey": "2017-488_PASQUALE-vPE 0", - "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "lineOfBusiness": "ONAP", - "platformName": "xxx1", - "modelInfo": { - "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "modelVersionId": "69e09f68-8b63-4cc9-b9ff-860960b5db09", - "modelName": "2017-488_PASQUALE-vPE", - "modelVersion": "5.0", - "modelCustomizationName": "2017-488_PASQUALE-vPE 0", - "modelCustomizationId": "1da7b585-5e61-4993-b95e-8e6606c81e45", - "uuid": "69e09f68-8b63-4cc9-b9ff-860960b5db09" - }, - "legacyRegion": "11111111", - "instanceParams": [{}] - }, - "2017-388_PASQUALE-vPE 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-388_PASQUALE-vPE 0", - "isMissingData": false, - "trackById": "nib719t5vca", - "vfModules": {}, - "vnfStoreKey": "2017-388_PASQUALE-vPE 0", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "11111", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": "zzz1", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "72e465fe-71b1-4e7b-b5ed-9496118ff7a8", - "modelVersionId": "afacccf6-397d-45d6-b5ae-94c39734b168", - "modelName": "2017-388_PASQUALE-vPE", - "modelVersion": "4.0", - "modelCustomizationId": "b3c76f73-eeb5-4fb6-9d31-72a889f1811c", - "modelCustomizationName": "2017-388_PASQUALE-vPE 0", - "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" - }, - "uuid": "afacccf6-397d-45d6-b5ae-94c39734b168" - }, - "2017-388_PASQUALE-vPE 1": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "2017-388_PASQUALE-vPE 1", - "isMissingData": false, - "trackById": "cv7l1ak8vpe", - "vfModules": {}, - "vnfStoreKey": "2017-388_PASQUALE-vPE 1", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "123", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": "ONAP", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "00beb8f9-6d39-452f-816d-c709b9cbb87d", - "modelVersionId": "0903e1c0-8e03-4936-b5c2-260653b96413", - "modelName": "2017-388_PASQUALE-vPE", - "modelVersion": "1.0", - "modelCustomizationId": "280dec31-f16d-488b-9668-4aae55d6648a", - "modelCustomizationName": "2017-388_PASQUALE-vPE 1", - "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413" - }, - "uuid": "0903e1c0-8e03-4936-b5c2-260653b96413" - } - }, - "instanceParams": [{}], - "validationCounter": 0, - "existingNames": {"yoav": ""}, - "existingVNFCounterMap": { - "69e09f68-8b63-4cc9-b9ff-860960b5db09": 1, - "afacccf6-397d-45d6-b5ae-94c39734b168": 1, - "0903e1c0-8e03-4936-b5c2-260653b96413": 1 - }, - "existingVnfGroupCounterMap": { - "daeb6568-cef8-417f-9075-ed259ce59f48": 0, - "c2b300e6-45de-4e5e-abda-3032bee2de56": -1 - }, - "existingNetworksCounterMap": {"ddc3f20c-08b5-40fd-af72-c6d14636b986": 1}, - "networks": { - "ExtVL 0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "ExtVL 0", - "isMissingData": false, - "trackById": "s6okajvv2n8", - "networkStoreKey": "ExtVL 0", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "legacyRegion": "12355555", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "platformName": "platform", - "lineOfBusiness": null, - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "379f816b-a7aa-422f-be30-17114ff50b7c", - "modelVersionId": "ddc3f20c-08b5-40fd-af72-c6d14636b986", - "modelName": "ExtVL", - "modelVersion": "37.0", - "modelCustomizationId": "94fdd893-4a36-4d70-b16a-ec29c54c184f", - "modelCustomizationName": "ExtVL 0", - "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986" - }, - "uuid": "ddc3f20c-08b5-40fd-af72-c6d14636b986" - } - }, - "vnfGroups": { - "groupingservicefortest..ResourceInstanceGroup..0": { - "inMaint": false, - "rollbackOnFailure": "true", - "originalName": "groupingservicefortest..ResourceInstanceGroup..0", - "isMissingData": false, - "trackById": "se0obn93qq", - "vnfGroupStoreKey": "groupingservicefortest..ResourceInstanceGroup..0", - "instanceName": "groupingservicefortestResourceInstanceGroup0", - "instanceParams": [{}], - "modelInfo": { - "modelInvariantId": "4bb2e27e-ddab-4790-9c6d-1f731bc14a45", - "modelVersionId": "daeb6568-cef8-417f-9075-ed259ce59f48", - "modelName": "groupingservicefortest..ResourceInstanceGroup..0", - "modelVersion": "1", - "modelCustomizationName": "groupingservicefortest..ResourceInstanceGroup..0", - "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48" - }, - "uuid": "daeb6568-cef8-417f-9075-ed259ce59f48" - } - }, - "instanceName": "yoav", - "globalSubscriberId": "e433710f-9217-458d-a79d-1c7aff376d89", - "subscriptionServiceType": "TYLER SILVIA", - "owningEntityId": "d61e6f2d-12fa-4cc2-91df-7c244011d6fc", - "productFamilyId": "d8a6ed93-251c-47ca-adc9-86671fd19f4c", - "lcpCloudRegionId": "AAIAIC25", - "tenantId": "092eb9e8e4b7412e8787dd091bc58e86", - "aicZoneId": "ATL53", - "pause": null, - "projectName": "WATKINS", - "rollbackOnFailure": "true", - "bulkSize": 1, - "aicZoneName": "AAIATLTE-ATL53", - "owningEntityName": "WayneHolland", - "testApi": "VNF_API", - "isEcompGeneratedNaming": false, - "tenantName": "USP-SIP-IC-24335-T-01", - "modelInfo": { - "modelInvariantId": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632", - "modelVersionId": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", - "modelName": "action-data", - "modelVersion": "1.0", - "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd" - }, - "isALaCarte": false, - "name": "action-data", - "version": "1.0", - "description": "PASQUALE vMX vPE based on Juniper 17.2 release. Updated with updated VF for v8.0 of VLM", - "category": "Network L1-3", - "uuid": "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd", - "invariantUuid": "cdb90b57-ed78-4d44-a5b4-7f43a02ec632", - "serviceType": "pnf", - "serviceRole": "Testing", - "vidNotions": {"instantiationUI": "legacy", "modelCategory": "other", "viewEditUI": "legacy"}, - "isMultiStepDesign": true - }; -} function getStore() { return { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts index 6c985ec6a..669f9b675 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/shared.tree.service.ts @@ -139,8 +139,8 @@ export class SharedTreeService { /********************************************** * should return true if can delete **********************************************/ - shouldShowDelete(node): boolean { - return this.shouldShowButtonGeneric(node, "delete") + shouldShowDelete(node, serviceModelId): boolean { + return this.shouldShowButtonGeneric(node, "delete", serviceModelId) } /********************************************** @@ -193,7 +193,7 @@ export class SharedTreeService { shouldShowUpgrade(node, serviceModelId): boolean { if (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) && this.isThereAnUpdatedLatestVersion(serviceModelId)) { - return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE); + return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE, serviceModelId); } else { return false @@ -201,12 +201,22 @@ export class SharedTreeService { } private isThereAnUpdatedLatestVersion(serviceModelId) : boolean{ - let serviceInstance = this._store.getState().service.serviceInstance[serviceModelId]; + let serviceInstance = this.getServiceInstance(serviceModelId); return !_.isNil(serviceInstance.latestAvailableVersion) && (Number(serviceInstance.modelInfo.modelVersion) < serviceInstance.latestAvailableVersion); } - private shouldShowButtonGeneric(node, method) { + private getServiceInstance(serviceModelId): any { + return this._store.getState().service.serviceInstance[serviceModelId]; + } + + shouldShowButtonGeneric(node, method, serviceModelId) { const mode = this._store.getState().global.drawingBoardStatus; + const isMacro = !(this.getServiceInstance(serviceModelId).isALaCarte); + + if (isMacro) { //if macro action allowed only for service level + return false; + } + if (!_.isNil(node) && !_.isNil(node.data) && !_.isNil(node.data.action) && !_.isNil(node.data.menuActions[method])) { if (mode !== DrawingBoardModes.EDIT || node.data.action === ServiceInstanceActions.Create) { return false; @@ -288,7 +298,7 @@ export class SharedTreeService { ************************************************/ getExistingInstancesWithDeleteMode(node, serviceModelId: string, type: string): number { let counter = 0; - const existingInstances = this._store.getState().service.serviceInstance[serviceModelId][type]; + const existingInstances = this.getServiceInstance(serviceModelId)[type]; const modelUniqueId = node.data.modelUniqueId; if (!_.isNil(existingInstances)) { for (let instanceKey in existingInstances) { |