mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Fix cache timeout persistence (#42204)
* user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * WIP: Mob session work 🚧🔱 Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: joshhunt <josh@trtr.co> Co-authored-by: kay delaney <kay@grafana.com>
This commit is contained in:
parent
b3e417f768
commit
67a1052334
@ -487,7 +487,7 @@ export interface DataQueryRequest<TQuery extends DataQuery = DataQuery> {
|
||||
timezone: string;
|
||||
app: CoreApp | string;
|
||||
|
||||
cacheTimeout?: string;
|
||||
cacheTimeout?: string | null;
|
||||
rangeRaw?: RawTimeRange;
|
||||
timeInfo?: string; // The query time description (blue text in the upper right)
|
||||
panelId?: number;
|
||||
|
@ -4,6 +4,7 @@ import { PanelModel } from '../../state';
|
||||
import { getLocationSrv } from '@grafana/runtime';
|
||||
import { QueryGroupDataSource, QueryGroupOptions } from 'app/types';
|
||||
import { DataQuery } from '@grafana/data';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
|
||||
interface Props {
|
||||
/** Current panel */
|
||||
@ -27,7 +28,10 @@ export class PanelEditorQueries extends PureComponent<Props> {
|
||||
default: true,
|
||||
};
|
||||
|
||||
const datasourceSettings = getDatasourceSrv().getInstanceSettings(dataSource.uid);
|
||||
|
||||
return {
|
||||
cacheTimeout: datasourceSettings?.meta.queryOptions?.cacheTimeout ? panel.cacheTimeout : undefined,
|
||||
dataSource,
|
||||
queries: panel.targets,
|
||||
maxDataPoints: panel.maxDataPoints,
|
||||
|
@ -3,7 +3,7 @@ import { Provider } from 'react-redux';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { Props, UnthemedDashboardPage } from './DashboardPage';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
import { locationService, setDataSourceSrv } from '@grafana/runtime';
|
||||
import { DashboardModel } from '../state';
|
||||
import { configureStore } from '../../../store/configureStore';
|
||||
import { mockToolkitActionCreator } from 'test/core/redux/mocks';
|
||||
@ -208,6 +208,12 @@ describe('DashboardPage', () => {
|
||||
});
|
||||
|
||||
dashboardPageScenario('When going into edit mode', (ctx) => {
|
||||
setDataSourceSrv({
|
||||
get: jest.fn().mockResolvedValue({}),
|
||||
getInstanceSettings: jest.fn().mockReturnValue({ meta: {} }),
|
||||
getList: jest.fn(),
|
||||
});
|
||||
|
||||
ctx.setup(() => {
|
||||
ctx.mount({
|
||||
dashboard: getTestDashboard(),
|
||||
|
@ -171,7 +171,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
isInView = false;
|
||||
configRev = 0; // increments when configs change
|
||||
hasRefreshed?: boolean;
|
||||
cacheTimeout?: any;
|
||||
cacheTimeout?: string | null;
|
||||
cachedPluginOptions: Record<string, PanelOptionsCache> = {};
|
||||
legend?: { show: boolean; sort?: string; sortDesc?: boolean };
|
||||
plugin?: PanelPlugin;
|
||||
@ -449,6 +449,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
uid: dataSource.uid,
|
||||
type: dataSource.type,
|
||||
};
|
||||
this.cacheTimeout = options.cacheTimeout;
|
||||
this.timeFrom = options.timeRange?.from;
|
||||
this.timeShift = options.timeRange?.shift;
|
||||
this.hideTimeOverride = options.timeRange?.hide;
|
||||
|
@ -51,7 +51,7 @@ export interface QueryRunnerOptions<
|
||||
maxDataPoints: number;
|
||||
minInterval: string | undefined | null;
|
||||
scopedVars?: ScopedVars;
|
||||
cacheTimeout?: string;
|
||||
cacheTimeout?: string | null;
|
||||
transformations?: DataTransformerConfig[];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user