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'; + +