summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/composition
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/composition')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/__snapshots__/info-tab.component.spec.ts.snap1
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.spec.ts27
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.ts57
3 files changed, 48 insertions, 37 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/__snapshots__/info-tab.component.spec.ts.snap b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/__snapshots__/info-tab.component.spec.ts.snap
index 7fcb62dbd3..1948395b47 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/__snapshots__/info-tab.component.spec.ts.snap
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/__snapshots__/info-tab.component.spec.ts.snap
@@ -14,6 +14,7 @@ exports[`InfoTabComponent can load instance 1`] = `
sdcMenu={[Function Object]}
serviceService={[Function Object]}
store={[Function Object]}
+ topologyTemplateService={[Function Object]}
versioning={[Function Function]}
workspaceService={[Function Object]}
>
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.spec.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.spec.ts
index 388e4b5542..263e22fa9f 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.spec.ts
@@ -1,4 +1,4 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { async, ComponentFixture} from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Store } from '@ngxs/store';
import { CompositionPaletteService } from '../../../../../pages/composition/palette/services/palette.service';
@@ -13,14 +13,13 @@ import { ConfigureFn, configureTests } from "../../../../../../../jest/test-conf
import { Observable } from "rxjs";
import { leftPaletteElements } from "../../../../../../../jest/mocks/left-paeltte-elements.mock";
import { TranslatePipe } from "../../../../../shared/translator/translate.pipe";
-import { HttpClientModule } from "@angular/common/http";
-import { TranslateModule } from "../../../../../../../app/ng2/shared/translator/translate.module";
-import _ from "lodash";
import { TranslateService } from "../../../../../shared/translator/translate.service";
import { SdcUiServices } from "onap-ui-angular";
-import { Component as TopologyTemplate, FullComponentInstance, ComponentInstance } from '../../../../../../../app/models';
+import {Component as TopologyTemplate, ComponentInstance, ComponentMetadata} from '../../../../../../../app/models';
import {KeyValuePipe} from "../../../../../pipes/key-value.pipe";
-
+import {TopologyTemplateService} from "../../../../../services/component-services/topology-template.service";
+import {ComponentGenericResponse} from "../../../../../services/responses/component-generic-response";
+import {serviceMetadata} from "../../../../../../../jest/mocks/service-metadata.mock";
describe('InfoTabComponent', () => {
@@ -31,11 +30,9 @@ describe('InfoTabComponent', () => {
let storeStub:Partial<Store>;
let compositionPaletteServiceStub:Partial<CompositionPaletteService>;
let iAppMenuStub:Partial<IAppMenu>;
- let compositionServiceStub:Partial<CompositionService>;
- let serviceServiceNg2Stub:Partial<ServiceServiceNg2>;
- let workspaceServiceStub:Partial<WorkspaceService>;
- let componentInstanceServiceNg2Stub:Partial<ComponentInstanceServiceNg2>;
let eventListenerServiceStub:Partial<EventListenerService>;
+ let topologyTemplateServiceStub:Partial<TopologyTemplateService>;
+ let componentGenericResponseStub:Partial<ComponentGenericResponse>;
beforeEach(
async(() => {
@@ -47,6 +44,13 @@ describe('InfoTabComponent', () => {
compositionPaletteServiceStub = {
getLeftPaletteElements: jest.fn().mockImplementation(()=> Observable.of(leftPaletteElements))
}
+ componentGenericResponseStub = {
+ metadata: new ComponentMetadata()
+ }
+ componentGenericResponseStub.metadata.allVersions = serviceMetadata.allVersions;
+ topologyTemplateServiceStub = {
+ getComponentMetadata: jest.fn().mockImplementation(() => Observable.of(componentGenericResponseStub))
+ }
const configure: ConfigureFn = testBed => {
testBed.configureTestingModule({
imports: [ ],
@@ -62,6 +66,7 @@ describe('InfoTabComponent', () => {
{ provide: WorkspaceService, useValue: {} },
{ provide: ComponentInstanceServiceNg2, useValue: {} },
{ provide: EventListenerService, useValue: eventListenerServiceStub },
+ { provide: TopologyTemplateService, useValue: topologyTemplateServiceStub},
{ provide: TranslateService, useValue: {}}
]
});
@@ -88,7 +93,7 @@ describe('InfoTabComponent', () => {
});
it('does not contain the highest minor version if it is checked out', () => {
fixture.componentInstance.component = new ComponentInstance();
- fixture.componentInstance.component.allVersions =
+ fixture.componentInstance.component.allVersions =
{'1.0': "9c829122-af05-4bc9-b537-5d84f4c8ae25", '1.1': "930d56cb-868d-4e35-bd0f-e737d2fdb171"};
fixture.componentInstance.component.version = "1.0";
fixture.componentInstance.component.uuid = "a8cf015e-e4e5-4d4b-a01e-8624e8d36095";
diff --git a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.ts b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.ts
index cb889a2583..773b44cab7 100644
--- a/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/panel/panel-tabs/info-tab/info-tab.component.ts
@@ -21,6 +21,7 @@ import { EventListenerService } from "app/services";
import * as _ from 'lodash';
import {SelectedComponentType, TogglePanelLoadingAction} from "../../../common/store/graph.actions";
import Dictionary = _.Dictionary;
+import {TopologyTemplateService} from "../../../../../services/component-services/topology-template.service";
@Component({
@@ -47,6 +48,7 @@ export class InfoTabComponent implements OnInit, OnDestroy {
private componentInstanceService: ComponentInstanceServiceNg2,
private serviceService: ServiceServiceNg2,
private eventListenerService: EventListenerService,
+ private topologyTemplateService: TopologyTemplateService,
@Inject(SdcMenuToken) public sdcMenu:IAppMenu) {
}
@@ -150,34 +152,37 @@ export class InfoTabComponent implements OnInit, OnDestroy {
};
- private initEditResourceVersion = (component, leftPaletteComponents): void => {
- if(this.component instanceof ComponentInstance) {
-
+ initEditResourceVersion = (component, leftPaletteComponents): void => {
+ if (this.component instanceof ComponentInstance) {
this.versions = [];
- let sorted:any = _.sortBy(_.toPairs(component.allVersions), (item) => {
- return item[0] !== "undefined" && this.versioning(item[0]);
- });
- _.forEach(sorted, (item) => {
- this.versions.push({label: item[0], value: item[1]});
- });
-
- let highestVersion = _.last(sorted)[0];
-
- if (parseFloat(highestVersion) % 1) { //if highest is minor, make sure it is the latest checked in -
- let latestVersionComponent: LeftPaletteComponent = _.maxBy(
- _.filter(leftPaletteComponents, (leftPaletteComponent: LeftPaletteComponent) => { //latest checked in
- return (leftPaletteComponent.systemName === component.systemName || leftPaletteComponent.uuid === component.uuid);
- })
- , (component) => {
- return component.version
- });
-
- let latestVersion: string = latestVersionComponent ? latestVersionComponent.version : highestVersion;
-
- if (latestVersion && highestVersion != latestVersion) { //highest is checked out - remove from options
- this.versions = this.versions.filter(version => version.label != highestVersion);
+ this.topologyTemplateService.getComponentMetadata(component.getComponentUid(), component.originType)
+ .subscribe((response) => {
+ const allVersions = response.metadata.allVersions;
+ let sorted: any = _.sortBy(_.toPairs(allVersions), (item) => {
+ return item[0] !== "undefined" && this.versioning(item[0]);
+ });
+ _.forEach(sorted, (item) => {
+ this.versions.push({label: item[0], value: item[1]});
+ });
+
+ let highestVersion = _.last(sorted)[0];
+
+ if (parseFloat(highestVersion) % 1) { //if highest is minor, make sure it is the latest checked in -
+ let latestVersionComponent: LeftPaletteComponent = _.maxBy(
+ _.filter(leftPaletteComponents, (leftPaletteComponent: LeftPaletteComponent) => { //latest checked in
+ return (leftPaletteComponent.systemName === component.systemName || leftPaletteComponent.uuid === component.uuid);
+ })
+ , (component) => {
+ return component.version
+ });
+
+ let latestVersion: string = latestVersionComponent ? latestVersionComponent.version : highestVersion;
+
+ if (latestVersion && highestVersion != latestVersion) { //highest is checked out - remove from options
+ this.versions = this.versions.filter(version => version.label != highestVersion);
+ }
}
- }
+ });
}
}