diff options
Diffstat (limited to 'vid-webpack-master/src/app/drawingBoard')
15 files changed, 289 insertions, 374 deletions
diff --git a/vid-webpack-master/src/app/drawingBoard/drawingBoard.module.ts b/vid-webpack-master/src/app/drawingBoard/drawingBoard.module.ts index 67b54059e..25d170320 100644 --- a/vid-webpack-master/src/app/drawingBoard/drawingBoard.module.ts +++ b/vid-webpack-master/src/app/drawingBoard/drawingBoard.module.ts @@ -40,7 +40,7 @@ import {VpnStepService} from "./service-planning/objectsToTree/models/vrf/vrfMod @NgModule({ imports: [ - TreeModule, + TreeModule.forRoot(), BrowserModule, ContextMenuModule, FormsModule, diff --git a/vid-webpack-master/src/app/drawingBoard/guards/servicePlanningGuard/drawingBoardGuard.ts b/vid-webpack-master/src/app/drawingBoard/guards/servicePlanningGuard/drawingBoardGuard.ts index 4a305b193..d486fb4fa 100644 --- a/vid-webpack-master/src/app/drawingBoard/guards/servicePlanningGuard/drawingBoardGuard.ts +++ b/vid-webpack-master/src/app/drawingBoard/guards/servicePlanningGuard/drawingBoardGuard.ts @@ -1,18 +1,17 @@ import {Injectable} from "@angular/core"; -import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from "@angular/router"; +import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from "@angular/router"; import {NgRedux} from "@angular-redux/store"; -import {Observable} from "rxjs"; +import {Observable, of} from "rxjs"; import {HttpClient} from "@angular/common/http"; import {AppState} from "../../../shared/store/reducers"; import {updateDrawingBoardStatus} from "../../../shared/storeUtil/utils/global/global.actions"; import {DrawingBoardModes} from "../../service-planning/drawing-board.modes"; -import {of} from "rxjs"; @Injectable() export class DrawingBoardGuard implements CanActivate { constructor(private store: NgRedux<AppState>, private _http: HttpClient, private _router : Router) { } canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> { - let url : string = `/vid/roles/service_permissions?subscriberId=${next.queryParams['subscriberId']}&serviceType=${next.queryParams['serviceType']}`; + let url : string = `../../roles/service_permissions?subscriberId=${next.queryParams['subscriberId']}&serviceType=${next.queryParams['serviceType']}`; const viewMode = state.url.includes(DrawingBoardModes.RETRY_EDIT)? DrawingBoardModes.RETRY: DrawingBoardModes.VIEW; return this._http.get(url) .map((result : DrawingBoardPermissions) => { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.html b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.html index 46807607d..7a18bce89 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.html +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.html @@ -7,7 +7,7 @@ [testId]="'backBtn'" [size]="'large'" [name]="'navigation-arrow-back'"> - </svg-icon> + </svg-icon> </span> <div class="header-col middleDetails" style="padding-top: 7px;padding-left: 13px;line-height: 100%;" *ngIf="isServiceFailed"> @@ -38,10 +38,13 @@ <span [attr.data-tests-id]="'isViewOnly-status-test'" class="service-instance-label purple">{{getModeName()}}</span> </div> - <div class="right-header"> - <span class="action-status-type-header delete" [attr.data-tests-id]="'delete-status-type-header'" *ngIf="isDeleted === true">Delete</span> - <span class="action-status-type-header resume" [attr.data-tests-id]="'resume-status-type-header'" *ngIf="isResume === true">Resume</span> + <span + *ngIf = "isUpgrade || isDeleted || isResume" + [ngClass] = "isDeleted===true ? 'action-status-type-header delete' : 'action-status-type-header resume'" + [attr.data-tests-id]="determineDataTestId()"> + {{getAction()}} + </span> <span class="menu-container notShowOnViewMode notShowOnRetryMode"> <span [attr.data-tests-id]="'openMenuBtn'" class="icon-browse" (click)="onContextMenu($event)"></span> <context-menu> diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.ts index 51f90534b..7923313bf 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.component.ts @@ -39,12 +39,16 @@ export class DrawingBoardHeader { mode : DrawingBoardModes = DrawingBoardModes.CREATE; serviceOrchStatus: string; isDeleted: boolean = false; + isUpgrade: boolean = false; isResume: boolean = false; store : NgRedux<AppState>; drawingBoardPermissions : DrawingBoardPermissions; drawingBoardHeaderService : DrawingBoardHeaderService; isServiceFailed: boolean; serviceStatusMessage: string; + private readonly action: string; + private presentedAction: string; + constructor(private _contextMenuService: ContextMenuService, private dialogService: DialogService, private _iframeService : IframeService, private route: ActivatedRoute, private msoService: MsoService, @@ -68,6 +72,11 @@ export class DrawingBoardHeader { }); } }); + if (!_.isNil(this.store.getState().service.serviceInstance[this.serviceModelId].action)){ + if (this.store.getState().service.serviceInstance[this.serviceModelId].action.includes("Upgrade")) { + this.isUpgrade = true; + } + } } @@ -114,6 +123,7 @@ export class DrawingBoardHeader { this.serviceOrchStatus = serviceInstance.orchStatus || ""; this.isServiceFailed = serviceInstance.isFailed; this.serviceStatusMessage = serviceInstance.statusMessage; + this.isUpgrade = serviceInstance.isUpgraded; } } @@ -131,12 +141,25 @@ export class DrawingBoardHeader { }); } + + onDeleteUndoDeleteClick(){ this.cancelResume(this.serviceModelId); this.isDeleted = !this.isDeleted; this._drawingBoardHeaderService.deleteService(this.serviceModelId, this.isDeleted) } + determineDataTestId() :string { + switch(true) { + case this.isResume: + return'resume-status-type-header'; + case this.isDeleted: + return 'delete-status-type-header'; + case this.isUpgrade: + return 'upgrade-status-type-header'; + } + } + onResumeUndoResumeClick(){ this.cancelDelete(this.serviceModelId); this.isResume = !this.isResume; @@ -174,9 +197,14 @@ export class DrawingBoardHeader { instanceFields.subscriberName = this.store.getState().service.subscribers.find(sub => sub.id === instanceFields.globalSubscriberId).name; instanceFields.owningEntityName = this.extractOwningEntityNameAccordingtoId(instanceFields.owningEntityId); } - return _.omit(instanceFields,'optionalGroupMembersMap'); + return _.omit(instanceFields,['optionalGroupMembersMap', 'upgradedVFMSonsCounter', 'isUpgraded', 'latestAvailableVersion']); } + private getAction(): string { + if(!_.isNil(this.store.getState().service.serviceInstance[this.serviceModelId].action)) + return this.store.getState().service.serviceInstance[this.serviceModelId].action.split('_').pop(); + return; + } public deployService(): void { let instanceFields = this.extractServiceFields(); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts index 7df2f3a3f..1b71d9098 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-header/drawing-board-header.service.ts @@ -36,6 +36,15 @@ export class DrawingBoardHeaderService{ } } + upgradeService(serviceModelId: string, isUpgraded: boolean ) { + if(isUpgraded){ + this.store.dispatch(addServiceAction(serviceModelId, ServiceInstanceActions.Upgrade)); + } + else{ + this.store.dispatch(addServiceAction(serviceModelId, ServiceInstanceActions.None)); + } + } + showAuditInfo(serviceModelId) : void { let instance: ServiceInstance = this.store.getState().service.serviceInstance[serviceModelId]; let model = new ServiceModel(this.store.getState().service.serviceHierarchy[serviceModelId]); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts index 6be5036b2..0e2d8e276 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.component.ts @@ -28,6 +28,7 @@ import {ComponentInfoService} from "../component-info/component-info.service"; import {ComponentInfoModel} from "../component-info/component-info-model"; import {ObjectToModelTreeService} from "../objectsToTree/objectToModelTree/objectToModelTree.service"; import {DrawingBoardModes} from "../drawing-board.modes"; +import {ServiceInstanceActions} from "../../../shared/models/serviceInstanceActions"; @Component({ selector: 'drawing-board-tree', @@ -203,6 +204,24 @@ export class DrawingBoardTreeComponent implements OnInit, AfterViewInit { return false; } + + + isUpgraded(node: ITreeNode): boolean { + return this.isLabeledAsAction(node, "Upgrade"); + } + + isDeleted(node: ITreeNode): boolean { + return this.isLabeledAsAction(node, "Delete"); + } + + private isLabeledAsAction(node: ITreeNode, action) { + let nodeAction = node.data.action.split('_').pop(); + if (!_.isNil(nodeAction)) { + return nodeAction === action; + } + return false; + } + public selectNode(node: ITreeNode): void { node.expand(); this._sharedTreeService.setSelectedVNF(node); @@ -220,6 +239,13 @@ export class DrawingBoardTreeComponent implements OnInit, AfterViewInit { this.tree.treeModel.getNodeById(id).parent.expand(); } + getcontextMenuOptionLabel(contextMenuOption: TreeNodeContextMenuModel): string{ + let optionLabel = contextMenuOption.label; + if(contextMenuOption.label === ServiceInstanceActions.Upgrade) { + return optionLabel.concat(" to V" + this._store.getState().service.serviceInstance[this.serviceModelId].latestAvailableVersion); + } + return optionLabel; + } } diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html index e1d88a696..8db53e808 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.html @@ -78,12 +78,12 @@ <div [attr.data-tests-id]="contextMenuOption.dataTestId"> <div style="float: left;margin-top: 3px;"> <svg-icon - [ngClass]="contextMenuOption.iconClass" class="icon-edit" + [ngClass]="contextMenuOption.iconClass" [size]="'small'" [name]="contextMenuOption.iconClass"> </svg-icon></div> - <div style="padding-left: 25px;">{{contextMenuOption.label}}</div> + <div style="padding-left: 25px;">{{getcontextMenuOptionLabel(contextMenuOption)}}</div> </div> </ng-template> </context-menu> @@ -100,16 +100,17 @@ [size]="'medium'" [name]="'alert-triangle-o'"> </svg-icon> - </span> + </span> <span *ngIf="drawingBoardTreeService.isVFModuleMissingData(node, serviceModelId)" class="icon-alert" tooltip="{{ missingDataTooltip }}" tooltipPlacement="left" [attr.data-tests-id]="'node-'+node.data.modelId +'-' +node.data.modelName+'-alert-icon'"></span> </div> <div class="action-status"> - <span class="action-status-type delete" [attr.data-tests-id]="'delete-status-type'" [ngStyle]="{ 'opacity': node.data.action.split('_').pop() !== 'Delete' ? '0' : '1'}">Delete</span> + <span + [ngClass]="isUpgraded(node)?'action-status-type upgrade':'action-status-type delete'" + [attr.data-tests-id]="isUpgraded(node)?'action-status-type':'delete-status-type'" [ngStyle]="{ 'opacity': isUpgraded(node) || isDeleted(node) ? '1' : '0'}">{{isUpgraded(node)?"Upgrade":"Delete"}}</span> </div> - </div> </ng-template> </tree-root> @@ -117,3 +118,4 @@ + diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.scss b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.scss index e08e69e2e..b774e03b6 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.scss +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.scss @@ -341,15 +341,21 @@ drawing-board-tree { line-height: 42px; width: 95px; min-width: 95px; - .action-status-type.delete { + .action-status-type { background: transparent; font-family: OpenSans-SemiBold; font-size: 12px; - color: red; border-radius: 50px; border: 1px solid gray; - padding: 5px 20px; + padding: 5px 17px; + &.delete { + color: red; + } + &.upgrade{ + color: #009FDB; + } } + } .model-info.rightBorder { diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.spec.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.spec.ts index b804342c6..e5979f7ed 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.spec.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.spec.ts @@ -1,8 +1,5 @@ -import {TestBed, getTestBed} from '@angular/core/testing'; -import { - HttpClientTestingModule, - HttpTestingController -} from '@angular/common/http/testing'; +import {getTestBed, TestBed} from '@angular/core/testing'; +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {NgRedux} from "@angular-redux/store"; import {DrawingBoardTreeService, TreeNodeContextMenuModel} from "./drawing-board-tree.service"; import {ITreeNode} from "angular-tree-component/dist/defs/api"; @@ -74,10 +71,12 @@ describe('Drawing board tree Service', () => { new TreeNodeContextMenuModel('addGroupMember', 'context-menu-addGroupMember', 'Add group members', 'plus'), new TreeNodeContextMenuModel('delete', 'context-menu-delete', 'Delete', 'trash-o'), new TreeNodeContextMenuModel('remove', 'context-menu-remove', 'Remove', 'trash-o'), + new TreeNodeContextMenuModel('upgrade', 'context-menu-upgrade', 'Upgrade', 'upgrade'), new TreeNodeContextMenuModel('undoDelete', 'context-menu-undoDelete', 'Undo Delete', 'undo-delete'), + new TreeNodeContextMenuModel('undoUpgrade', 'context-menu-undoUpgrade', 'Undo Upgrade', 'undo-delete'), new TreeNodeContextMenuModel('changeAssociations', 'context-menu-changeAssociations', 'Change Associations', 'edit-file-o') ]; - expect(options.length).toEqual(8); + expect(options.length).toEqual(10); expect(options).toEqual(expected); }); diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.ts index acf622463..28b6e51b1 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/drawing-board-tree/drawing-board-tree.service.ts @@ -42,7 +42,9 @@ export class DrawingBoardTreeService { new TreeNodeContextMenuModel('addGroupMember', 'context-menu-addGroupMember', 'Add group members', 'plus'), new TreeNodeContextMenuModel('delete', 'context-menu-delete', 'Delete', 'trash-o'), new TreeNodeContextMenuModel('remove', 'context-menu-remove', 'Remove', 'trash-o'), + new TreeNodeContextMenuModel('upgrade', 'context-menu-upgrade', 'Upgrade', 'upgrade'), new TreeNodeContextMenuModel('undoDelete', 'context-menu-undoDelete', 'Undo Delete', 'undo-delete'), + new TreeNodeContextMenuModel('undoUpgrade', 'context-menu-undoUpgrade', 'Undo Upgrade', 'undo-delete'), new TreeNodeContextMenuModel('changeAssociations', 'context-menu-changeAssociations', 'Change Associations', 'edit-file-o') ]; } 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 bfe1d0082..47a6dcb50 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 @@ -23,10 +23,12 @@ import { deleteActionVfModuleInstance, removeVfModuleInstance, undoDeleteVfModuleInstance, - updateVFModulePosition + undoUgradeVFModule, + updateVFModulePosition, + upgradeVFModule } from "../../../../../shared/storeUtil/utils/vfModule/vfModule.actions"; import {ComponentInfoService} from "../../../component-info/component-info.service"; -import {ComponentInfoModel, ComponentInfoType} from "../../../component-info/component-info-model"; +import {ComponentInfoType} from "../../../component-info/component-info-model"; import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component"; export class VFModuleModelInfo implements ILevelNodeInfo { @@ -353,10 +355,32 @@ export class VFModuleModelInfo implements ILevelNodeInfo { }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && this._sharedTreeService.shouldShowDelete(node.parent) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) - } + }, + upgrade : { + method : (node, serviceModelId) => { + this._sharedTreeService.upgradeBottomUp(node, serviceModelId); + this._store.dispatch(upgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.dynamicModelName)); + }, + visible: (node,serviceModelId) => { + return this._sharedTreeService.shouldShowUpgrade(node, serviceModelId); + }, + enable: (node, serviceModelId) => { + return this._sharedTreeService.shouldShowUpgrade(node, serviceModelId); + } + }, + undoUpgrade: { + method: (node, serviceModelId) => { + this._sharedTreeService.undoUpgradeBottomUp(node, serviceModelId); + this._store.dispatch(undoUgradeVFModule(node.data.modelName, node.parent.data.vnfStoreKey, serviceModelId, node.data.dynamicModelName)); + }, + visible: (node) => { + return this._sharedTreeService.shouldShowUndoUpgrade(node); + }, + enable: (node) => { + return this._sharedTreeService.shouldShowUndoUpgrade(node); + } + }, }; - - } updatePosition(that , node, instanceId, parentStoreKey): void { 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 2bdeda083..ebcba162e 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 @@ -29,7 +29,9 @@ import {ServiceInstanceActions} from "../../../../../shared/models/serviceInstan import { deleteActionVnfInstance, undoDeleteActionVnfInstance, - updateVnfPosition + undoUpgradeVnf, + updateVnfPosition, + upgradeVnf } from "../../../../../shared/storeUtil/utils/vnf/vnf.actions"; import * as _ from 'lodash'; import {IModalConfig} from "onap-ui-angular/dist/modals/models/modal-config"; @@ -278,7 +280,21 @@ export class VnfModelInfo implements ILevelNodeInfo { }, visible: (node) => this._sharedTreeService.shouldShowUndoDelete(node), enable: (node, serviceModelId) => this._sharedTreeService.shouldShowUndoDelete(node) && !this._sharedTreeService.isServiceOnDeleteMode(serviceModelId) - } + }, + upgrade: { + method: (node, serviceModelId) => { + this._store.dispatch(upgradeVnf(node.data.vnfStoreKey, serviceModelId)); + }, + visible: () => false, + enable: () => false + }, + undoUpgrade: { + method: (node, serviceModelId) => { + this._store.dispatch(undoUpgradeVnf(node.data.vnfStoreKey, serviceModelId)); + }, + visible: () => false, + enable: () => false + }, } } diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.ts index 9cd928e8f..f303434a8 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/vrf/vrfModal/networkStep/network.step.service.ts @@ -8,7 +8,9 @@ import { } from "../../../../../../../shared/storeUtil/utils/global/global.actions"; import {ElementsTableService} from "../../../../../../../shared/components/searchMembersModal/members-table/elements-table.service"; import { - ICriteria, ISearchField, ITableContent, + ICriteria, + ISearchField, + ITableContent, ModalInformation } from "../../../../../../../shared/components/searchMembersModal/members-table/element-table-row.model"; import {Observable, of} from "rxjs"; @@ -76,7 +78,7 @@ export class NetworkStepService { getNetworks = (serviceInstance): Observable<any[]> => { let cloudRegion = serviceInstance.lcpCloudRegionId; - let tenantId = serviceInstance.tenantName; + let tenantId = serviceInstance.tenantId; return this._aaiService.retrieveActiveNetwork(cloudRegion, tenantId).map((networks: NetworkModalRow[]) => { this.generateRolesOptions(networks); return this.sortElementsResultByField(networks, this.uniqObjectField); 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 cad23ffd9..89e20a2d6 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 @@ -50,13 +50,27 @@ class MockAppStore<T> { } } -class MockVnfModelInfo<T> { - getModel() { - return {} + + + +function getNodeWithData(menuAction:string){ + const nodeData = { + menuActions: {} + }; + nodeData['menuActions'][menuAction] = { + method: (node, serviceModelId) => {} } + const node = { + parent: { + data: nodeData, + parent: { + data: nodeData + } + } + }; + return node } - describe('Shared Tree Service', () => { let injector; let service: SharedTreeService; @@ -110,6 +124,25 @@ describe('Shared Tree Service', () => { expect(service).toBeDefined(); }); + test('SharedTreeService upgradeBottomUp should call redux actions', () => { + const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; + 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); + expect(node.parent.data.menuActions['upgrade'].method).toBeCalledTimes(2); + + }); + + test('SharedTreeService undoUpgradeBottomUp should call redux actions', () => { + const serviceModelId = "1a80c596-27e5-4ca9-b5bb-e03a7fd4c0fd"; + 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); + expect(node.parent.data.menuActions['undoUpgrade'].method).toBeCalledTimes(2); + }); + test('shouldShowDeleteInstanceWithChildrenModal should open modal if child exist with action create', () => { jest.spyOn(MessageBoxService.openModal, 'next'); let foo = () => { @@ -128,7 +161,9 @@ describe('Shared Tree Service', () => { test('openAuditInfoModal should open modal for failed instance', () => { jest.spyOn(AuditInfoModalComponent.openInstanceAuditInfoModal, 'next'); - let modelInfoServiceMock: ILevelNodeInfo = new VnfModelInfo(null, null, null, null, null, null, null, null, null, null,null); + let modelInfoServiceMock: ILevelNodeInfo = new VnfModelInfo(null, null, + null, null, null, null, + null, null, null, null,null); const modelMock = {"a": "a"}; const instanceMock = {"instance": "instance", "trackById": "123456789"}; const instanceTypeMock = "instanceTypeMock"; @@ -1331,128 +1366,8 @@ function getStore() { "isPermitted": true, "cloudOwner": "irma-aic" }, { - "id": "229bcdc6eaeb4ca59d55221141d01f8e", - "name": "AIN Web Tool-15-D-STTest2", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "1178612d2b394be4834ad77f567c0af2", - "name": "AIN Web Tool-15-D-SSPtestcustome", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "19c5ade915eb461e8af52fb2fd8cd1f2", - "name": "AIN Web Tool-15-D-UncheckedEcopm", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "de007636e25249238447264a988a927b", - "name": "AIN Web Tool-15-D-dfsdf", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "62f29b3613634ca6a3065cbe0e020c44", - "name": "AIN/SMS-16-D-Multiservices1", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "649289e30d3244e0b48098114d63c2aa", - "name": "AIN Web Tool-15-D-SSPST66", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "3f21eeea6c2c486bba31dab816c05a32", - "name": "AIN Web Tool-15-D-ASSPST47", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "f60ce21d3ee6427586cff0d22b03b773", - "name": "CESAR-100-D-sspjg67246", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "8774659e425f479895ae091bb5d46560", - "name": "CESAR-100-D-sspjg68359", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "624eb554b0d147c19ff8885341760481", - "name": "AINWebTool-15-D-iftach", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "214f55f5fc414c678059c383b03e4962", - "name": "CESAR-100-D-sspjg612401", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "c90666c291664841bb98e4d981ff1db5", - "name": "CESAR-100-D-sspjg621340", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "ce5b6bc5c7b348e1bf4b91ac9a174278", - "name": "sspjg621351cloned", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "b386b768a3f24c8e953abbe0b3488c02", - "name": "AINWebTool-15-D-eteancomp", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "dc6c4dbfd225474e9deaadd34968646c", - "name": "AINWebTool-15-T-SPFET", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "02cb5030e9914aa4be120bd9ed1e19eb", - "name": "AINWebTool-15-X-eeweww", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "f2f3830e4c984d45bcd00e1a04158a79", - "name": "CESAR-100-D-spjg61909", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "05b91bd5137f4929878edd965755c06d", - "name": "CESAR-100-D-sspjg621512cloned", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "7002fbe8482d4a989ddf445b1ce336e0", - "name": "AINWebTool-15-X-vdr", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "4008522be43741dcb1f5422022a2aa0b", - "name": "AINWebTool-15-D-ssasa", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "f44e2e96a1b6476abfda2fa407b00169", - "name": "AINWebTool-15-D-PFNPT", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "b69a52bec8a84669a37a1e8b72708be7", - "name": "AINWebTool-15-X-vdre", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "fac7d9fd56154caeb9332202dcf2969f", - "name": "AINWebTool-15-X-NONPODECOMP", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "2d34d8396e194eb49969fd61ffbff961", - "name": "DN5242-Nov16-T5", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "cb42a77ff45b48a8b8deb83bb64acc74", - "name": "ro-T11", + "id": "d0a3e3f2964542259d155a81c41aadc3", + "name": "test-hvf6-09", "isPermitted": true, "cloudOwner": "irma-aic" }, { @@ -1461,16 +1376,6 @@ function getStore() { "isPermitted": true, "cloudOwner": "irma-aic" }, { - "id": "4914ab0ab3a743e58f0eefdacc1dde77", - "name": "DN5242-Nov21-T1", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { - "id": "d0a3e3f2964542259d155a81c41aadc3", - "name": "test-hvf6-09", - "isPermitted": true, - "cloudOwner": "irma-aic" - }, { "id": "cbb99fe4ada84631b7baf046b6fd2044", "name": "DN5242-Nov16-T3", "isPermitted": true, @@ -1567,199 +1472,28 @@ function getStore() { "isPermitted": false }, {"id": "7", "name": "vVM", "isPermitted": false}, {"id": "4", "name": "vVoiceMail", "isPermitted": false}] }, - "aicZones": [{"id": "ATL53", "name": "AAIATLTE-ATL53"}, {"id": "ABC15", "name": "AAITESAN-ABC15"}, { - "id": "TES36", - "name": "ABCEETES-TES36" - }, {"id": "ATL54", "name": "AICFTAAI-ATL54"}, {"id": "ATL43", "name": "AICLOCID-ATL43"}, { - "id": "AMD15", - "name": "AMDFAA01-AMD15" - }, {"id": "AMF11", "name": "AMDOCS01-AMF11"}, {"id": "RCT1", "name": "AMSTERNL-RCT1"}, { - "id": "AMS1", - "name": "AMSTNLBW-AMS1" - }, {"id": "HJH1", "name": "AOEEQQQD-HJH1"}, {"id": "HJE1", "name": "AOEEWWWD-HJE1"}, { - "id": "MCS1", - "name": "ASACMAMS-MCS1" - }, {"id": "AUG1", "name": "ASDFGHJK-AUG1"}, {"id": "LUC1", "name": "ATLDFGYC-LUC1"}, { - "id": "ATL1", - "name": "ATLNGAMA-ATL1" - }, {"id": "ATL2", "name": "ATLNGANW-ATL2"}, {"id": "HPO1", "name": "ATLNGAUP-HPO1"}, { - "id": "ANI1", - "name": "ATLNGTRE-ANI1" - }, {"id": "ATL44", "name": "ATLSANAB-ATL44"}, {"id": "ATL56", "name": "ATLSANAC-ATL56"}, { - "id": "ABC11", - "name": "ATLSANAI-ABC11" - }, {"id": "ATL34", "name": "ATLSANAI-ATL34"}, {"id": "ATL63", "name": "ATLSANEW-ATL63"}, { - "id": "ABC12", - "name": "ATLSECIA-ABC12" - }, {"id": "AMD18", "name": "AUDIMA01-AMD18"}, {"id": "AVT1", "name": "AVTRFLHD-AVT1"}, { - "id": "KIT1", - "name": "BHYJFGLN-KIT1" - }, {"id": "BHY17", "name": "BHYTFRF3-BHY17"}, {"id": "RTW5", "name": "BHYTFRY4-RTW5"}, { - "id": "RTZ4", - "name": "BHYTFRZ6-RTZ4" - }, {"id": "RTD2", "name": "BHYTFRk4-RTD2"}, {"id": "BNA1", "name": "BNARAGBK-BNA1"}, { - "id": "VEL1", - "name": "BNMLKUIK-VEL1" - }, {"id": "BOT1", "name": "BOTHWAKY-BOT1"}, {"id": "CAL33", "name": "CALIFORN-CAL33"}, { - "id": "ATL84", - "name": "CANTTCOC-ATL84" - }, {"id": "HSD1", "name": "CHASKCDS-HSD1"}, {"id": "CHI1", "name": "CHILLIWE-CHI1"}, { - "id": "XCP12", - "name": "CHKGH123-XCP12" - }, {"id": "JNL1", "name": "CJALSDAC-JNL1"}, {"id": "KJN1", "name": "CKALDKSA-KJN1"}, { - "id": "CLG1", - "name": "CLGRABAD-CLG1" - }, {"id": "CKL1", "name": "CLKSKCKK-CKL1"}, {"id": "ATL66", "name": "CLLIAAII-ATL66"}, { - "id": "CQK1", - "name": "CQKSCAKK-CQK1" - }, {"id": "CWY1", "name": "CWYMOWBS-CWY1"}, {"id": "DKJ1", "name": "DKJSJDKA-DKJ1"}, { - "id": "DSF45", - "name": "DSFBG123-DSF45" - }, {"id": "DSL12", "name": "DSLFK242-DSL12"}, {"id": "FDE55", "name": "FDERT555-FDE55"}, { - "id": "VEN2", - "name": "FGHJUHIL-VEN2" - }, {"id": "ATL64", "name": "FORLOAAJ-ATL64"}, {"id": "GNV1", "name": "GNVLSCTL-GNV1"}, { - "id": "SAN22", - "name": "GNVLSCTL-SAN22" - }, {"id": "KAP1", "name": "HIOUYTRQ-KAP1"}, {"id": "LIS1", "name": "HOSTPROF-LIS1"}, { - "id": "HRG1", - "name": "HRGHRGGS-HRG1" - }, {"id": "HST25", "name": "HSTNTX01-HST25"}, {"id": "STN27", "name": "HSTNTX01-STN27"}, { - "id": "HST70", - "name": "HSTNTX70-HST70" - }, {"id": "KOR1", "name": "HYFLNBVT-KOR1"}, {"id": "RAD10", "name": "INDIPUNE-RAD10"}, { - "id": "REL1", - "name": "INGERFGT-REL1" - }, {"id": "JAD1", "name": "JADECLLI-JAD1"}, {"id": "HKA1", "name": "JAKHLASS-HKA1"}, { - "id": "JCS1", - "name": "JCSJSCJS-JCS1" - }, {"id": "JCV1", "name": "JCVLFLBW-JCV1"}, {"id": "KGM2", "name": "KGMTNC20-KGM2"}, { - "id": "KJF12", - "name": "KJFDH123-KJF12" - }, {"id": "JGS1", "name": "KSJKKKKK-JGS1"}, {"id": "LAG1", "name": "LARGIZON-LAG1"}, { - "id": "LAG1a", - "name": "LARGIZON-LAG1a" - }, {"id": "LAG45", "name": "LARGIZON-LAG1a"}, {"id": "LAG1b", "name": "LARGIZON-LAG1b"}, { - "id": "WAN1", - "name": "LEIWANGW-WAN1" - }, {"id": "DSA1", "name": "LKJHGFDS-DSA1"}, {"id": "LON1", "name": "LONEENCO-LON1"}, { - "id": "SITE", - "name": "LONEENCO-SITE" - }, {"id": "ZXL1", "name": "LWLWCANN-ZXL1"}, {"id": "hvf20", "name": "MDTWNJ21-hvf20"}, { - "id": "hvf32", - "name": "MDTWNJ21-hvf32" - }, {"id": "AMD13", "name": "MEMATLAN-AMD13"}, {"id": "MIC54", "name": "MICHIGAN-MIC54"}, { - "id": "MAR1", - "name": "MNBVCXZM-MAR1" - }, {"id": "NCA1", "name": "NCANCANN-NCA1"}, {"id": "NFT1", "name": "NFTJSSSS-NFT1"}, { - "id": "GAR1", - "name": "NGFVSJKO-GAR1" - }, {"id": "NYC1", "name": "NYCMNY54-NYC1"}, {"id": "OKC1", "name": "OKCBOK55-OKC1"}, { - "id": "OLG1", - "name": "OLHOLHOL-OLG1" - }, {"id": "OLK1", "name": "OLKOLKLS-OLK1"}, {"id": "NIR1", "name": "ORFLMANA-NIR1"}, { - "id": "JAN1", - "name": "ORFLMATT-JAN1" - }, {"id": "ORL1", "name": "ORLDFLMA-ORL1"}, {"id": "PAR1", "name": "PARSFRCG-PAR1"}, { - "id": "PBL1", - "name": "PBLAPBAI-PBL1" - }, {"id": "mac10", "name": "PKGTESTF-mac10"}, {"id": "mac20", "name": "PKGTESTF-mac20"}, { - "id": "TIR2", - "name": "PLKINHYI-TIR2" - }, {"id": "IBB1", "name": "PLMKOIJU-IBB1"}, {"id": "COM1", "name": "PLMKOPIU-COM1"}, { - "id": "POI1", - "name": "PLMNJKIU-POI1" - }, {"id": "PLT1", "name": "PLTNCA60-PLT1"}, {"id": "POI22", "name": "POIUY123-POI22"}, { - "id": "DCC1", - "name": "POIUYTGH-DCC1" - }, {"id": "DCC1a", "name": "POIUYTGH-DCC1a"}, {"id": "DCC1b", "name": "POIUYTGH-DCC1b"}, { - "id": "DCC2", - "name": "POIUYTGH-DCC2" - }, {"id": "DCC3", "name": "POIUYTGH-DCC3"}, {"id": "IAA1", "name": "QAZXSWED-IAA1"}, { - "id": "QWE1", - "name": "QWECLLI1-QWE1" - }, {"id": "NUM1", "name": "QWERTYUI-NUM1"}, {"id": "RAD1", "name": "RADICAL1-RAD1"}, { - "id": "RJN1", - "name": "RJNRBZAW-RJN1" - }, {"id": "SAA13", "name": "SAIT1AA9-SAA13"}, {"id": "SAA14", "name": "SAIT1AA9-SAA14"}, { - "id": "SDD81", - "name": "SAIT1DD6-SDD81" - }, {"id": "SDD82", "name": "SAIT1DD9-SDD82"}, {"id": "SAA11", "name": "SAIT9AA2-SAA11"}, { - "id": "SAA80", - "name": "SAIT9AA3-SAA80" - }, {"id": "SAA12", "name": "SAIT9AF8-SAA12"}, {"id": "SCC80", "name": "SAIT9CC3-SCC80"}, { - "id": "ATL75", - "name": "SANAAIRE-ATL75" - }, {"id": "ICC1", "name": "SANJITAT-ICC1"}, {"id": "SCK1", "name": "SCKSCKSK-SCK1"}, { - "id": "EHH78", - "name": "SDCSHHH5-EHH78" - }, {"id": "SAA78", "name": "SDCTAAA1-SAA78"}, {"id": "SAX78", "name": "SDCTAXG1-SAX78"}, { - "id": "SBX78", - "name": "SDCTBXG1-SBX78" - }, {"id": "SEE78", "name": "SDCTEEE4-SEE78"}, {"id": "SGG78", "name": "SDCTGGG1-SGG78"}, { - "id": "SXB78", - "name": "SDCTGXB1-SXB78" - }, {"id": "SJJ78", "name": "SDCTJJJ1-SJJ78"}, {"id": "SKK78", "name": "SDCTKKK1-SKK78"}, { - "id": "SLF78", - "name": "SDCTLFN1-SLF78" - }, {"id": "SLL78", "name": "SDCTLLL1-SLL78"}, {"id": "MAD11", "name": "SDFQWGKL-MAD11"}, { - "id": "HGD1", - "name": "SDFQWHGD-HGD1" - }, {"id": "SBB78", "name": "SDIT1BBB-SBB78"}, {"id": "SDG78", "name": "SDIT1BDG-SDG78"}, { - "id": "SBU78", - "name": "SDIT1BUB-SBU78" - }, {"id": "SHH78", "name": "SDIT1HHH-SHH78"}, {"id": "SJU78", "name": "SDIT1JUB-SJU78"}, { - "id": "SNA1", - "name": "SNANTXCA-SNA1" - }, {"id": "SAM1", "name": "SNDGCA64-SAN1"}, {"id": "SNG1", "name": "SNGPSIAU-SNG1"}, { - "id": "SSA56", - "name": "SSIT2AA7-SSA56" - }, {"id": "STG1", "name": "STTGGE62-STG1"}, {"id": "STT1", "name": "STTLWA02-STT1"}, { - "id": "SYD1", - "name": "SYDNAUBV-SYD1" - }, {"id": "ATL99", "name": "TEESTAAI-ATL43"}, {"id": "ATL98", "name": "TEESTAAI-ATL43"}, { - "id": "ATL76", - "name": "TELEPAAI-ATL76" - }, {"id": "ABC14", "name": "TESAAISA-ABC14"}, {"id": "TAT33", "name": "TESAAISA-TAT33"}, { - "id": "TAT34", - "name": "TESAAISB-TAT34" - }, {"id": "TAT37", "name": "TESAAISD-TAT37"}, {"id": "ATL62", "name": "TESSASCH-ATL62"}, { - "id": "TLP1", - "name": "TLPNXM18-TLP1" - }, {"id": "SAN13", "name": "TOKYJPFA-SAN13"}, {"id": "TOK1", "name": "TOKYJPFA-TOK1"}, { - "id": "TOL1", - "name": "TOLDOH21-TOL1" - }, {"id": "TOR1", "name": "TOROONXN-TOR1"}, {"id": "TOY1", "name": "TORYONNZ-TOY1"}, { - "id": "ATL35", - "name": "TTESSAAI-ATL35" - }, {"id": "TUF1", "name": "TUFCLLI1-TUF1"}, {"id": "SAI1", "name": "UBEKQLPD-SAI1"}, { - "id": "UUU4", - "name": "UUUAAAUU-UUU4" - }, {"id": "YYY1", "name": "UUUAIAAI-YYY1"}, {"id": "BAN1", "name": "VSDKYUTP-BAN1"}, { - "id": "WAS1", - "name": "WASHDCSW-WAS1" - }, {"id": "APP1", "name": "WBHGTYUI-APP1"}, {"id": "SUL2", "name": "WERTYUJK-SUL2"}, { - "id": "DEF2", - "name": "WSBHGTYL-DEF2" - }, {"id": "DHA12", "name": "WSXEDECF-DHA12"}, {"id": "MNT11", "name": "WSXEFBTH-MNT11"}, { - "id": "RAJ1", - "name": "YGBIJNLQ-RAJ1" - }, {"id": "JAG1", "name": "YUDFJULP-JAG1"}, {"id": "ZEN1", "name": "ZENCLLI1-ZEN1"}, { - "id": "ZOG1", - "name": "ZOGASTRO-ZOG1" - }, {"id": "SDE1", "name": "ZXCVBNMA-SDE1"}, {"id": "SIP1", "name": "ZXCVBNMK-SIP1"}, { - "id": "JUL1", - "name": "ZXCVBNMM-JUL1" - }, {"id": "ERT1", "name": "ertclli1-ERT1"}, {"id": "IOP1", "name": "iopclli1-IOP1"}, { - "id": "OPA1", - "name": "opaclli1-OPA1" - }, {"id": "RAI1", "name": "poiuytre-RAI1"}, {"id": "PUR1", "name": "purelyde-PUR1"}, { - "id": "RTY1", - "name": "rtyclli1-RTY1" - }, {"id": "SDF1", "name": "sdfclli1-SDF1"}, {"id": "SSW56", "name": "ss8126GT-SSW56"}, { - "id": "UIO1", - "name": "uioclli1-UIO1" - }], + "aicZones": [ + { + "id": "NFT1", + "name": "NFTJSSSS-NFT1" + }, + { + "id": "JAG1", + "name": "YUDFJULP-JAG1" + }, + { + "id": "YYY1", + "name": "UUUAIAAI-YYY1" + }, + { + "id": "AVT1", + "name": "AVTRFLHD-AVT1" + }, + { + "id": "ATL34", + "name": "ATLSANAI-ATL34" + } + ], "categoryParameters": { "owningEntityList": [{ "id": "aaa1", 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 7df03fd0a..c56cc4999 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 @@ -7,10 +7,12 @@ import {MessageBoxService} from "../../../shared/components/messageBox/messageBo import * as _ from "lodash"; import {DrawingBoardModes} from "../drawing-board.modes"; import {AuditInfoModalComponent} from "../../../shared/components/auditInfoModal/auditInfoModal.component"; -import {VnfModelInfo} from "./models/vnf/vnf.model.info"; import {ILevelNodeInfo} from "./models/basic.model.info"; import {ComponentInfoModel, ComponentInfoType} from "../component-info/component-info-model"; import {ModelInformationItem} from "../../../shared/components/model-information/model-information.component"; +import {undoUpgradeService, upgradeService} from "../../../shared/storeUtil/utils/service/service.actions"; +import {VNFMethods} from "../../../shared/storeUtil/utils/vnf/vnf.actions"; +import {FeatureFlagsService, Features} from "../../../shared/services/featureFlag/feature-flags.service"; @Injectable() export class SharedTreeService { @@ -106,16 +108,7 @@ export class SharedTreeService { * should return true if can delete **********************************************/ shouldShowDelete(node): boolean { - const mode = this._store.getState().global.drawingBoardStatus; - if (!_.isNil(node) && !_.isNil(node.data) && !_.isNil(node.data.action) && !_.isNil(node.data.menuActions['delete'])) { - if (mode !== DrawingBoardModes.EDIT || node.data.action === ServiceInstanceActions.Create) { - return false; - } else if (node.data.action === ServiceInstanceActions.None) { - return true - } - return false; - } - return false; + return this.shouldShowButtonGeneric(node, "delete") } /********************************************** @@ -146,6 +139,78 @@ export class SharedTreeService { return false; } /********************************************** + * enabled only on edit/design + * enabled only if there's a newer version for VNF-M + **********************************************/ + upgradeBottomUp(node,serviceModelId: string): void { + this.iterateOverTreeBranchAndRunAction(node, serviceModelId, VNFMethods.UPGRADE); + this._store.dispatch(upgradeService(serviceModelId)); + } + + private iterateOverTreeBranchAndRunAction(node, serviceModelId: string, actionMethod) { + while (_.has(node.parent, 'data') && _.has(node.parent.data, 'menuActions') + && !_.isNil(node.parent.data.menuActions[actionMethod])) { + node = node.parent; + node.data.menuActions[actionMethod]['method'](node, serviceModelId); + } + } + + /**************************************************** + * should return true if customer can upgrade a VFM * + ****************************************************/ + shouldShowUpgrade(node, serviceModelId): boolean { + if (FeatureFlagsService.getFlagState(Features.FLAG_FLASH_REPLACE_VF_MODULE, this._store) && + this.isThereAnUpdatedLatestVersion(serviceModelId)) { + return this.shouldShowButtonGeneric(node, VNFMethods.UPGRADE); + } + else { + return false + } + } + + private isThereAnUpdatedLatestVersion(serviceModelId) : boolean{ + let serviceInstance = this._store.getState().service.serviceInstance[serviceModelId]; + return !_.isNil(serviceInstance.latestAvailableVersion) && (Number(serviceInstance.modelInfo.modelVersion) < serviceInstance.latestAvailableVersion); + } + + private shouldShowButtonGeneric(node, method) { + const mode = this._store.getState().global.drawingBoardStatus; + 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; + } + else if (node.data.action === ServiceInstanceActions.None) { + return true + } + } + return false; + } + + /********************************************** + * return boolean according to + * current defined action of VFModule node + **********************************************/ + shouldShowUndoUpgrade(node): boolean { + const mode = this._store.getState().global.drawingBoardStatus; + if (mode === DrawingBoardModes.EDIT && !_.isNil(node.data.action) && !_.isNil(node.data.menuActions[VNFMethods.UNDO_UPGRADE])) { + if (node.data.action === ServiceInstanceActions.Upgrade) { + return false; + } else if (node.data.action.split('_').pop() === ServiceInstanceActions.Upgrade) { + return true + } + return false; + } + return false; + } + /********************************************** + * enabled only on edit/design + * enabled only if there's a newer version for VNF-M + **********************************************/ + undoUpgradeBottomUp(node,serviceModelId: string): void { + this.iterateOverTreeBranchAndRunAction(node, serviceModelId, VNFMethods.UNDO_UPGRADE); + this._store.dispatch(undoUpgradeService(serviceModelId)); + } + /********************************************** * should return true if can duplicate by mode **********************************************/ shouldShowDuplicate(node): boolean { |