diff --git a/public/components/context_menu/context_menu_helpers.js b/public/components/context_menu/context_menu_helpers.js index 1a1e9959..c0965d2e 100644 --- a/public/components/context_menu/context_menu_helpers.js +++ b/public/components/context_menu/context_menu_helpers.js @@ -13,6 +13,8 @@ import { } from './context_menu_ui'; import { timeRangeMatcher } from '../utils/utils'; import { unhashUrl } from '../../../../../src/plugins/opensearch_dashboards_utils/public'; +import { PLUGIN_ID } from '../../../common'; +import { applicationService } from '../utils/application_service'; const getReportSourceURL = (baseURI) => { const url = baseURI.substr(0, baseURI.indexOf('?')); @@ -20,8 +22,7 @@ const getReportSourceURL = (baseURI) => { return reportSourceId; }; -export const contextMenuViewReports = () => - window.location.assign('reports-dashboards#/'); +export const contextMenuViewReports = () => applicationService.getApplication().navigateToApp(PLUGIN_ID); export const getTimeFieldsFromUrl = () => { const url = unhashUrl(window.location.href); diff --git a/public/components/utils/application_service.ts b/public/components/utils/application_service.ts new file mode 100644 index 00000000..b32862db --- /dev/null +++ b/public/components/utils/application_service.ts @@ -0,0 +1,15 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { ApplicationStart} from '../../../../../src/core/public'; + +let application: ApplicationStart + +export const applicationService = { + init: (applicationStart: ApplicationStart) => { + application = applicationStart + }, + getApplication: () => application, +}; diff --git a/public/plugin.ts b/public/plugin.ts index b91b6be1..c7e18f4b 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -18,6 +18,7 @@ import { i18n } from '@osd/i18n'; 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'; export class ReportsDashboardsPlugin implements Plugin @@ -57,6 +58,7 @@ export class ReportsDashboardsPlugin } public start(core: CoreStart): ReportsDashboardsPluginStart { + applicationService.init(core.application); return {}; }