Skip to content

Commit

Permalink
fix test snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl committed Mar 7, 2024
1 parent d639c1d commit efc9053
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.

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

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

11 changes: 9 additions & 2 deletions src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type WorkspaceAppType = (params: AppMountParameters, services: Services) => () =

export class WorkspacePlugin implements Plugin<{}, {}> {
private coreStart?: CoreStart;
private currentWorkspaceIdSubscription?: Subscription;
private currentWorkspaceSubscription?: Subscription;
private getWorkspaceIdFromURL(): string | null {
return getWorkspaceIdFromUrl(window.location.href);
Expand All @@ -36,11 +37,16 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
return allNavLinks.filter(featureMatchesConfig(features));
}

/**
* Filter nav links by currentWorkspace$, once the current workspace change, the nav links(left nav bar)
* should also be updated according to the configured features of the current workspace
*/
private filterNavLinks(core: CoreStart) {
const currentWorkspace$ = core.workspaces.currentWorkspace$;
let filterLinksByWorkspace: LinksUpdater;

currentWorkspace$.subscribe((currentWorkspace) => {
this.currentWorkspaceSubscription?.unsubscribe();
this.currentWorkspaceSubscription = currentWorkspace$.subscribe((currentWorkspace) => {
const linkUpdaters$ = core.chrome.navLinks.getLinkUpdaters$();
let linkUpdaters = linkUpdaters$.value;

Expand Down Expand Up @@ -158,14 +164,15 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
public start(core: CoreStart) {
this.coreStart = core;

this.currentWorkspaceSubscription = this._changeSavedObjectCurrentWorkspace();
this.currentWorkspaceIdSubscription = this._changeSavedObjectCurrentWorkspace();
if (core) {
this.filterNavLinks(core);
}
return {};
}

public stop() {
this.currentWorkspaceIdSubscription?.unsubscribe();
this.currentWorkspaceSubscription?.unsubscribe();
}
}

0 comments on commit efc9053

Please sign in to comment.