diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx index ecb5b5c08645..b2109ceb08ca 100644 --- a/src/plugins/management/public/components/management_app/management_app.tsx +++ b/src/plugins/management/public/components/management_app/management_app.tsx @@ -37,8 +37,7 @@ import { ManagementSection, MANAGEMENT_BREADCRUMB } from '../../utils'; import { ManagementRouter } from './management_router'; import { ManagementSidebarNav } from '../management_sidebar_nav'; import { reactRouterNavigate } from '../../../../opensearch_dashboards_react/public'; -import { SectionsServiceStart, ManagementSectionId } from '../../types'; -import { ApplicationStart, WorkspacesStart } from '../../../../../core/public'; +import { SectionsServiceStart } from '../../types'; import './management_app.scss'; @@ -52,12 +51,10 @@ export interface ManagementAppDependencies { sections: SectionsServiceStart; opensearchDashboardsVersion: string; setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void; - capabilities: ApplicationStart['capabilities']; - workspaces: WorkspacesStart; } export const ManagementApp = ({ dependencies, history }: ManagementAppProps) => { - const { setBreadcrumbs, capabilities, workspaces } = dependencies; + const { setBreadcrumbs } = dependencies; const [selectedId, setSelectedId] = useState(''); const [sections, setSections] = useState(); @@ -82,19 +79,8 @@ export const ManagementApp = ({ dependencies, history }: ManagementAppProps) => ); useEffect(() => { - // If workspace is enabled and user has entered workspace, hide advance settings and dataSource menu - if (capabilities.workspaces.enabled && workspaces.currentWorkspace$.getValue()) { - const opensearchDashboardsSection = dependencies.sections - .getSectionsEnabled() - .find((section) => section.id === ManagementSectionId.OpenSearchDashboards); - const disabledApps = opensearchDashboardsSection?.apps.filter( - (app) => app.id === 'settings' || app.id === 'dataSources' - ); - disabledApps?.forEach((app) => app.disable()); - } - setSections(dependencies.sections.getSectionsEnabled()); - }, [dependencies.sections.getSectionsEnabled(), capabilities.workspaces.enabled, workspaces.currentWorkspace$.getValue()]); + }, [dependencies.sections]); if (!sections) { return null; diff --git a/src/plugins/management/public/plugin.ts b/src/plugins/management/public/plugin.ts index 2c1bca7907de..81a970a0fc48 100644 --- a/src/plugins/management/public/plugin.ts +++ b/src/plugins/management/public/plugin.ts @@ -87,8 +87,6 @@ export class ManagementPlugin implements Plugin () = interface WorkspacePluginSetupDeps { savedObjectsManagement?: SavedObjectsManagementPluginSetup; + management: ManagementSetup; } export class WorkspacePlugin implements Plugin<{}, {}> { @@ -98,7 +100,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(); /** @@ -140,6 +145,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 + const managementSectionApps = management.sections.section.opensearchDashboards.getAppsEnabled(); + const disabledApps = managementSectionApps.filter( + (app) => app.id === 'settings' || app.id === 'dataSources' + ); + disabledApps?.forEach((app) => app.disable()); } }