From fb76ee9beee3a98d9b7c0783df072abe745acd7a Mon Sep 17 00:00:00 2001 From: Zhongnan Su Date: Wed, 17 Apr 2024 17:13:12 -0700 Subject: [PATCH] [MD]Refactor dev tool to use dataSourceManagement.ui API to get DataSourceSelector (#6477) * Refactor dev tool to use dataSourceManagement.ui interfaces to obtain DataSourceSelector Signed-off-by: Zhongnan Su --- changelogs/fragments/6477.yml | 2 + .../dev_tools/opensearch_dashboards.json | 5 +- src/plugins/dev_tools/public/application.tsx | 48 +++++++++---------- src/plugins/dev_tools/public/plugin.ts | 5 +- 4 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 changelogs/fragments/6477.yml diff --git a/changelogs/fragments/6477.yml b/changelogs/fragments/6477.yml new file mode 100644 index 000000000000..fe9c055906f4 --- /dev/null +++ b/changelogs/fragments/6477.yml @@ -0,0 +1,2 @@ +refactor: +- Refactor dev tool to use dataSourceManagement.ui API to get DataSourceSelector ([#6477](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6477)) \ No newline at end of file diff --git a/src/plugins/dev_tools/opensearch_dashboards.json b/src/plugins/dev_tools/opensearch_dashboards.json index 97dbe29f3001..c8f4ccc88439 100644 --- a/src/plugins/dev_tools/opensearch_dashboards.json +++ b/src/plugins/dev_tools/opensearch_dashboards.json @@ -3,7 +3,6 @@ "version": "opensearchDashboards", "server": false, "ui": true, - "optionalPlugins": ["dataSource", "managementOverview"], - "requiredPlugins": ["urlForwarding"], - "requiredBundles": ["dataSourceManagement"] + "optionalPlugins": ["dataSource", "managementOverview", "dataSourceManagement"], + "requiredPlugins": ["urlForwarding"] } diff --git a/src/plugins/dev_tools/public/application.tsx b/src/plugins/dev_tools/public/application.tsx index ebd70960ba1e..569c4b82a7dd 100644 --- a/src/plugins/dev_tools/public/application.tsx +++ b/src/plugins/dev_tools/public/application.tsx @@ -39,13 +39,12 @@ import { ApplicationStart, ChromeStart, CoreStart, - IUiSettingsClient, NotificationsStart, SavedObjectsStart, ScopedHistory, } from 'src/core/public'; -import { DataSourceSelector } from '../../data_source_management/public'; +import { DataSourceManagementPluginSetup } from 'src/plugins/data_source_management/public'; import { DevToolApp } from './dev_tool'; import { DevToolsSetupDependencies } from './plugin'; import { addHelpMenuToAppChrome } from './utils/util'; @@ -56,8 +55,7 @@ interface DevToolsWrapperProps { savedObjects: SavedObjectsStart; notifications: NotificationsStart; dataSourceEnabled: boolean; - hideLocalCluster: boolean; - uiSettings: IUiSettingsClient; + dataSourceManagement?: DataSourceManagementPluginSetup; } interface MountedDevToolDescriptor { @@ -73,8 +71,7 @@ function DevToolsWrapper({ savedObjects, notifications: { toasts }, dataSourceEnabled, - hideLocalCluster, - uiSettings, + dataSourceManagement, }: DevToolsWrapperProps) { const mountedTool = useRef(null); const [isLoading, setIsLoading] = React.useState(true); @@ -117,6 +114,21 @@ function DevToolsWrapper({ setIsLoading(false); }; + const renderDataSourceSelector = () => { + const DataSourceSelector = dataSourceManagement!.ui.DataSourceSelector; + return ( +
+ +
+ ); + }; + return (
@@ -135,19 +147,7 @@ function DevToolsWrapper({ ))} - {dataSourceEnabled && !isLoading ? ( -
- -
- ) : null} + {dataSourceEnabled && !isLoading && dataSourceManagement && renderDataSourceSelector()}
{}; } @@ -255,8 +254,7 @@ export function renderApp( savedObjects={savedObjects} notifications={notifications} dataSourceEnabled={dataSourceEnabled} - hideLocalCluster={hideLocalCluster} - uiSettings={uiSettings} + dataSourceManagement={dataSourceManagement} /> )} /> diff --git a/src/plugins/dev_tools/public/plugin.ts b/src/plugins/dev_tools/public/plugin.ts index bb0b6ee1d981..944ea6d96ba3 100644 --- a/src/plugins/dev_tools/public/plugin.ts +++ b/src/plugins/dev_tools/public/plugin.ts @@ -33,7 +33,7 @@ import { Plugin, CoreSetup, AppMountParameters } from 'src/core/public'; import { AppUpdater } from 'opensearch-dashboards/public'; import { i18n } from '@osd/i18n'; import { sortBy } from 'lodash'; - +import { DataSourceManagementPluginSetup } from 'src/plugins/data_source_management/public'; import { DataSourcePluginSetup } from 'src/plugins/data_source/public'; import { AppNavLinkStatus, DEFAULT_APP_CATEGORIES } from '../../../core/public'; import { UrlForwardingSetup } from '../../url_forwarding/public'; @@ -43,8 +43,9 @@ import './index.scss'; import { ManagementOverViewPluginSetup } from '../../management_overview/public'; export interface DevToolsSetupDependencies { - dataSource?: DataSourcePluginSetup; urlForwarding: UrlForwardingSetup; + dataSource?: DataSourcePluginSetup; + dataSourceManagement?: DataSourceManagementPluginSetup; managementOverview?: ManagementOverViewPluginSetup; }