Skip to content

Commit

Permalink
feat(workbench/view): associate sci-router-outlet with provider and…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
danielwiehl authored and Marcarrian committed Oct 11, 2022
1 parent 74db341 commit 47f0f96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<wb-content-as-overlay [overlayHost]="iframeHost">
<sci-router-outlet #router_outlet
[name]="viewId"
[ngClass]="microfrontendCssClasses"
[attr.data-capabilityid]="viewCapability && viewCapability.metadata!.id"
[attr.data-app]="viewCapability && viewCapability.metadata!.appSymbolicName"
[ngClass]="viewCssClasses" class="e2e-view"
[keystrokes]="keystrokesToBubble$ | async">
</sci-router-outlet>
</wb-content-as-overlay>
Original file line number Diff line number Diff line change
Expand Up @@ -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<ViewContainerRef>;

@ViewChild('router_outlet', {static: true})
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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];
}

/**
Expand All @@ -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.
*/
Expand Down

0 comments on commit 47f0f96

Please sign in to comment.