From 47f0f96a1151f424df2f0775bdc6feca53932586 Mon Sep 17 00:00:00 2001 From: danielwiehl Date: Tue, 11 Oct 2022 12:46:52 +0200 Subject: [PATCH] feat(workbench/view): associate `sci-router-outlet` with provider and capability identity The following attributes are added to `sci-router-outlet` when embedding a microfrontend as workbench view: - `data-capabilityid`: identity of the view capability - `data-app`: symbolic name of the application that provides the view capability --- .../microfrontend-view/microfrontend-view.component.html | 4 +++- .../microfrontend-view/microfrontend-view.component.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.html b/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.html index e0c16a0d6..43409f6f6 100644 --- a/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.html +++ b/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.html @@ -1,7 +1,9 @@ diff --git a/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.ts b/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.ts index 4a59649f5..270cb29c3 100644 --- a/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.ts +++ b/projects/scion/workbench/src/lib/microfrontend-platform/microfrontend-view/microfrontend-view.component.ts @@ -46,7 +46,7 @@ export class MicrofrontendViewComponent implements OnInit, OnDestroy, WbBeforeDe 'keydown.escape', // allows closing notifications ]; - public microfrontendCssClasses!: string[]; + public viewCapability: WorkbenchViewCapability | undefined; public iframeHost: Promise; @ViewChild('router_outlet', {static: true}) @@ -126,6 +126,7 @@ export class MicrofrontendViewComponent implements OnInit, OnDestroy, WbBeforeDe // Check if navigating to a new microfrontend. if (!prevViewCapability || prevViewCapability.metadata!.id !== viewCapability.metadata!.id) { + this.viewCapability = viewCapability; this.setViewProperties(viewCapability, activatedRoute); this.installParamsUpdater(viewCapability); } @@ -209,7 +210,6 @@ export class MicrofrontendViewComponent implements OnInit, OnDestroy, WbBeforeDe .concat(Arrays.coerce(activatedRoute.data[WorkbenchRouteData.state]?.[WorkbenchNavigationalStates.cssClass])); this._view.closable = viewCapability.properties.closable ?? true; this._view.dirty = false; - this.microfrontendCssClasses = ['e2e-view', `e2e-${viewCapability.metadata!.appSymbolicName}`, ...this._view.cssClasses]; } /** @@ -226,6 +226,10 @@ export class MicrofrontendViewComponent implements OnInit, OnDestroy, WbBeforeDe return this._view.viewId; } + public get viewCssClasses(): string[] { + return this._view.cssClasses; + } + /** * Promise that resolves once params contain the given capability id. */