summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2021-04-15 18:47:55 +0100
committerAndré Schmid <andre.schmid@est.tech>2021-04-20 10:30:55 +0000
commit39b533344f0a86401f5c41025cfdcf3139934569 (patch)
tree2a6b48a5368525aaf0d167c43afade6a5c532f30 /catalog-ui/src/app/ng2/pages
parentcd12a2ac6ddc43493c4ba0685dfc75f11bf2aa6b (diff)
Fix VSP update for checked-in resources
Checkout the VF (if checked-in) related to the VSP before loading the VF workspace. Change-Id: I9576fd5b429fdae2ac00de5bfbd38e183b93be59 Issue-ID: SDC-3560 Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/pages')
-rw-r--r--catalog-ui/src/app/ng2/pages/home/__snapshots__/home.component.spec.ts.snap1
-rw-r--r--catalog-ui/src/app/ng2/pages/home/home.component.spec.ts33
-rw-r--r--catalog-ui/src/app/ng2/pages/home/home.component.ts66
-rw-r--r--catalog-ui/src/app/ng2/pages/home/home.module.ts3
4 files changed, 65 insertions, 38 deletions
diff --git a/catalog-ui/src/app/ng2/pages/home/__snapshots__/home.component.spec.ts.snap b/catalog-ui/src/app/ng2/pages/home/__snapshots__/home.component.spec.ts.snap
index ae5445e546..42686c1567 100644
--- a/catalog-ui/src/app/ng2/pages/home/__snapshots__/home.component.spec.ts.snap
+++ b/catalog-ui/src/app/ng2/pages/home/__snapshots__/home.component.spec.ts.snap
@@ -13,6 +13,7 @@ exports[`home component should match current snapshot 1`] = `
loaderService={[Function Object]}
modalService={[Function Object]}
modalsHandler={[Function Object]}
+ resourceService={[Function Object]}
sdcConfig={[Function Object]}
sdcMenu={[Function Object]}
translateService={[Function Object]}
diff --git a/catalog-ui/src/app/ng2/pages/home/home.component.spec.ts b/catalog-ui/src/app/ng2/pages/home/home.component.spec.ts
index df854024fa..1c03790e04 100644
--- a/catalog-ui/src/app/ng2/pages/home/home.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/home/home.component.spec.ts
@@ -1,22 +1,17 @@
+import {SdcConfigToken} from "../../config/sdc-config.config";
+import {SdcMenuToken} from "../../config/sdc-menu.config";
-import { SdcConfigToken, ISdcConfig } from "../../config/sdc-config.config";
-import { SdcMenuToken, IAppMenu } from "../../config/sdc-menu.config";
-
-import { async, ComponentFixture, TestBed } from "@angular/core/testing";
-import { HomeComponent } from "./home.component";
+import {async, ComponentFixture, TestBed} from "@angular/core/testing";
+import {HomeComponent} from "./home.component";
import {ConfigureFn, configureTests} from "../../../../jest/test-config.helper";
import {NO_ERRORS_SCHEMA} from "@angular/core";
-import { TranslateService } from "../../shared/translator/translate.service";
-import { HomeService, CacheService, AuthenticationService, ImportVSPService } from '../../../../app/services-ng2';
-import { ModalsHandler } from "../../../../app/utils";
-import { SdcUiServices } from "onap-ui-angular";
+import {TranslateService} from "../../shared/translator/translate.service";
+import {AuthenticationService, CacheService, HomeService, ImportVSPService, ResourceServiceNg2} from '../../../../app/services-ng2';
+import {ModalsHandler} from "../../../../app/utils";
+import {SdcUiServices} from "onap-ui-angular";
import {ComponentType, ResourceType} from "../../../utils/constants";
-import { FoldersMenu, FoldersItemsMenu, FoldersItemsMenuGroup } from './folders';
-import { HomeFilter } from "../../../../app/models/home-filter";
-import {Component} from "../../../models/components/component";
-
-
+import {HomeFilter} from "../../../models/home-filter";
describe('home component', () => {
@@ -33,6 +28,7 @@ describe('home component', () => {
let homeFilterMock :Partial<HomeFilter>;
let foldersMock;
let loaderServiceMock;
+ let resourceServiceNg2Mock: Partial<ResourceServiceNg2>;
beforeEach(
@@ -62,7 +58,11 @@ describe('home component', () => {
loaderServiceMock = {
activate: jest.fn(),
deactivate: jest.fn()
- }
+ };
+
+ resourceServiceNg2Mock = {
+ checkout: jest.fn()
+ };
const configure: ConfigureFn = testBed => {
testBed.configureTestingModule({
@@ -80,7 +80,8 @@ describe('home component', () => {
{provide: ModalsHandler, useValue: {}},
{provide: SdcUiServices.ModalService, useValue: modalServiceMock},
{provide: SdcUiServices.LoaderService, useValue: loaderServiceMock},
- {provide: ImportVSPService, useValue: {}}
+ {provide: ImportVSPService, useValue: {}},
+ {provide: ResourceServiceNg2, useValue: resourceServiceNg2Mock}
],
});
};
diff --git a/catalog-ui/src/app/ng2/pages/home/home.component.ts b/catalog-ui/src/app/ng2/pages/home/home.component.ts
index 77fd3b5ae4..f0e8815d93 100644
--- a/catalog-ui/src/app/ng2/pages/home/home.component.ts
+++ b/catalog-ui/src/app/ng2/pages/home/home.component.ts
@@ -18,19 +18,20 @@
* ============LICENSE_END=========================================================
*/
'use strict';
-import { Component as NgComponent, Inject, OnInit } from '@angular/core';
-import { Component, IConfigRoles, IUserProperties, Resource } from 'app/models';
-import { HomeFilter } from 'app/models/home-filter';
-import { AuthenticationService, CacheService, HomeService } from 'app/services-ng2';
-import { ModalsHandler } from 'app/utils';
-import { SdcUiServices } from 'onap-ui-angular';
-import { CHANGE_COMPONENT_CSAR_VERSION_FLAG, ComponentType, ResourceType } from '../../../utils/constants';
-import { ImportVSPService } from '../../components/modals/onboarding-modal/import-vsp.service';
-import { ISdcConfig, SdcConfigToken } from '../../config/sdc-config.config';
-import { IAppMenu, SdcMenuToken } from '../../config/sdc-menu.config';
-import { EntityFilterPipe } from '../../pipes/entity-filter.pipe';
-import { TranslateService } from '../../shared/translator/translate.service';
-import { FoldersItemsMenu, FoldersItemsMenuGroup, FoldersMenu } from './folders';
+import {Component as NgComponent, Inject, OnInit} from '@angular/core';
+import {Component, ComponentMetadata, IConfigRoles, IUserProperties, Resource} from 'app/models';
+import {HomeFilter} from 'app/models/home-filter';
+import {AuthenticationService, CacheService, HomeService, ResourceServiceNg2} from 'app/services-ng2';
+import {ComponentState, ModalsHandler} from 'app/utils';
+import {SdcUiServices} from 'onap-ui-angular';
+import {CHANGE_COMPONENT_CSAR_VERSION_FLAG, ComponentType, ResourceType} from '../../../utils/constants';
+import {ImportVSPService} from '../../components/modals/onboarding-modal/import-vsp.service';
+import {ISdcConfig, SdcConfigToken} from '../../config/sdc-config.config';
+import {IAppMenu, SdcMenuToken} from '../../config/sdc-menu.config';
+import {EntityFilterPipe} from '../../pipes/entity-filter.pipe';
+import {TranslateService} from '../../shared/translator/translate.service';
+import {FoldersItemsMenu, FoldersItemsMenuGroup, FoldersMenu} from './folders';
+import {ImportVSPdata} from "../../components/modals/onboarding-modal/onboarding-modal.component";
@NgComponent({
selector: 'home-page',
@@ -63,8 +64,9 @@ export class HomeComponent implements OnInit {
private modalsHandler: ModalsHandler,
private modalService: SdcUiServices.ModalService,
private loaderService: SdcUiServices.LoaderService,
- private importVSPService: ImportVSPService
- ) {}
+ private importVSPService: ImportVSPService,
+ private resourceService: ResourceServiceNg2
+ ) { }
ngOnInit(): void {
this.initHomeComponentVars();
@@ -90,16 +92,38 @@ export class HomeComponent implements OnInit {
// Open onboarding modal
public notificationIconCallback(): void {
- this.importVSPService.openOnboardingModal().subscribe((result) => {
- if (!result.previousComponent || result.previousComponent.csarVersion !== result.componentCsar.csarVersion) {
- this.cacheService.set(CHANGE_COMPONENT_CSAR_VERSION_FLAG, result.componentCsar.csarVersion);
+ this.importVSPService.openOnboardingModal().subscribe((importVSPdata: ImportVSPdata) => {
+ const actualComponent = importVSPdata.previousComponent;
+ if (!actualComponent || actualComponent.csarVersion !== importVSPdata.componentCsar.csarVersion) {
+ this.cacheService.set(CHANGE_COMPONENT_CSAR_VERSION_FLAG, importVSPdata.componentCsar.csarVersion);
}
+ const vfExistsAndIsNotCheckedOut: boolean = actualComponent && actualComponent.lifecycleState != ComponentState.NOT_CERTIFIED_CHECKOUT;
+ if (vfExistsAndIsNotCheckedOut) {
+ this.checkoutAndRedirectToWorkspace(importVSPdata);
+ return;
+ }
+ this.$state.go('workspace.general', {
+ id: actualComponent && actualComponent.uniqueId,
+ componentCsar: importVSPdata.componentCsar,
+ type: importVSPdata.type
+ });
+ });
+ }
+
+ private checkoutAndRedirectToWorkspace(importVSPdata: ImportVSPdata) {
+ this.loaderService.activate();
+ this.resourceService.checkout(importVSPdata.previousComponent.uniqueId)
+ .subscribe((componentMetadata: ComponentMetadata) => {
this.$state.go('workspace.general', {
- id: result.previousComponent && result.previousComponent.uniqueId,
- componentCsar: result.componentCsar,
- type: result.type
+ id: componentMetadata.uniqueId,
+ componentCsar: importVSPdata.componentCsar,
+ type: importVSPdata.type
});
+ this.loaderService.deactivate();
+ }, () => {
+ this.loaderService.deactivate();
});
+ return;
}
public onImportVf(file: any): void {
diff --git a/catalog-ui/src/app/ng2/pages/home/home.module.ts b/catalog-ui/src/app/ng2/pages/home/home.module.ts
index 3e7c0cd312..1a397b44be 100644
--- a/catalog-ui/src/app/ng2/pages/home/home.module.ts
+++ b/catalog-ui/src/app/ng2/pages/home/home.module.ts
@@ -6,6 +6,7 @@ import { UiElementsModule } from "../../components/ui/ui-elements.module";
import { GlobalPipesModule } from "../../pipes/global-pipes.module";
import { TranslateModule } from "../../shared/translator/translate.module";
import { SdcUiComponentsModule } from "onap-ui-angular";
+import { ResourceServiceNg2 } from "../../services/component-services/resource.service";
@NgModule({
declarations: [
@@ -25,7 +26,7 @@ import { SdcUiComponentsModule } from "onap-ui-angular";
entryComponents: [
HomeComponent
],
- providers: []
+ providers: [ResourceServiceNg2]
})
export class HomeModule {
}