mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Explore: Fix running of log queries with shift-enter shortcut (#36600)
* Re-run query if we are running query fromo query row * Fix imports in tests * Change solution * Dispatch clear cache
This commit is contained in:
parent
b1d576c5da
commit
528fe90536
@ -19,7 +19,7 @@ import { ExploreTimeControls } from './ExploreTimeControls';
|
||||
import { LiveTailButton } from './LiveTailButton';
|
||||
import { RunButton } from './RunButton';
|
||||
import { LiveTailControls } from './useLiveTailControls';
|
||||
import { cancelQueries, clearQueries, runQueries, clearCache } from './state/query';
|
||||
import { cancelQueries, clearQueries, runQueries } from './state/query';
|
||||
import ReturnToDashboardButton from './ReturnToDashboardButton';
|
||||
import { isSplit } from './state/selectors';
|
||||
|
||||
@ -40,12 +40,10 @@ export class UnConnectedExploreToolbar extends PureComponent<Props> {
|
||||
};
|
||||
|
||||
onRunQuery = (loading = false) => {
|
||||
const { clearCache, runQueries, cancelQueries, exploreId } = this.props;
|
||||
const { runQueries, cancelQueries, exploreId } = this.props;
|
||||
if (loading) {
|
||||
return cancelQueries(exploreId);
|
||||
} else {
|
||||
// We want to give user a chance tu re-run the query even if it is saved in cache
|
||||
clearCache(exploreId);
|
||||
return runQueries(exploreId);
|
||||
}
|
||||
};
|
||||
@ -249,7 +247,6 @@ const mapDispatchToProps = {
|
||||
split: splitOpen,
|
||||
syncTimes,
|
||||
onChangeTimeZone: updateTimeZoneForSession,
|
||||
clearCache,
|
||||
};
|
||||
|
||||
const connector = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
@ -304,10 +304,19 @@ export function modifyQueries(
|
||||
/**
|
||||
* Main action to run queries and dispatches sub-actions based on which result viewers are active
|
||||
*/
|
||||
export const runQueries = (exploreId: ExploreId, options?: { replaceUrl?: boolean }): ThunkResult<void> => {
|
||||
export const runQueries = (
|
||||
exploreId: ExploreId,
|
||||
options?: { replaceUrl?: boolean; preserveCache?: boolean }
|
||||
): ThunkResult<void> => {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(updateTime({ exploreId }));
|
||||
|
||||
// We always want to clear cache unless we explicitly pass preserveCache parameter
|
||||
const preserveCache = options?.preserveCache === true;
|
||||
if (!preserveCache) {
|
||||
dispatch(clearCache(exploreId));
|
||||
}
|
||||
|
||||
const richHistory = getState().explore.richHistory;
|
||||
const exploreItemState = getState().explore[exploreId]!;
|
||||
const {
|
||||
|
@ -47,12 +47,14 @@ export const updateTimeRange = (options: {
|
||||
const { syncedTimes } = getState().explore;
|
||||
if (syncedTimes) {
|
||||
dispatch(updateTime({ ...options, exploreId: ExploreId.left }));
|
||||
dispatch(runQueries(ExploreId.left));
|
||||
// When running query by updating time range, we want to preserve cache.
|
||||
// Cached results are currently used in Logs pagination.
|
||||
dispatch(runQueries(ExploreId.left, { preserveCache: true }));
|
||||
dispatch(updateTime({ ...options, exploreId: ExploreId.right }));
|
||||
dispatch(runQueries(ExploreId.right));
|
||||
dispatch(runQueries(ExploreId.right, { preserveCache: true }));
|
||||
} else {
|
||||
dispatch(updateTime({ ...options }));
|
||||
dispatch(runQueries(options.exploreId));
|
||||
dispatch(runQueries(options.exploreId, { preserveCache: true }));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user