Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed Apr 11, 2024
1 parent 5db6063 commit a12bdb4
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
private coreStart?: CoreStart;
private currentWorkspaceIdSubscription?: Subscription;
private currentWorkspaceSubscription?: Subscription;
private managementCurrentWorkspaceSubscription?: Subscription;
private appUpdater$ = new BehaviorSubject<AppUpdater>(() => undefined);
private _changeSavedObjectCurrentWorkspace() {
if (this.coreStart) {
Expand Down Expand Up @@ -76,6 +77,26 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
});
}

/**
* If workspace is enabled and user has entered workspace, hide advance settings and dataSource menu and disable
*/
private disableManagementApps(core: CoreSetup, management: ManagementSetup) {
const currentWorkspaceId$ = core.workspaces.currentWorkspaceId$;
this.managementCurrentWorkspaceSubscription?.unsubscribe();

this.managementCurrentWorkspaceSubscription = currentWorkspaceId$.subscribe(
(currentWorkspaceId) => {
if (currentWorkspaceId) {
const managementSectionApps = management.sections.section.opensearchDashboards.getAppsEnabled();
const disabledApps = managementSectionApps.filter(
(app) => app.id === 'settings' || app.id === 'dataSources'
);
disabledApps?.forEach((app) => app.disable());
}
}
);
}

public async setup(
core: CoreSetup,
{ savedObjectsManagement, management }: WorkspacePluginSetupDeps
Expand Down Expand Up @@ -124,12 +145,8 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
});
})();

// If workspace is enabled and user has entered workspace, hide advance settings and dataSource menu and disable
const managementSectionApps = management.sections.section.opensearchDashboards.getAppsEnabled();
const disabledApps = managementSectionApps.filter(
(app) => app.id === 'settings' || app.id === 'dataSources'
);
disabledApps?.forEach((app) => app.disable());
// Hide advance settings and dataSource menus and disable in setup
this.disableManagementApps(core, management);
}
}

Expand Down Expand Up @@ -235,6 +252,6 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
public stop() {
this.currentWorkspaceIdSubscription?.unsubscribe();
this.currentWorkspaceSubscription?.unsubscribe();
this.currentWorkspaceIdSubscription?.unsubscribe();
this.managementCurrentWorkspaceSubscription?.unsubscribe();
}
}

0 comments on commit a12bdb4

Please sign in to comment.