From 68eed7997aab4aa4f785085303aab61cf8e16a31 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Wed, 13 Oct 2021 16:01:51 +0100 Subject: Make Service base type optional Issue-ID: SDC-3759 Change-Id: I8adf112966ee9303fc965a74cec7203274acd735 Signed-off-by: andre.schmid --- .../panel/composition-panel.component.spec.ts | 44 ++++++++++++++++------ .../panel/composition-panel.component.ts | 13 ++++++- .../properties-assignment.page.component.html | 2 +- .../properties-assignment.page.component.ts | 9 ++++- 4 files changed, 54 insertions(+), 14 deletions(-) (limited to 'catalog-ui/src/app/ng2/pages') diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts index d5c0b6093b..2f27f468b6 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.spec.ts @@ -169,28 +169,49 @@ describe('composition-panel component', () => { expect(fixture).toMatchSnapshot(); }); - it('When Topology Template is Service and no instance is selected Expect (info, deployment, inputs, info and api)', () => { - + it('When Topology Template is Service and no instance is selected Expect tabs info, deployment, inputs, info, api, substitution filter', () => { const selectedComponent: Service = new Service(null, null); selectedComponent.isResource = jest.fn(() => false); - selectedComponent.isService = jest.fn(() => true ); + selectedComponent.isService = jest.fn(() => true); + selectedComponent.isSubstituteCandidate = jest.fn(() => true); + fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent)); + + fixture.componentInstance.topologyTemplate = selectedComponent; + + // Call ngOnInit + fixture.componentInstance.ngOnInit(); + + // Expect that + expect(fixture.componentInstance.tabs.length).toBe(6); + expect(fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab); + expect(fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts); + expect(fixture.componentInstance.tabs[2]).toEqual(tabs.inputs); + expect(fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts); + expect(fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts); + expect(fixture.componentInstance.tabs[5]).toEqual(tabs.substitutionFilter); + }); + + it('When Topology Template is Service without base type, and no instance is selected. Expect tabs info, deployment, inputs, info and api', () => { + + const selectedComponent: Service = new Service(null, null); + selectedComponent.isResource = jest.fn(() => false); + selectedComponent.isService = jest.fn(() => true); + selectedComponent.isSubstituteCandidate = jest.fn(() => false); fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent)); - // const pnfMock = Mock.of({ isResource : () => false }); fixture.componentInstance.topologyTemplate = selectedComponent; // Call ngOnInit fixture.componentInstance.ngOnInit(); // Expect that - expect (fixture.componentInstance.tabs.length).toBe(6); - expect (fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab); - expect (fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts); - expect (fixture.componentInstance.tabs[2]).toEqual(tabs.inputs); - expect (fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts); - expect (fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts); - expect (fixture.componentInstance.tabs[5]).toEqual(tabs.substitutionFilter); + expect(fixture.componentInstance.tabs.length).toBe(5); + expect(fixture.componentInstance.tabs[0]).toEqual(tabs.infoTab); + expect(fixture.componentInstance.tabs[1]).toEqual(tabs.deploymentArtifacts); + expect(fixture.componentInstance.tabs[2]).toEqual(tabs.inputs); + expect(fixture.componentInstance.tabs[3]).toEqual(tabs.infoArtifacts); + expect(fixture.componentInstance.tabs[4]).toEqual(tabs.apiArtifacts); }); @@ -223,6 +244,7 @@ describe('composition-panel component', () => { const selectedComponent: Service = new Service(null, null); selectedComponent.isResource = jest.fn(() => false); selectedComponent.isService = jest.fn(() => true ); + selectedComponent.isSubstituteCandidate = jest.fn(() => true ); fixture.componentInstance.store.select = jest.fn(() => Observable.of(selectedComponent)); fixture.componentInstance.selectedComponentIsServiceProxyInstance = jest.fn(() => true); diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts index 6ed73b3384..3422cc142d 100644 --- a/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts +++ b/catalog-ui/src/app/ng2/pages/composition/panel/composition-panel.component.ts @@ -264,7 +264,7 @@ export class CompositionPanelComponent { this.tabs.push(tabs.apiArtifacts); } - if((component.isService() || this.isVF()) && !this.isComponentInstanceSelected()){ + if (this.showSubstitutionFilterTab(component)) { this.tabs.push(tabs.substitutionFilter); } @@ -279,6 +279,17 @@ export class CompositionPanelComponent { } + private showSubstitutionFilterTab(component): boolean { + if ((component.isService() || this.isVF()) && !this.isComponentInstanceSelected()) { + if (component.isService()) { + return (component).isSubstituteCandidate(); + } + return true; + } + + return false; + } + private toggleSidebarDisplay = () => { // this.withSidebar = !this.withSidebar; this.store.dispatch(new OnSidebarOpenOrCloseAction()); diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html index b54cbc97c2..747624a03f 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html @@ -87,7 +87,7 @@
Add Property
+ (click)="addProperty(component.model)" data-tests-id="properties-add-button" [ngClass]="{'disabled': !showAddProperties()}">Add Property
Add Input
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index 09fd888755..e0a1cbf8ff 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -38,6 +38,7 @@ import { PropertyBEModel, PropertyFEModel, PropertyInputDetail, + Service, SimpleFlatProperty } from "app/models"; import {ResourceType} from "app/utils"; @@ -67,7 +68,6 @@ import {ToscaPresentationData} from "../../../models/tosca-presentation"; import {Observable} from "rxjs"; import {ToscaGetFunctionType} from "../../../models/tosca-get-function-type.enum"; import {TranslateService} from "../../shared/translator/translate.service"; -import {Model} from '../../../models/model'; const SERVICE_SELF_TITLE = "SELF"; @Component({ @@ -250,6 +250,13 @@ export class PropertiesAssignmentComponent { return this.selectedInstanceData && this.selectedInstanceData.uniqueId == this.component.uniqueId; } + showAddProperties = (): boolean => { + if (this.component.isService() && !(this.component).isSubstituteCandidate()) { + return false; + } + return this.isSelf(); + } + getServiceProperties() { this.loadingProperties = true; this.topologyTemplateService -- cgit 1.2.3-korg