Skip to content

Commit

Permalink
[Enhancement] De-register reporting when MDS is enabled (#411) (#412)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0af5edd)

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 161eee7 commit f6d235b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 34 deletions.
4 changes: 3 additions & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"opensearchDashboardsUtils"
],
"optionalPlugins": [
"share"
"share",
"dataSource",
"dataSourceManagement"
],
"server": true,
"ui": true,
Expand Down
77 changes: 44 additions & 33 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,59 @@ import {
CoreStart,
Plugin,
} from '../../../src/core/public';
import { DataSourcePluginSetup } from '../../../src/plugins/data_source/public';
import { PLUGIN_ID, PLUGIN_NAME } from '../common';
import './components/context_menu/context_menu';
import { applicationService } from './components/utils/application_service';
import { uiSettingsService } from './components/utils/settings_service';
import { registerAllPluginNavGroups } from './plugin_nav';
import {
AppPluginStartDependencies,
ReportsDashboardsPluginSetup,
ReportsDashboardsPluginStart,
AppPluginStartDependencies,
} from './types';
import './components/context_menu/context_menu';
import { PLUGIN_ID, PLUGIN_NAME } from '../common';
import { uiSettingsService } from './components/utils/settings_service';
import { applicationService } from './components/utils/application_service';
import { registerAllPluginNavGroups } from './plugin_nav';

export interface ReportingPluginSetupDependencies {
dataSource: DataSourcePluginSetup;
}

export class ReportsDashboardsPlugin
implements Plugin<ReportsDashboardsPluginSetup, ReportsDashboardsPluginStart> {
public setup(core: CoreSetup): ReportsDashboardsPluginSetup {
implements
Plugin<ReportsDashboardsPluginSetup, ReportsDashboardsPluginStart> {
public setup(
core: CoreSetup,
{ dataSource }: ReportingPluginSetupDependencies
): ReportsDashboardsPluginSetup {
uiSettingsService.init(core.uiSettings, core.http);
// Register an application into the side navigation menu
core.application.register({
id: PLUGIN_ID,
title: i18n.translate('opensearch.reports.pluginName', {
defaultMessage: PLUGIN_NAME,
}),
category: {
id: 'opensearch',
label: i18n.translate('opensearch.reports.categoryName', {
defaultMessage: 'OpenSearch Plugins',
if (!dataSource) {
core.application.register({
id: PLUGIN_ID,
title: i18n.translate('opensearch.reports.pluginName', {
defaultMessage: PLUGIN_NAME,
}),
category: {
id: 'opensearch',
label: i18n.translate('opensearch.reports.categoryName', {
defaultMessage: 'OpenSearch Plugins',
}),
order: 2000,
},
order: 2000,
},
order: 2000,
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(
coreStart,
depsStart as AppPluginStartDependencies,
params
);
},
});
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in opensearch_dashboards.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(
coreStart,
depsStart as AppPluginStartDependencies,
params
);
},
});
}
registerAllPluginNavGroups(core);
// Return methods that should be available to other plugins
return {};
Expand All @@ -62,5 +73,5 @@ export class ReportsDashboardsPlugin
return {};
}

public stop() { }
public stop() {}
}

0 comments on commit f6d235b

Please sign in to comment.