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

hide datasource and settings menu when workspace enabled and entering workspace #325

Merged
merged 11 commits into from
Apr 15, 2024
3 changes: 2 additions & 1 deletion src/plugins/workspace/opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"server": true,
"ui": true,
"requiredPlugins": [
"savedObjects"
"savedObjects",
"management"
],
"optionalPlugins": ["savedObjectsManagement"],
"requiredBundles": ["opensearchDashboardsReact"]
Expand Down
14 changes: 13 additions & 1 deletion src/plugins/workspace/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { BehaviorSubject, Subscription } from 'rxjs';
import { i18n } from '@osd/i18n';
import { SavedObjectsManagementPluginSetup } from 'src/plugins/saved_objects_management/public';
import { ManagementSetup } from 'src/plugins/management/public';
import {
AppMountParameters,
AppNavLinkStatus,
Expand Down Expand Up @@ -33,6 +34,7 @@ type WorkspaceAppType = (params: AppMountParameters, services: Services) => () =

interface WorkspacePluginSetupDeps {
savedObjectsManagement?: SavedObjectsManagementPluginSetup;
management: ManagementSetup;
}

export class WorkspacePlugin implements Plugin<{}, {}> {
Expand Down Expand Up @@ -74,7 +76,10 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
});
}

public async setup(core: CoreSetup, { savedObjectsManagement }: WorkspacePluginSetupDeps) {
public async setup(
core: CoreSetup,
{ savedObjectsManagement, management }: WorkspacePluginSetupDeps
) {
const workspaceClient = new WorkspaceClient(core.http, core.workspaces);
await workspaceClient.init();
core.application.registerAppUpdater(this.appUpdater$);
Expand Down Expand Up @@ -118,6 +123,13 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
currentAppIdSubscription.unsubscribe();
});
})();

// If workspace is enabled and user has entered workspace, hide advance settings and dataSource menu and disable
Copy link
Collaborator

@SuZhou-Joe SuZhou-Joe Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: better to extract to a private method and listen the currentWorkspaceId$ change. currentWorkspaceId$ should be the single source of truth for detecting whether inside a workspace.

const managementSectionApps = management.sections.section.opensearchDashboards.getAppsEnabled();
const disabledApps = managementSectionApps.filter(
(app) => app.id === 'settings' || app.id === 'dataSources'
);
disabledApps?.forEach((app) => app.disable());
}
}

Expand Down
Loading