Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.11] Use core navigation instead of hard coding URLs #231

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions public/components/context_menu/context_menu_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ 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('?'));
const reportSourceId = url.substr(url.lastIndexOf('/') + 1, url.length);
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);
Expand Down
15 changes: 15 additions & 0 deletions public/components/utils/application_service.ts
Original file line number Diff line number Diff line change
@@ -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,
};
2 changes: 2 additions & 0 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReportsDashboardsPluginSetup, ReportsDashboardsPluginStart>
Expand Down Expand Up @@ -57,6 +58,7 @@ export class ReportsDashboardsPlugin
}

public start(core: CoreStart): ReportsDashboardsPluginStart {
applicationService.init(core.application);
return {};
}

Expand Down
Loading