Skip to content

Commit

Permalink
hide datasource and settings menu
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <tygao@amazon.com>
  • Loading branch information
raintygao committed Apr 11, 2024
1 parent e2a8ae2 commit 69bed52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ 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 } from '../../types';
import { SectionsServiceStart, ManagementSectionId } from '../../types';
import { ApplicationStart, WorkspacesStart } from '../../../../../core/public';

import './management_app.scss';

Expand All @@ -51,10 +52,12 @@ export interface ManagementAppDependencies {
sections: SectionsServiceStart;
opensearchDashboardsVersion: string;
setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void;
capabilities: ApplicationStart['capabilities'];
workspaces: WorkspacesStart;
}

export const ManagementApp = ({ dependencies, history }: ManagementAppProps) => {
const { setBreadcrumbs } = dependencies;
const { setBreadcrumbs, capabilities, workspaces } = dependencies;
const [selectedId, setSelectedId] = useState<string>('');
const [sections, setSections] = useState<ManagementSection[]>();

Expand All @@ -79,8 +82,19 @@ 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]);
}, [dependencies.sections, capabilities, workspaces]);

if (!sections) {
return null;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export class ManagementPlugin implements Plugin<ManagementSetup, ManagementStart
sections: getSectionsServiceStartPrivate(),
opensearchDashboardsVersion,
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
capabilities: coreStart.application.capabilities,
workspaces: coreStart.workspaces,
});
},
});
Expand Down

0 comments on commit 69bed52

Please sign in to comment.