mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Don't run queries on datasource change (#26033)
- more and more datasources are having long-running queries, automatically triggering is becoming more of a burden than a help. - some datasource queries might actually cost money, so running queries should be explicit.
This commit is contained in:
parent
66460ae740
commit
081f954a2b
@ -259,7 +259,7 @@ describe('changing datasource', () => {
|
||||
|
||||
jest.spyOn(Actions, 'importQueries').mockImplementationOnce(() => jest.fn);
|
||||
jest.spyOn(Actions, 'loadDatasource').mockImplementationOnce(() => jest.fn);
|
||||
jest.spyOn(Actions, 'runQueries').mockImplementationOnce(() => jest.fn);
|
||||
const runQueriesAction = jest.spyOn(Actions, 'runQueries').mockImplementationOnce(() => jest.fn);
|
||||
const dispatchedActions = await thunkTester(initialState)
|
||||
.givenThunk(changeDatasource)
|
||||
.whenThunkIsDispatched(exploreId, name);
|
||||
@ -272,6 +272,8 @@ describe('changing datasource', () => {
|
||||
mode: ExploreMode.Logs,
|
||||
}),
|
||||
]);
|
||||
// Don't run queries just on datasource change
|
||||
expect(runQueriesAction).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -157,7 +157,6 @@ export function changeDatasource(exploreId: ExploreId, datasourceName: string):
|
||||
}
|
||||
|
||||
await dispatch(loadDatasource(exploreId, newDataSourceInstance, orgId));
|
||||
dispatch(runQueries(exploreId));
|
||||
};
|
||||
}
|
||||
|
||||
@ -265,11 +264,12 @@ export function loadExploreDatasourcesAndSetDatasource(
|
||||
exploreId: ExploreId,
|
||||
datasourceName: string
|
||||
): ThunkResult<void> {
|
||||
return dispatch => {
|
||||
return async dispatch => {
|
||||
const exploreDatasources = getExploreDatasources();
|
||||
|
||||
if (exploreDatasources.length >= 1) {
|
||||
dispatch(changeDatasource(exploreId, datasourceName));
|
||||
await dispatch(changeDatasource(exploreId, datasourceName));
|
||||
dispatch(runQueries(exploreId));
|
||||
} else {
|
||||
dispatch(loadDatasourceMissingAction({ exploreId }));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user