Commit f00f3470 by David Committed by GitHub

Merge pull request #14033 from grafana/davkal/explore-slow-ds-load

Explore: Dont set datasource in state if navigated away
parents aa340b90 9b48338d
......@@ -94,6 +94,10 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
* Not kept in component state to prevent edit-render roundtrips.
*/
queryExpressions: string[];
/**
* Local ID cache to compare requested vs selected datasource
*/
requestedDatasourceId: string;
constructor(props) {
super(props);
......@@ -167,6 +171,9 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
const datasourceId = datasource.meta.id;
let datasourceError = null;
// Keep ID to track selection
this.requestedDatasourceId = datasourceId;
try {
const testResult = await datasource.testDatasource();
datasourceError = testResult.status === 'success' ? null : testResult.message;
......@@ -174,6 +181,11 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
datasourceError = (error && error.statusText) || 'Network error';
}
if (datasourceId !== this.requestedDatasourceId) {
// User already changed datasource again, discard results
return;
}
const historyKey = `grafana.explore.history.${datasourceId}`;
const history = store.getObject(historyKey, []);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment