From 04bcfe1da4d797f1acd44784721a8dd1cc86a8ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 28 Oct 2024 08:38:45 +0000 Subject: [PATCH] Fixing a bug with initial data source being set to local cluster (#1189) (#1190) (cherry picked from commit 66abae36ef706687d2bbdd7e2e2574911203ca1c) Signed-off-by: Kshitij Tandon Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] (cherry picked from commit d37f0b1e07ef071e2d9f697661e4dcbabc35dd70) Signed-off-by: github-actions[bot] --- public/pages/Main/Main.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/pages/Main/Main.tsx b/public/pages/Main/Main.tsx index 5fa273475..43013b4c1 100644 --- a/public/pages/Main/Main.tsx +++ b/public/pages/Main/Main.tsx @@ -198,7 +198,7 @@ const LocalCluster: DataSourceOption = { label: i18n.translate("dataSource.localCluster", { defaultMessage: "Local cluster", }), - id: "", + id: "Local", }; export const dataSourceObservable = new BehaviorSubject(LocalCluster); @@ -231,8 +231,8 @@ export default class Main extends Component { * empty string: using the local cluster. * string: using the selected data source. */ - dataSourceLoading: dataSourceId === undefined ? props.multiDataSourceEnabled : false, - }; + dataSourceLoading: dataSourceId === undefined || dataSourceId === "Local" ? props.multiDataSourceEnabled : false, + }; //Checking for dataSourceId to be Local to ensure that we set the dataSource once so that if no Local cluster present then it is set to default data source } setDataSourceReadOnly = (readonly: boolean) => { @@ -280,6 +280,10 @@ export default class Main extends Component { } onSelectedDataSources = (dataSources: DataSourceOption[]) => { + if (dataSources.length == 0) { + //No datasource selected + return; + } const { id = "", label = "" } = dataSources[0] || {}; if (this.state.dataSourceId !== id || this.state.dataSourceLabel !== label) { this.setState({