From 39a8639ddd4f9821c207cfa53264a475dcca8cf2 Mon Sep 17 00:00:00 2001 From: Yoav Schneiderman Date: Sun, 5 Jan 2020 15:03:16 +0200 Subject: Hide Templates entry point when no instances Issue-ID: VID-741 Signed-off-by: Yoav Schneiderman Change-Id: I9f2c1879b30ed15b227cdd6189d14ef988bc3b1e Signed-off-by: Yoav Schneiderman --- .../objectToModelTree/objectToModelTree.service.ts | 2 -- .../generic-form-popup.component.ts | 17 +++++++-------- .../generic-form-popup.service.spec.ts | 24 +++++++++++++++++++--- .../genericFormPopup/generic-form-popup.service.ts | 12 +++++++++++ .../service/service.popup.service.spec.ts | 1 - .../instantiation.templates.modal.service.spec.ts | 2 +- .../instantiation.templates.modal.service.ts | 2 +- .../shared/components/spinner/spinner.component.ts | 1 - .../services/featureFlag/feature-flags.service.ts | 1 + .../utils/vfModule/vfModule.reducers.spec.ts | 2 -- .../network-selector/network-selector.component.ts | 1 - 11 files changed, 45 insertions(+), 20 deletions(-) (limited to 'vid-webpack-master/src') diff --git a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts index 75ae1e149..f1ebdaff9 100644 --- a/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts +++ b/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/objectToModelTree/objectToModelTree.service.ts @@ -28,8 +28,6 @@ export class ObjectToModelTreeService { } this.calculateNumberOfNodesWithPlusIcon(serviceModel, nodes); - - console.log('nodes', nodes); return nodes; } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts index eb608652c..9063e6723 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.component.ts @@ -8,7 +8,7 @@ import * as _ from "lodash"; import {NgRedux} from "@angular-redux/store"; import {AppState} from "../../store/reducers"; import {ServicePopupService} from "./genericFormServices/service/service.popup.service"; -import {ActivatedRoute} from "@angular/router"; +import {ActivatedRoute, Router} from "@angular/router"; import {AaiService} from "../../services/aaiService/aai.service"; import {GenericFormPopupService} from "./generic-form-popup.service"; import {FormControlModel} from "../../models/formControlModels/formControl.model"; @@ -53,7 +53,7 @@ export class GenericFormPopupComponent extends DialogComponent { - console.log('changed'); - if (params['serviceModelId'] && params['isCreate'] == "true") { - this.onInitForCreateNewServicePopup(); + this.serviceModelId = params['serviceModelId']; + if (this.serviceModelId && params['isCreate'] == "true") { + this.onInitForCreateNewServicePopup(params['hasTemplate']); } }); @@ -106,7 +107,7 @@ export class GenericFormPopupComponent extends DialogComponent { this.uuidData = { bulkSize: 1, @@ -115,8 +116,8 @@ export class GenericFormPopupComponent extends DialogComponent { @@ -154,7 +155,7 @@ export class GenericFormPopupComponent extends DialogComponent { - this._dialogService.addDialog(InstantiationTemplatesModalComponent, {}); + this._router.navigate(['/instantiationTemplatesPopup'], { queryParams: { serviceModelId: this.serviceModelId}, queryParamsHandling: 'merge' }); } } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts index ac417ed6e..53f345af0 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.spec.ts @@ -22,6 +22,8 @@ import {VfModuleControlGenerator} from "../genericForm/formControlsServices/vfMo import {FeatureFlagsService} from "../../services/featureFlag/feature-flags.service"; import {VfModuleUpgradePopupService} from "./genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service"; import {SharedControllersService} from "../genericForm/formControlsServices/sharedControlles/shared.controllers.service"; +import {AppState} from "../../store/reducers"; +import each from 'jest-each'; class MockAppStore{ getState() { @@ -951,6 +953,8 @@ describe('Generic Form popup Service', () => { let servicePopupService : ServicePopupService; let _aaiService : AaiService; let _activatedRoute : ActivatedRoute; + let _store : NgRedux; + let _featureFlagsService : FeatureFlagsService; beforeAll(done => (async () => { TestBed.configureTestingModule({ @@ -972,7 +976,7 @@ describe('Generic Form popup Service', () => { VfModulePopupService, VfModuleUpgradePopupService, VfModuleControlGenerator, - {provide:FeatureFlagsService, useClass: MockFeatureFlagsService}, + FeatureFlagsService, {provide: ActivatedRoute, useClass: ActivatedRouteMock}, {provide: NgRedux, useClass: MockAppStore}] }); @@ -987,7 +991,8 @@ describe('Generic Form popup Service', () => { servicePopupService = injector.get(ServicePopupService); _aaiService = injector.get(AaiService); _activatedRoute = injector.get(ActivatedRoute); - + _store = injector.get(NgRedux); + _featureFlagsService = injector.get(FeatureFlagsService); })().then(done).catch(done.fail)); @@ -1065,5 +1070,18 @@ describe('Generic Form popup Service', () => { test('initReduxOnCreateNewService',() => { jest.spyOn(_aaiService, 'getServiceModelById'); service.initReduxOnCreateNewService(); - }) + }); + + + const shouldShowTemplateBtnDataProvider = [ + ['shouldShowTemplateBtn : should return true if flag is true and has template', true , true, true], + ['shouldShowTemplateBtn : should return false if flag is false and has template',false , true, false], + ['shouldShowTemplateBtn : should return false if flag is true and has no template',true , false, false], + ['shouldShowTemplateBtn : should return false if flag is false and has no template',false , false, false]]; + each(shouldShowTemplateBtnDataProvider).test('%s', (desc : string, flag : boolean, hasTemplate : boolean, expected : boolean ) => { + spyOn(_featureFlagsService, 'getFlagState').and.returnValue(flag) + + const result: boolean = service.shouldShowTemplateBtn(hasTemplate); + expect(result).toEqual(expected); + }); }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts index 6636a54f2..2998ba92b 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/generic-form-popup.service.ts @@ -10,6 +10,7 @@ import {UUIDData} from "./generic-form-popup.component"; import {FormPopupDetails} from "../../models/formControlModels/formPopupDetails.model"; import {Subject} from "rxjs"; import {deleteAllServiceInstances} from "../../storeUtil/utils/service/service.actions"; +import {FeatureFlagsService, Features} from "../../services/featureFlag/feature-flags.service"; @Injectable() export class GenericFormPopupService { @@ -17,6 +18,7 @@ export class GenericFormPopupService { private _store: NgRedux, private _servicePopupService : ServicePopupService, public _activatedRoute : ActivatedRoute, + private _featureFlagsService : FeatureFlagsService, private _aaiService : AaiService){ } @@ -90,4 +92,14 @@ export class GenericFormPopupService { } refreshModalCheckForGeneralErrorTrigger : Subject = new Subject(); + + + + shouldShowTemplateBtn = (hasTemplate: boolean) : boolean => { + const instantiationTemplateFlag = this._featureFlagsService.getFlagState(Features.FLAG_2004_INSTANTIATION_TEMPLATES_POPUP); + if(instantiationTemplateFlag){ + return hasTemplate; + } + return false; + } } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts index 0ce051cf4..3a106ec93 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/service/service.popup.service.spec.ts @@ -2172,7 +2172,6 @@ describe('Service popup service', () => { test('getDynamicInputs should return list of controls' ,() => { const result: FormControlModel[] = service.getDynamicInputs('6b528779-44a3-4472-bdff-9cd15ec93450'); - console.log(result); expect(result.length).toEqual(4); expect(result[0].controlName).toEqual('2017488_pasqualevpe0_ASN_1'); expect(result[1].controlName).toEqual('2017488_pasqualevpe0_ASN_2'); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts index 308597ac6..61f75e84b 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.spec.ts @@ -173,7 +173,7 @@ describe('instantiation templates modal service', () => { service.navigateToNewServiceModal(serviceModelId); - expect(_router.navigate).toBeCalledWith(["/servicePopup"], {"queryParams": {"isCreate": true, "serviceModelId": serviceModelId}, "queryParamsHandling": "merge"}); + expect(_router.navigate).toBeCalledWith(["/servicePopup"], {"queryParams": {"isCreate": true, "serviceModelId": serviceModelId, hasTemplate : true}, "queryParamsHandling": "merge"}); }) }); diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts index c17591845..c7c198fcb 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/instantiationTemplatesModal/instantiation.templates.modal.service.ts @@ -30,7 +30,7 @@ export class InstantiationTemplatesModalService { navigateToNewServiceModal(serviceModelId: string) { - this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true}, queryParamsHandling: 'merge' }); + this._router.navigate(['/servicePopup'], { queryParams: { serviceModelId: serviceModelId, isCreate:true, hasTemplate : true}, queryParamsHandling: 'merge' }); } } diff --git a/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts b/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts index 94a0e1c52..ebaca6276 100644 --- a/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts +++ b/vid-webpack-master/src/app/shared/components/spinner/spinner.component.ts @@ -29,7 +29,6 @@ export class SpinnerComponent{ }else { delete this.requestMap[requestUrl] } - console.log(this.requestMap); this.show = !_.isEmpty(this.requestMap) && this.requestMap !== undefined; }) diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts index 74fcd8f87..cccade887 100644 --- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts @@ -16,6 +16,7 @@ export enum Features { FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER', FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE', FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER', + FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP' } @Injectable() 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 9b3a287a6..91b749e0d 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 @@ -251,7 +251,6 @@ test('#DELETE_ACTION_VF_MODULE_INSTANCE', () => { serviceId: 'serviceModelId' }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); expect(vfModule).toBeDefined(); expect(vfModule.isMissingData).toBeTruthy(); expect(vfModule.action).toEqual(ServiceInstanceActions.None_Delete); @@ -287,7 +286,6 @@ test('#UNDO_DELETE_ACTION_VF_MODULE_INSTANCE', () => { serviceId: 'serviceModelId' }).serviceInstance['serviceModelId'].vnfs['vnfStoreKey'].vfModules['modelName']['dynamicModelName1']; - console.log(vfModule.action); expect(vfModule).toBeDefined(); expect(vfModule.action).toEqual(ServiceInstanceActions.None); }); diff --git a/vid-webpack-master/src/app/vlanTagging/network-selector/network-selector.component.ts b/vid-webpack-master/src/app/vlanTagging/network-selector/network-selector.component.ts index d3df9268d..c0aeb0b51 100644 --- a/vid-webpack-master/src/app/vlanTagging/network-selector/network-selector.component.ts +++ b/vid-webpack-master/src/app/vlanTagging/network-selector/network-selector.component.ts @@ -26,7 +26,6 @@ export class NetworkSelectorComponent implements OnInit { constructor(store: NgRedux) { this.localStore = store; this.groupSelection = {}; - console.log(store); } getValueOfLabelInGroup(group: any, label: string){ -- cgit 1.2.3-korg