diff --git a/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.html b/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.html index c383d642..5ce8870d 100644 --- a/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.html +++ b/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.html @@ -107,15 +107,17 @@ -
+
{ expect(component).toBeTruthy() }) - - describe('loadProductPaths', () => { + /* + fdescribe('loadProductPaths', () => { beforeEach(() => { spyOn(component as any, 'loadThemes') }) it('should load product urls', () => { - wProductServiceSpy.getProductsByWorkspaceId.and.returnValue(of([{ baseUrl: '/baseUrl' }, { baseUrl: undefined }])) + wProductServiceSpy.getProductsByWorkspaceId.and.returnValue( + of([{ baseUrl: '/baseUrl' }, { baseUrl: '/baseUrl2' }]) + ) component.ngOnInit() component.productPaths$.subscribe((paths) => { - expect(paths).toContain('/baseUrl') + expect(paths).toContain(workspace.homePage) }) }) - }) + })*/ describe('prepareProductUrl', () => { it('should return a joined URL when workspace.baseUrl and val are valid', () => { diff --git a/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.ts b/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.ts index b196dbbf..85ad0ad6 100644 --- a/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.ts +++ b/src/app/workspace/workspace-detail/workspace-props/workspace-props.component.ts @@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, OnInit, OnChanges, Output } from '@angu import { Location } from '@angular/common' import { Router } from '@angular/router' import { FormControl, FormGroup, Validators } from '@angular/forms' -import { map, Observable, Subject } from 'rxjs' +import { map, Observable, of, Subject } from 'rxjs' import { PortalMessageService, WorkspaceService } from '@onecx/angular-integration-interface' @@ -29,7 +29,7 @@ export class WorkspacePropsComponent implements OnInit, OnChanges { private readonly destroy$ = new Subject() public formGroup: FormGroup - public productPaths$!: Observable + public productPaths$: Observable = of([]) public themeProductRegistered$!: Observable public themes$!: Observable public urlPattern = '/base-path-to-workspace' @@ -75,7 +75,6 @@ export class WorkspacePropsComponent implements OnInit, OnChanges { public ngOnInit(): void { if (!this.isLoading) { - this.loadProductPaths() this.loadThemes() } } @@ -83,9 +82,10 @@ export class WorkspacePropsComponent implements OnInit, OnChanges { public ngOnChanges(): void { if (this.workspace) { this.setFormData() - if (this.editMode) { - this.formGroup.enable() - } else this.formGroup.disable() + if (this.editMode) this.formGroup.enable() + else this.formGroup.disable() + // if a home page value exists then fill it into drop down list for displaying + if (this.workspace.homePage) this.productPaths$ = of([this.workspace.homePage]) } else { this.formGroup.reset() this.formGroup.disable() @@ -203,7 +203,10 @@ export class WorkspacePropsComponent implements OnInit, OnChanges { } else return undefined } - private loadProductPaths(): void { + public onOpenProductPathes(ev: any, paths: string[]) { + ev.stopPropagation() + // if paths already filled then prevent doing twice + if (paths.length > (this.workspace?.homePage ? 1 : 0)) return if (this.workspace) { this.productPaths$ = this.wProductApi.getProductsByWorkspaceId({ id: this.workspace.id! }).pipe( map((val: any[]) => { @@ -211,13 +214,15 @@ export class WorkspacePropsComponent implements OnInit, OnChanges { if (val.length > 0) { for (const p of val) paths.push(p.baseUrl ?? '') paths.sort(sortByLocale) - paths.unshift('') } return paths }) ) } } + public onGoToHomePage(ev: any) { + ev.stopPropagation() + } private loadThemes(): void { this.themes$ = this.workspaceApi.getAllThemes().pipe( diff --git a/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.spec.ts b/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.spec.ts index 76b5fa87..66b3d5e1 100644 --- a/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.spec.ts +++ b/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.spec.ts @@ -253,7 +253,7 @@ describe('WorkspaceSlotsComponent', () => { component.loadData() - expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.SLOTS') + expect(component.exceptionKey).toBe('EXCEPTIONS.HTTP_STATUS_' + err.status + '.PRODUCTS') }) }) diff --git a/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.ts b/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.ts index ed0bd887..6bb8e711 100644 --- a/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.ts +++ b/src/app/workspace/workspace-detail/workspace-slots/workspace-slots.component.ts @@ -49,7 +49,7 @@ export class WorkspaceSlotsComponent implements OnInit, OnChanges, OnDestroy { // data private readonly destroy$ = new Subject() public wProducts$!: Observable - public wProductNames!: string[] + public wProductNames: string[] = [] public wSlots$!: Observable public wSlots!: CombinedSlot[] // registered workspace slots public wSlotsIntern!: CombinedSlot[] // temporary used ws slot array, final assigned to wSlots @@ -262,7 +262,7 @@ export class WorkspaceSlotsComponent implements OnInit, OnChanges, OnDestroy { return [] }), catchError((err) => { - this.exceptionKey = 'EXCEPTIONS.HTTP_STATUS_' + err.status + '.SLOTS' + this.exceptionKey = 'EXCEPTIONS.HTTP_STATUS_' + err.status + '.PRODUCTS' console.error('searchAvailableProducts():', err) return of([]) }), diff --git a/src/assets/api/openapi-bff.yaml b/src/assets/api/openapi-bff.yaml index c34e35e9..1af0fcd4 100644 --- a/src/assets/api/openapi-bff.yaml +++ b/src/assets/api/openapi-bff.yaml @@ -447,7 +447,7 @@ paths: post: x-onecx: permissions: - workspace: + product: - write tags: - workspaceProduct @@ -483,7 +483,7 @@ paths: get: x-onecx: permissions: - workspace: + product: - read tags: - workspaceProduct @@ -504,7 +504,7 @@ paths: delete: x-onecx: permissions: - workspace: + product: - delete tags: - workspaceProduct @@ -525,7 +525,7 @@ paths: put: x-onecx: permissions: - workspace: + product: - write tags: - workspaceProduct @@ -558,7 +558,7 @@ paths: get: x-onecx: permissions: - workspace: + product: - read tags: - workspaceProduct @@ -579,7 +579,7 @@ paths: /products: x-onecx: permissions: - workspace: + product: - read post: tags: @@ -957,7 +957,7 @@ paths: get: x-onecx: permissions: - workspace: + product: - read tags: - imagesInternal