Skip to content

Commit

Permalink
Fixing a bug with initial data source being set to local cluster (ope…
Browse files Browse the repository at this point in the history
…nsearch-project#1189)

Signed-off-by: Kshitij Tandon <tandonks@amazon.com>
  • Loading branch information
tandonks authored Oct 15, 2024
1 parent 64014ef commit 66abae3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const LocalCluster: DataSourceOption = {
label: i18n.translate("dataSource.localCluster", {
defaultMessage: "Local cluster",
}),
id: "",
id: "Local",
};

export const dataSourceObservable = new BehaviorSubject<DataSourceOption>(LocalCluster);
Expand Down Expand Up @@ -231,8 +231,8 @@ export default class Main extends Component<MainProps, MainState> {
* 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) => {
Expand Down Expand Up @@ -280,6 +280,10 @@ export default class Main extends Component<MainProps, MainState> {
}

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({
Expand Down

0 comments on commit 66abae3

Please sign in to comment.