From 1ddfde73d5834c37cd5b7c527cf7a3b80a57ab66 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:21:54 -0700 Subject: [PATCH] testing default ds switch changes (#1199) (#1201) (cherry picked from commit 5d3801a6c16640d3b0f5785ec8d2e1e8db43ff93) Signed-off-by: Riya Saxena Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- public/pages/Main/Main.tsx | 14 +++++--------- public/plugin.ts | 15 ++++++++++++--- public/utils/constants.ts | 5 ++++- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index f37080b6..9cfb6c89 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -156,10 +156,6 @@ export default class Main extends Component { }; dataSourceId = parsedDataSourceId; dataSourceLabel = parsedDataSourceLabel || ''; - - if (dataSourceId) { - dataSourceObservable.next({ id: dataSourceId, label: dataSourceLabel }); - } } this.state = { @@ -275,17 +271,17 @@ export default class Main extends Component { this.setState({ selectedDataSource: { ...sources[0] }, }); - DataStore.logTypes.getLogTypes(); + dataSourceObservable.next( + dataSourceInfo.activeDataSource + ); } - dataSourceObservable.next({ - id: this.state.selectedDataSource.id, - label: this.state.selectedDataSource.label, - }); + if (dataSourceLoading) { this.setState({ dataSourceLoading: false }); } }; + setDataSourceMenuReadOnly = (readOnly: boolean) => { this.setState({ dataSourceMenuReadOnly: readOnly }); }; diff --git a/public/plugin.ts b/public/plugin.ts index ba5f7056..c31db826 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -75,10 +75,19 @@ export class SecurityAnalyticsPlugin ) {} 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 determined 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, - }; + defaultPath: hash + } }; private appStateUpdater = new BehaviorSubject( diff --git a/public/utils/constants.ts b/public/utils/constants.ts index afae860c..87e36ea2 100644 --- a/public/utils/constants.ts +++ b/public/utils/constants.ts @@ -316,6 +316,9 @@ const LocalCluster: DataSourceOption = { id: '', }; -export const dataSourceObservable = new BehaviorSubject(LocalCluster); +// We should use empty object for default value as local cluster may be disabled +export const dataSourceObservable = new BehaviorSubject({}); export const DATA_SOURCE_NOT_SET_ERROR = 'Data source is not set'; + +