diff --git a/public/pages/utils/constants.ts b/public/pages/utils/constants.ts index a08e2ba2c..ff30dd076 100644 --- a/public/pages/utils/constants.ts +++ b/public/pages/utils/constants.ts @@ -9,10 +9,11 @@ import { DataSourceOption } from "../../../../../src/plugins/data_source_managem export const COMMENTS_ENABLED_SETTING = "plugins.alerting.comments_enabled"; const LocalCluster: DataSourceOption = { - label: i18n.translate("dataSource.localCluster", { - defaultMessage: "Local cluster", - }), - id: "", - }; - - export const dataSourceObservable = new BehaviorSubject(LocalCluster); \ No newline at end of file + label: i18n.translate("dataSource.localCluster", { + defaultMessage: "Local cluster", + }), + id: "", +}; + +// We should use empty object for default value as local cluster may be disabled +export const dataSourceObservable = new BehaviorSubject({}); \ No newline at end of file diff --git a/public/plugin.tsx b/public/plugin.tsx index 82ce91b70..bc63d80b0 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -62,7 +62,14 @@ export interface AlertingStartDeps { export class AlertingPlugin implements Plugin { private updateDefaultRouteOfManagementApplications: AppUpdater = () => { - const hash = `#/?dataSourceId=${dataSourceObservable.value?.id || ""}`; + const dataSourceValue = dataSourceObservable.value?.id; + let hash = `#/`; + // When data source value is undefined, + // it means the data source picker has not determine which data source to use(local or default data source) + // so we should not append any data source id into hash to avoid impacting the data source picker. + if (dataSourceValue !== undefined) { + hash = `#/?dataSourceId=${dataSourceValue}`; + } return { defaultPath: hash, };