From 395c74b585c88356cf8c49400d6b5a64cb033fd4 Mon Sep 17 00:00:00 2001 From: Michael Mandrus Date: Tue, 31 Jan 2023 08:51:23 -0500 Subject: [PATCH] move caching config to the right place in the ds info --- packages/grafana-data/src/types/datasource.ts | 13 +++++-------- pkg/api/frontendsettings.go | 4 ++-- pkg/plugins/models.go | 4 ++-- .../components/PanelEditor/PanelEditorQueries.tsx | 2 +- .../features/query/components/QueryGroupOptions.tsx | 4 ++-- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/grafana-data/src/types/datasource.ts b/packages/grafana-data/src/types/datasource.ts index cdcb722c8ca..4da86b39889 100644 --- a/packages/grafana-data/src/types/datasource.ts +++ b/packages/grafana-data/src/types/datasource.ts @@ -133,6 +133,7 @@ export interface DataSourcePluginMeta extends PluginMet hasQueryHelp?: boolean; category?: string; queryOptions?: PluginMetaQueryOptions; + cachingConfig?: PluginQueryCachingConfig; sort?: number; streaming?: boolean; unlicensed?: boolean; @@ -145,6 +146,10 @@ interface PluginMetaQueryOptions { maxDataPoints?: boolean; minInterval?: boolean; } +/** + * Information about the datasource's query caching configuration + * When the caching feature is disabled, this config will always be falsy + */ interface PluginQueryCachingConfig { enabled?: boolean; TTLMs?: number; @@ -229,7 +234,6 @@ abstract class DataSourceApi< this.id = instanceSettings.id; this.type = instanceSettings.type; this.meta = instanceSettings.meta; - this.cachingConfig = instanceSettings.cachingConfig; this.uid = instanceSettings.uid; } @@ -307,12 +311,6 @@ abstract class DataSourceApi< */ meta: DataSourcePluginMeta; - /** - * Information about the datasource's query caching configuration - * When the caching feature is disabled, this config will always be empty - */ - cachingConfig?: PluginQueryCachingConfig; - /** * Used by alerting to check if query contains template variables */ @@ -599,7 +597,6 @@ export interface DataSourceInstanceSettings { type: datasourceSettings?.type, uid: datasourceSettings?.uid, }, - queryCachingTTL: datasourceSettings?.cachingConfig?.enabled ? panel.queryCachingTTL : undefined, + queryCachingTTL: datasourceSettings?.meta.cachingConfig?.enabled ? panel.queryCachingTTL : undefined, queries: panel.targets, maxDataPoints: panel.maxDataPoints, minInterval: panel.interval, diff --git a/public/app/features/query/components/QueryGroupOptions.tsx b/public/app/features/query/components/QueryGroupOptions.tsx index e73fdf31677..5107e2fad9f 100644 --- a/public/app/features/query/components/QueryGroupOptions.tsx +++ b/public/app/features/query/components/QueryGroupOptions.tsx @@ -188,7 +188,7 @@ export class QueryGroupOptionsEditor extends PureComponent { const tooltip = `Cache time-to-live: How long results from this queries in this panel will be cached, in milliseconds. Defaults to the TTL in the caching configuration for this datasource.`; - if (!dataSource.cachingConfig?.enabled) { + if (!dataSource.meta.cachingConfig?.enabled) { return null; } @@ -201,7 +201,7 @@ export class QueryGroupOptionsEditor extends PureComponent {