From 5bb4fa649c823054df4a8e5560a704d65fa10a6f Mon Sep 17 00:00:00 2001 From: markuczy Date: Mon, 13 May 2024 12:54:36 +0200 Subject: [PATCH 1/7] feat: slot service with permission service to be proxied --- .../src/lib/services/user.service.ts | 2 +- libs/angular-remote-components/package.json | 1 + libs/angular-remote-components/src/index.ts | 3 +- .../lib/angular-remote-components.module.ts | 2 +- .../src/lib/services/permission.service.ts | 25 +++++++ .../src/lib/services/slot.service.ts | 67 ++++++++++++++++--- libs/integration-interface/src/index.ts | 1 + .../permissions/v1/permissions.model.ts | 5 ++ .../permissions/v1/permissions.topic.ts | 13 ++-- .../v1/remote-component.model.ts | 23 ++++--- .../v1/remote-components.topic.ts | 6 +- 11 files changed, 120 insertions(+), 28 deletions(-) create mode 100644 libs/angular-remote-components/src/lib/services/permission.service.ts create mode 100644 libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts diff --git a/libs/angular-integration-interface/src/lib/services/user.service.ts b/libs/angular-integration-interface/src/lib/services/user.service.ts index b72e95f4..1197e64c 100644 --- a/libs/angular-integration-interface/src/lib/services/user.service.ts +++ b/libs/angular-integration-interface/src/lib/services/user.service.ts @@ -40,7 +40,7 @@ export class UserService implements OnDestroy { ? this.permissions$.getValue()?.includes(permissionKey) : false const result = this.permissionsTopic$.getValue() - ? this.permissionsTopic$.getValue()?.includes(permissionKey) + ? this.permissionsTopic$.getValue()?.permissions?.includes(permissionKey) : oldConceptResult if (!result) { diff --git a/libs/angular-remote-components/package.json b/libs/angular-remote-components/package.json index 6b24a4b0..75347c10 100644 --- a/libs/angular-remote-components/package.json +++ b/libs/angular-remote-components/package.json @@ -5,6 +5,7 @@ "@angular/common": "^15.2.7", "@angular/core": "^15.2.7", "@onecx/angular-accelerator": "^4", + "@onecx/integration-interface": "^4", "@ngx-translate/core": "^14.0.0", "rxjs": "~7.8.0" }, diff --git a/libs/angular-remote-components/src/index.ts b/libs/angular-remote-components/src/index.ts index e943e419..d6f8b139 100644 --- a/libs/angular-remote-components/src/index.ts +++ b/libs/angular-remote-components/src/index.ts @@ -4,4 +4,5 @@ export * from './lib/model/injection-tokens' export * from './lib/components/slot/slot.component' export * from './lib/angular-remote-components.module' export * from './lib/services/slot.service' -export * from './lib/utils/provide-translate-service-for-root.utils' \ No newline at end of file +export * from './lib/services/permission.service' +export * from './lib/utils/provide-translate-service-for-root.utils' diff --git a/libs/angular-remote-components/src/lib/angular-remote-components.module.ts b/libs/angular-remote-components/src/lib/angular-remote-components.module.ts index 9df0bb4e..43a2f528 100644 --- a/libs/angular-remote-components/src/lib/angular-remote-components.module.ts +++ b/libs/angular-remote-components/src/lib/angular-remote-components.module.ts @@ -7,6 +7,6 @@ import { AppConfigService } from '@onecx/angular-accelerator' imports: [CommonModule], declarations: [SlotComponent], exports: [SlotComponent], - providers: [AppConfigService] + providers: [AppConfigService], }) export class AngularRemoteComponentsModule {} diff --git a/libs/angular-remote-components/src/lib/services/permission.service.ts b/libs/angular-remote-components/src/lib/services/permission.service.ts new file mode 100644 index 00000000..88df11f1 --- /dev/null +++ b/libs/angular-remote-components/src/lib/services/permission.service.ts @@ -0,0 +1,25 @@ +import { Injectable } from '@angular/core' +import { PermissionsTopic } from '@onecx/integration-interface' +import { filter, firstValueFrom, map } from 'rxjs' + +@Injectable({ providedIn: 'root' }) +export class PermissionService { + private permissionsTopic$ = new PermissionsTopic() + + async getPermissions(appId: string, productName: string): Promise { + this.permissionsTopic$.publish({ appId: appId, productName: productName }) + + return firstValueFrom( + this.permissionsTopic$.pipe( + filter( + (message) => + message.appId === appId && + message.productName === productName && + Array.isArray(message.permissions) && + message.permissions.length > 0 + ), + map((message) => message.permissions ?? []) + ) + ) + } +} diff --git a/libs/angular-remote-components/src/lib/services/slot.service.ts b/libs/angular-remote-components/src/lib/services/slot.service.ts index c753556f..c4a80540 100644 --- a/libs/angular-remote-components/src/lib/services/slot.service.ts +++ b/libs/angular-remote-components/src/lib/services/slot.service.ts @@ -1,19 +1,70 @@ -import { InjectionToken, Type } from '@angular/core' -import { Observable } from 'rxjs' +import { loadRemoteModule } from '@angular-architects/module-federation' +import { Injectable, InjectionToken, Type } from '@angular/core' +import { RemoteComponent, RemoteComponentsTopic } from '@onecx/integration-interface' +import { Observable, map, shareReplay } from 'rxjs' +import { PermissionService } from './permission.service' export const SLOT_SERVICE: InjectionToken = new InjectionToken('SLOT_SERVICE') export type RemoteComponentInfo = { appId: string; productName: string; baseUrl: string } export type SlotComponentConfiguration = { - componentType: Promise | undefined> | Type | undefined; - remoteComponent: RemoteComponentInfo; - permissions: Promise | string[]; + componentType: Promise | undefined> | Type | undefined + remoteComponent: RemoteComponentInfo + permissions: Promise | string[] } export interface SlotService { init(): Promise - getComponentsForSlot( - slotName: string - ): Observable + getComponentsForSlot(slotName: string): Observable +} + +@Injectable({ providedIn: 'root' }) +export class SlotService implements SlotService { + remoteComponents$ = new RemoteComponentsTopic() + + constructor(private permissionsService: PermissionService) {} + + async init(): Promise { + return Promise.resolve() + } + + getComponentsForSlot(slotName: string): Observable { + return this.remoteComponents$.pipe( + map((remoteComponentsInfo) => + (remoteComponentsInfo.slots?.find((slotMapping) => slotMapping.name === slotName)?.components ?? []) + .map((remoteComponentName) => remoteComponentsInfo.components.find((rc) => rc.name === remoteComponentName)) + .filter((remoteComponent): remoteComponent is RemoteComponent => !!remoteComponent) + .map((remoteComponent) => remoteComponent) + ), + map((infos) => + infos.map((remoteComponent) => ({ + componentType: this.loadComponent(remoteComponent), + remoteComponent, + permissions: this.permissionsService.getPermissions(remoteComponent.appId, remoteComponent.productName), + })) + ), + shareReplay() + ) + } + + private async loadComponent(component: { + remoteEntryUrl: string + exposedModule: string + }): Promise | undefined> { + try { + const exposedModule = component.exposedModule.startsWith('./') + ? component.exposedModule.slice(2) + : component.exposedModule + const m = await loadRemoteModule({ + type: 'module', + remoteEntry: component.remoteEntryUrl, + exposedModule: './' + exposedModule, + }) + return m[exposedModule] + } catch (e) { + console.log('Failed to load remote module ', component.exposedModule, component.remoteEntryUrl, e) + return undefined + } + } } diff --git a/libs/integration-interface/src/index.ts b/libs/integration-interface/src/index.ts index d531a39b..97e2ef82 100644 --- a/libs/integration-interface/src/index.ts +++ b/libs/integration-interface/src/index.ts @@ -28,6 +28,7 @@ export * from './lib/topics/remote-components/v1/remote-component.model' export * from './lib/topics/remote-components/v1/remote-components.topic' export * from './lib/topics/permissions/v1/permissions.topic' +export * from './lib/topics/permissions/v1/permissions.model' export * from './lib/topics/events/v1/events-topic' export * from './lib/topics/events/v1/topic-event-type' diff --git a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts new file mode 100644 index 00000000..e6f6d4b3 --- /dev/null +++ b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts @@ -0,0 +1,5 @@ +export interface Permissions { + appId: string + productName: string + permissions?: Array +} diff --git a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts index de03d49b..c737f7c1 100644 --- a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts +++ b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts @@ -1,7 +1,8 @@ -import { SyncableTopic } from "@onecx/accelerator"; +import { SyncableTopic } from '@onecx/accelerator' +import { Permissions } from './permissions.model' -export class PermissionsTopic extends SyncableTopic { - constructor() { - super('permissions', 1) - } - } \ No newline at end of file +export class PermissionsTopic extends SyncableTopic { + constructor() { + super('permissions', 1) + } +} diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts index 91d0c84c..c8bd7d9c 100644 --- a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts @@ -1,8 +1,15 @@ -export interface RemoteComponent { - name: string; - baseUrl: string; - remoteEntryUrl: string; - appId: string; - productName: string; - exposedModule: string; -} \ No newline at end of file +export type RemoteComponentsInfo = { components: RemoteComponent[]; slots: Slot[] } + +export type RemoteComponent = { + name: string + baseUrl: string + remoteEntryUrl: string + appId: string + productName: string + exposedModule: string +} + +export type Slot = { + name: string + components: Array +} diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts index 1fe996db..f598af88 100644 --- a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts @@ -1,8 +1,8 @@ import { Topic } from '@onecx/accelerator' -import { RemoteComponent } from './remote-component.model' +import { RemoteComponentsInfo } from './remote-component.model' -export class RemoteComponentsTopic extends Topic { +export class RemoteComponentsTopic extends Topic { constructor() { - super('remoteComponents', 1) + super('remoteComponentsInfo', 1) } } From 472a1f3ab0146a67f3f55a6f13a8875b7c663575 Mon Sep 17 00:00:00 2001 From: markuczy Date: Mon, 13 May 2024 13:26:09 +0200 Subject: [PATCH 2/7] feat: lint --- libs/angular-remote-components/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/angular-remote-components/package.json b/libs/angular-remote-components/package.json index 75347c10..5d4c2dc6 100644 --- a/libs/angular-remote-components/package.json +++ b/libs/angular-remote-components/package.json @@ -7,7 +7,8 @@ "@onecx/angular-accelerator": "^4", "@onecx/integration-interface": "^4", "@ngx-translate/core": "^14.0.0", - "rxjs": "~7.8.0" + "rxjs": "~7.8.0", + "@angular-architects/module-federation": "15.0.0" }, "dependencies": {}, "publishConfig": { From 8fa9691e99b37f96bcf411e4393dc64a47884ed9 Mon Sep 17 00:00:00 2001 From: markuczy Date: Tue, 14 May 2024 14:25:16 +0200 Subject: [PATCH 3/7] feat: new topic and structure --- .../src/lib/services/user.service.ts | 2 +- .../src/lib/services/permission.service.ts | 15 ++++++--------- libs/integration-interface/src/index.ts | 6 +++++- .../v1/permissions-rpc.model.ts} | 2 +- .../permissions-rpc/v1/permissions-rpc.topic.ts | 8 ++++++++ .../topics/permissions/v1/permissions.topic.ts | 3 +-- .../v1/remote-component.model.ts | 7 ------- .../v1/remote-components-info.model.ts | 4 ++++ .../v1/remote-components.topic.ts | 2 +- .../lib/topics/remote-components/v1/slot.model.ts | 4 ++++ 10 files changed, 31 insertions(+), 22 deletions(-) rename libs/integration-interface/src/lib/topics/{permissions/v1/permissions.model.ts => permissions-rpc/v1/permissions-rpc.model.ts} (67%) create mode 100644 libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts create mode 100644 libs/integration-interface/src/lib/topics/remote-components/v1/remote-components-info.model.ts create mode 100644 libs/integration-interface/src/lib/topics/remote-components/v1/slot.model.ts diff --git a/libs/angular-integration-interface/src/lib/services/user.service.ts b/libs/angular-integration-interface/src/lib/services/user.service.ts index 1197e64c..b72e95f4 100644 --- a/libs/angular-integration-interface/src/lib/services/user.service.ts +++ b/libs/angular-integration-interface/src/lib/services/user.service.ts @@ -40,7 +40,7 @@ export class UserService implements OnDestroy { ? this.permissions$.getValue()?.includes(permissionKey) : false const result = this.permissionsTopic$.getValue() - ? this.permissionsTopic$.getValue()?.permissions?.includes(permissionKey) + ? this.permissionsTopic$.getValue()?.includes(permissionKey) : oldConceptResult if (!result) { diff --git a/libs/angular-remote-components/src/lib/services/permission.service.ts b/libs/angular-remote-components/src/lib/services/permission.service.ts index 88df11f1..b052888b 100644 --- a/libs/angular-remote-components/src/lib/services/permission.service.ts +++ b/libs/angular-remote-components/src/lib/services/permission.service.ts @@ -1,25 +1,22 @@ import { Injectable } from '@angular/core' -import { PermissionsTopic } from '@onecx/integration-interface' +import { PermissionsRpcTopic } from '@onecx/integration-interface' import { filter, firstValueFrom, map } from 'rxjs' @Injectable({ providedIn: 'root' }) export class PermissionService { - private permissionsTopic$ = new PermissionsTopic() + private permissionsTopic$ = new PermissionsRpcTopic() async getPermissions(appId: string, productName: string): Promise { - this.permissionsTopic$.publish({ appId: appId, productName: productName }) - - return firstValueFrom( + const permissions = firstValueFrom( this.permissionsTopic$.pipe( filter( (message) => - message.appId === appId && - message.productName === productName && - Array.isArray(message.permissions) && - message.permissions.length > 0 + message.appId === appId && message.productName === productName && Array.isArray(message.permissions) ), map((message) => message.permissions ?? []) ) ) + this.permissionsTopic$.publish({ appId: appId, productName: productName }) + return permissions } } diff --git a/libs/integration-interface/src/index.ts b/libs/integration-interface/src/index.ts index 97e2ef82..340c3260 100644 --- a/libs/integration-interface/src/index.ts +++ b/libs/integration-interface/src/index.ts @@ -25,10 +25,14 @@ export * from './lib/topics/message/v1/message.model' export * from './lib/topics/message/v1/message.topic' export * from './lib/topics/remote-components/v1/remote-component.model' +export * from './lib/topics/remote-components/v1/remote-components-info.model' +export * from './lib/topics/remote-components/v1/slot.model' export * from './lib/topics/remote-components/v1/remote-components.topic' export * from './lib/topics/permissions/v1/permissions.topic' -export * from './lib/topics/permissions/v1/permissions.model' + +export * from './lib/topics/permissions-rpc/v1/permissions-rpc.topic' +export * from './lib/topics/permissions-rpc/v1/permissions-rpc.model' export * from './lib/topics/events/v1/events-topic' export * from './lib/topics/events/v1/topic-event-type' diff --git a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.model.ts similarity index 67% rename from libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts rename to libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.model.ts index e6f6d4b3..4d05ed70 100644 --- a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.model.ts +++ b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.model.ts @@ -1,4 +1,4 @@ -export interface Permissions { +export interface PermissionsRpc { appId: string productName: string permissions?: Array diff --git a/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts new file mode 100644 index 00000000..d19e8365 --- /dev/null +++ b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts @@ -0,0 +1,8 @@ +import { SyncableTopic } from '@onecx/accelerator' +import { PermissionsRpc } from './permissions-rpc.model' + +export class PermissionsRpcTopic extends SyncableTopic { + constructor() { + super('permissionsRpc', 1) + } +} diff --git a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts index c737f7c1..0d1a7b55 100644 --- a/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts +++ b/libs/integration-interface/src/lib/topics/permissions/v1/permissions.topic.ts @@ -1,7 +1,6 @@ import { SyncableTopic } from '@onecx/accelerator' -import { Permissions } from './permissions.model' -export class PermissionsTopic extends SyncableTopic { +export class PermissionsTopic extends SyncableTopic { constructor() { super('permissions', 1) } diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts index c8bd7d9c..80ffe205 100644 --- a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-component.model.ts @@ -1,5 +1,3 @@ -export type RemoteComponentsInfo = { components: RemoteComponent[]; slots: Slot[] } - export type RemoteComponent = { name: string baseUrl: string @@ -8,8 +6,3 @@ export type RemoteComponent = { productName: string exposedModule: string } - -export type Slot = { - name: string - components: Array -} diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components-info.model.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components-info.model.ts new file mode 100644 index 00000000..a067c03c --- /dev/null +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components-info.model.ts @@ -0,0 +1,4 @@ +import { RemoteComponent } from './remote-component.model' +import { Slot } from './slot.model' + +export type RemoteComponentsInfo = { components: RemoteComponent[]; slots: Slot[] } diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts index f598af88..c6eec09e 100644 --- a/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/remote-components.topic.ts @@ -1,5 +1,5 @@ import { Topic } from '@onecx/accelerator' -import { RemoteComponentsInfo } from './remote-component.model' +import { RemoteComponentsInfo } from './remote-components-info.model' export class RemoteComponentsTopic extends Topic { constructor() { diff --git a/libs/integration-interface/src/lib/topics/remote-components/v1/slot.model.ts b/libs/integration-interface/src/lib/topics/remote-components/v1/slot.model.ts new file mode 100644 index 00000000..3ce1df35 --- /dev/null +++ b/libs/integration-interface/src/lib/topics/remote-components/v1/slot.model.ts @@ -0,0 +1,4 @@ +export type Slot = { + name: string + components: Array +} From d37243fbf9e1c97d8cb09280f76848b01c79776e Mon Sep 17 00:00:00 2001 From: markuczy Date: Tue, 14 May 2024 17:12:32 +0200 Subject: [PATCH 4/7] feat: extended SlotService with component presence check --- .../src/lib/services/slot.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/angular-remote-components/src/lib/services/slot.service.ts b/libs/angular-remote-components/src/lib/services/slot.service.ts index c4a80540..9872e0ba 100644 --- a/libs/angular-remote-components/src/lib/services/slot.service.ts +++ b/libs/angular-remote-components/src/lib/services/slot.service.ts @@ -17,6 +17,7 @@ export type SlotComponentConfiguration = { export interface SlotService { init(): Promise getComponentsForSlot(slotName: string): Observable + isComponentDefinedForSlot(slotName: string): Observable } @Injectable({ providedIn: 'root' }) @@ -48,6 +49,16 @@ export class SlotService implements SlotService { ) } + isComponentDefinedForSlot(slotName: string): Observable { + return this.remoteComponents$.pipe( + map((remoteComponentsInfo) => { + const components = + remoteComponentsInfo.slots?.find((slotMapping) => slotMapping.name === slotName)?.components ?? [] + return components.length > 0 + }) + ) + } + private async loadComponent(component: { remoteEntryUrl: string exposedModule: string From 653598123dd1d51882a888e0300c5dd0f0c4e24a Mon Sep 17 00:00:00 2001 From: markuczy Date: Wed, 15 May 2024 11:54:07 +0200 Subject: [PATCH 5/7] fix: topic not synchronizable --- .../lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts index d19e8365..f1ebc0fc 100644 --- a/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts +++ b/libs/integration-interface/src/lib/topics/permissions-rpc/v1/permissions-rpc.topic.ts @@ -1,7 +1,7 @@ -import { SyncableTopic } from '@onecx/accelerator' +import { Topic } from '@onecx/accelerator' import { PermissionsRpc } from './permissions-rpc.model' -export class PermissionsRpcTopic extends SyncableTopic { +export class PermissionsRpcTopic extends Topic { constructor() { super('permissionsRpc', 1) } From 269b570cfd6db175ddad21fb53fd1604a7067d7a Mon Sep 17 00:00:00 2001 From: markuczy Date: Wed, 15 May 2024 11:54:35 +0200 Subject: [PATCH 6/7] refactor: someComponentDefinedForSlot refactor --- .../src/lib/services/slot.service.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libs/angular-remote-components/src/lib/services/slot.service.ts b/libs/angular-remote-components/src/lib/services/slot.service.ts index 9872e0ba..ae4e2099 100644 --- a/libs/angular-remote-components/src/lib/services/slot.service.ts +++ b/libs/angular-remote-components/src/lib/services/slot.service.ts @@ -17,7 +17,7 @@ export type SlotComponentConfiguration = { export interface SlotService { init(): Promise getComponentsForSlot(slotName: string): Observable - isComponentDefinedForSlot(slotName: string): Observable + isSomeComponentDefinedForSlot(slotName: string): Observable } @Injectable({ providedIn: 'root' }) @@ -49,13 +49,9 @@ export class SlotService implements SlotService { ) } - isComponentDefinedForSlot(slotName: string): Observable { + isSomeComponentDefinedForSlot(slotName: string): Observable { return this.remoteComponents$.pipe( - map((remoteComponentsInfo) => { - const components = - remoteComponentsInfo.slots?.find((slotMapping) => slotMapping.name === slotName)?.components ?? [] - return components.length > 0 - }) + map((remoteComponentsInfo) => remoteComponentsInfo.slots.some((slotMapping) => slotMapping.name == slotName)) ) } From 88f7466a6729dc4d2375e601986d7d86e5727f11 Mon Sep 17 00:00:00 2001 From: markuczy Date: Wed, 15 May 2024 11:56:12 +0200 Subject: [PATCH 7/7] fix: fixed comparsion between strings --- libs/angular-remote-components/src/lib/services/slot.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/angular-remote-components/src/lib/services/slot.service.ts b/libs/angular-remote-components/src/lib/services/slot.service.ts index ae4e2099..05fffde3 100644 --- a/libs/angular-remote-components/src/lib/services/slot.service.ts +++ b/libs/angular-remote-components/src/lib/services/slot.service.ts @@ -51,7 +51,7 @@ export class SlotService implements SlotService { isSomeComponentDefinedForSlot(slotName: string): Observable { return this.remoteComponents$.pipe( - map((remoteComponentsInfo) => remoteComponentsInfo.slots.some((slotMapping) => slotMapping.name == slotName)) + map((remoteComponentsInfo) => remoteComponentsInfo.slots.some((slotMapping) => slotMapping.name === slotName)) ) }