Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/246 #279

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MessageBoxOpenerPageComponent {
const currentView = Beans.get(WorkbenchView);
const unsetViewContext = (this.form.get(VIEW_CONTEXT).value === false);

unsetViewContext && Beans.register(WorkbenchView, {useValue: undefined});
unsetViewContext && Beans.register(WorkbenchView, {useValue: null});
try {
this._messageBoxService.open({
title: this.form.get(TITLE).value.replace(/\\n/g, '\n') || undefined, // restore line breaks as sanitized by the user agent
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
"@angular/platform-browser": "11.0.0",
"@angular/platform-browser-dynamic": "11.0.0",
"@angular/router": "11.0.0",
"@scion/microfrontend-platform": "1.0.0-beta.13",
"@scion/toolkit": "11.0.0-beta.10",
"@scion/toolkit.internal": "11.0.0-beta.10",
"@scion/microfrontend-platform": "1.0.0-beta.15",
"@scion/toolkit": "11.0.0-beta.11",
"@scion/toolkit.internal": "11.0.0-beta.11",
"rxjs": "6.6.0",
"tslib": "2.0.0",
"zone.js": "0.10.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class WorkbenchPopupService {
// To be able to integrate popups from apps without workbench integration, we do not delegate the opening of the popup to
// the app that provides the requested popup, but interact with the workbench directly. Nevertheless, we issue an intent
// so that the platform throws an error in case of unqualified interaction.
await Beans.get(IntentClient).publish<WorkbenchPopupConfig>({type: WorkbenchCapabilities.Popup, qualifier, params: Maps.coerce(config.params)}, {...config, anchor: undefined});
await Beans.get(IntentClient).publish<WorkbenchPopupConfig>({type: WorkbenchCapabilities.Popup, qualifier, params: Maps.coerce(config.params)}, {...config, anchor: undefined!});

const view = Beans.opt(WorkbenchView);
const popupCommand: ɵWorkbenchPopupCommand = {
Expand All @@ -85,7 +85,7 @@ export class WorkbenchPopupService {
]),
context: {
viewId: view?.viewId,
capabilityId: await view?.capability$.pipe(map(capability => capability.metadata.id), take(1)).toPromise(),
capabilityId: await view?.capability$.pipe(map(capability => capability.metadata!.id), take(1)).toPromise(),
},
};
const popupOriginPublisher = this.observePopupOrigin$(config).subscribe(origin => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export abstract class WorkbenchPopup {
/**
* Capability that represents the microfrontend loaded into this workbench popup.
*/
public readonly capability: WorkbenchPopupCapability;
public abstract readonly capability: WorkbenchPopupCapability;

/**
* Parameters including qualifier entries as passed for navigation by the popup opener.
*/
public readonly params: Map<string, any>;
public abstract readonly params: Map<string, any>;

/**
* Closes the popup. Optionally, pass a result to the popup opener.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class WorkbenchRouter {
const {intent, capability} = await this.currentNavigation();
return {
capabilities: [capability],
qualifier: intent.qualifier,
qualifier: intent.qualifier!, // a view must always be qualified
extras: {
...extras,
target: 'self',
Expand Down Expand Up @@ -133,7 +133,7 @@ export class WorkbenchRouter {

return {
capability: currentCapability,
intent: this.deriveViewIntent(currentCapability.qualifier, currentParams),
intent: this.deriveViewIntent(currentCapability.qualifier!, currentParams), // a view must always be qualified
};
}

Expand All @@ -154,7 +154,7 @@ export class WorkbenchRouter {
* Derives the intent that was issued to open the view of the passed capability.
*/
private deriveViewIntent(capabilityQualifier: Qualifier, params: Map<string, any>): Intent {
const intentQualifier = Object.entries(capabilityQualifier).reduce((acc, [key, value]) => {
const intentQualifier = Object.entries(capabilityQualifier).reduce<Qualifier>((acc, [key, value]) => {
if (!params.has(key) && value !== '?') {
throw Error(`[ViewContextError] Missing required qualifier param '${key}'.`);
}
Expand Down
14 changes: 7 additions & 7 deletions projects/scion/workbench-client/src/lib/view/workbench-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export abstract class WorkbenchView {
/**
* Represents the identity of this workbench view.
*/
public readonly viewId: string;
public abstract readonly viewId: string;

/**
* Observable containing the view capability that represents the microfrontend loaded into this workbench view.
Expand All @@ -46,7 +46,7 @@ export abstract class WorkbenchView {
* or navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before
* displaying another microfrontend.
*/
public readonly capability$: Observable<WorkbenchViewCapability>;
public abstract readonly capability$: Observable<WorkbenchViewCapability>;

/**
* Observable containing the parameters including the qualifier as passed for navigation in {@link WorkbenchNavigationExtras.params}.
Expand All @@ -56,7 +56,7 @@ export abstract class WorkbenchView {
* navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before displaying
* another microfrontend.
*/
public readonly params$: Observable<Map<string, any>>;
public abstract readonly params$: Observable<Map<string, any>>;

/**
* Indicates whether this is the active view in its view part.
Expand All @@ -66,7 +66,7 @@ export abstract class WorkbenchView {
* the view or navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before displaying
* another microfrontend.
*/
public readonly active$: Observable<boolean>;
public abstract readonly active$: Observable<boolean>;

/**
* Sets the title to be displayed in the view tab.
Expand Down Expand Up @@ -139,7 +139,7 @@ export class ɵWorkbenchView implements WorkbenchView, PreDestroy { // tslint:di
*/
private _beforeInAppNavigation$ = new Subject<void>();
private _closingListeners = new Set<ViewClosingListener>();
private _closingSubscription: Subscription;
private _closingSubscription: Subscription | undefined;

public active$: Observable<boolean>;
public capability$: Observable<WorkbenchViewCapability>;
Expand Down Expand Up @@ -264,7 +264,7 @@ export class ɵWorkbenchView implements WorkbenchView, PreDestroy { // tslint:di
public removeClosingListener(listener: ViewClosingListener): void {
if (this._closingListeners.delete(listener) && this._closingListeners.size === 0) {
this._closingSubscription?.unsubscribe();
this._closingSubscription = null;
this._closingSubscription = undefined;
}
}

Expand Down Expand Up @@ -405,7 +405,7 @@ function lookupViewCapabilityAndShareReplay(): OperatorFunction<string, Workbenc
shareReplay({refCount: true, bufferSize: 1}),
// Ensure not to replay a stale capability upon the subscription of new subscribers. For this reason, we install a filter to filter them out.
// The 'shareReplay' operator would replay a stale capability if the source has emitted a new capability id, but the lookup for it did not complete yet.
filter(viewCapability => latestViewCapabilityId === viewCapability.metadata.id),
filter(viewCapability => latestViewCapabilityId === viewCapability.metadata!.id),
);
}

11 changes: 9 additions & 2 deletions projects/scion/workbench-client/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
"declarationMap": true,
"stripInternal": true,
"inlineSources": true,
"types": []
"types": [],
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
"enableResourceInlining": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
},
"exclude": [
"src/test.ts",
Expand Down
5 changes: 4 additions & 1 deletion projects/scion/workbench-client/tslint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../../tslint.json"
"extends": "../../../tslint.json",
"rules": {
"no-non-null-assertion": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ export class ActivityPartComponent {
private _panelWidth = PANEL_INITIAL_WIDTH;
private _panelWidth$ = new Subject<number>();

@ViewChild('viewport')
public viewport: ElementRef;

@ViewChild('panel', {read: ElementRef})
private _panelElementRef: ElementRef;
private _panelElementRef!: ElementRef;

constructor(public host: ElementRef<HTMLElement>,
public activityPartService: WorkbenchActivityPartService,
Expand All @@ -69,7 +66,7 @@ export class ActivityPartComponent {
return this.activityPartService.activities.filter(it => it.visible);
}

public get activeActivity(): Activity {
public get activeActivity(): Activity | null {
const activeActivity = this.activityPartService.activeActivity;
return activeActivity && activeActivity.visible ? activeActivity : null;
}
Expand Down
40 changes: 20 additions & 20 deletions projects/scion/workbench/src/lib/activity-part/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@ export abstract class Activity {
/**
* Specifies the title of the activity.
*/
public title: string;
public abstract title: string | null;

/**
* Specifies CSS class(es) added to the activity item and activity panel, e.g. used for e2e testing.
*/
public cssClass: string | string[];
public abstract cssClass: string | string[] | undefined;

/**
* Specifies the text for the activity item.
*
* You can use it in combination with `itemCssClass`, e.g. to render an icon glyph by using its textual name.
*/
public itemText: string;
public abstract itemText: string | null;

/**
* Specifies CSS class(es) added to the activity item, e.g. used for e2e testing or to set an icon font class.
*/
public itemCssClass: string | string[];
public abstract itemCssClass: string | string[] | undefined;
/**
* Controls whether to open this activity in the activity panel or to open it in a separate view.
*/
public target: 'activity-panel' | 'view';
public abstract target: 'activity-panel' | 'view';

/**
* Controls whether to show or hide this activity. By default, this activity is showing.
*/
public visible: boolean;
public abstract visible: boolean;

/**
* Specifies where to insert this activity in the list of activities.
*/
public position: number;
public abstract position: number | undefined;

/**
* Specifies the number of pixels added to the activity panel width if this is the active activity.
*/
public panelWidthDelta: number;
public abstract panelWidthDelta: number;

/**
* Specifies the routing commands used by Angular router to navigate when this activity is activated.
Expand All @@ -61,27 +61,27 @@ export abstract class Activity {
/**
* Returns the routing commands of this activity.
*/
public abstract get commands(): any[];
public abstract readonly commands: any[];

/**
* Returns the routing path of this activity.
*/
public abstract get path(): string;
public abstract readonly path: string | undefined;

/**
* Emits upon activation change of this activity.
*/
public abstract get active$(): Observable<boolean>;
public abstract readonly active$: Observable<boolean>;

/**
* Indicates if this activity is currently active.
*/
public abstract get active(): boolean;
public abstract readonly active: boolean;

/**
* Returns the actions associated with this activity.
*/
public abstract get actions(): ActivityAction[];
public abstract readonly actions: ActivityAction[];

/**
* Associates an action with this activity. When this activity is active, it is displayed in the activity panel header.
Expand All @@ -95,19 +95,19 @@ export class InternalActivity implements Activity {

private _commands: any[] = [];
private _actions: ActivityAction[] = [];
private _path: string;
private _path: string | undefined;
private _active$ = new BehaviorSubject<boolean>(false);

public panelWidthDelta = 0;
public title: string;
public cssClass: string | string[];
public title: string | null = null;
public cssClass: string | string[] | undefined;

public itemText: string;
public itemCssClass: string | string[];
public itemText: string | null = null;
public itemCssClass: string | string[] | undefined;

public target: 'activity-panel' | 'view' = 'activity-panel';
public visible = true;
public position: number;
public position: number | undefined;

constructor(private _wbRouter: WorkbenchRouter, private _injector: Injector) {
}
Expand All @@ -125,7 +125,7 @@ export class InternalActivity implements Activity {
return this._commands;
}

public get path(): string {
public get path(): string | undefined {
return this._path;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import { Directive, OnDestroy, TemplateRef } from '@angular/core';
import { WorkbenchActivityPartService } from './workbench-activity-part.service';
import { Activity } from './activity';
import { ActivatedRoute } from '@angular/router';
import { Disposable } from '../disposable';

Expand All @@ -34,18 +33,17 @@ import { Disposable } from '../disposable';
})
export class WbActivityActionDirective implements OnDestroy {

private readonly _activity: Activity;
private readonly _action: Disposable;

constructor(private _template: TemplateRef<void>,
activityService: WorkbenchActivityPartService,
route: ActivatedRoute) {
this._activity = activityService.getActivityFromRoutingContext(route.snapshot);
if (!this._activity) {
const activity = activityService.getActivityFromRoutingContext(route.snapshot);
if (!activity) {
throw Error('[RoutingContextError] Route not in the context of an activity');
}

this._action = this._activity.registerAction(this._template);
this._action = activity.registerAction(this._template);
}

public ngOnDestroy(): void {
Expand Down
Loading