From 56702902a1f76ecc6fba12c9cba43b5b948ac376 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 9 May 2019 22:46:14 -0700 Subject: [PATCH] Plugins: Remove dataFormats key and add skipDataQuery (#16984) --- packages/grafana-ui/src/types/panel.ts | 11 +--------- pkg/api/frontendsettings.go | 21 ++++++++++--------- pkg/plugins/panel_plugin.go | 6 +----- .../dashboard/dashgrid/PanelChrome.tsx | 2 +- .../dashgrid/PanelPluginNotFound.tsx | 1 - .../dashboard/panel_editor/PanelEditor.tsx | 2 +- .../features/plugins/__mocks__/pluginMocks.ts | 3 +-- .../app/plugins/panel/alertlist/plugin.json | 2 +- public/app/plugins/panel/bargauge/plugin.json | 2 -- public/app/plugins/panel/dashlist/plugin.json | 2 +- public/app/plugins/panel/gauge/plugin.json | 2 -- public/app/plugins/panel/graph/plugin.json | 2 -- public/app/plugins/panel/heatmap/plugin.json | 2 -- public/app/plugins/panel/piechart/plugin.json | 2 -- .../app/plugins/panel/pluginlist/plugin.json | 2 +- .../app/plugins/panel/singlestat/plugin.json | 2 -- .../app/plugins/panel/singlestat2/plugin.json | 2 -- public/app/plugins/panel/table/plugin.json | 2 -- public/app/plugins/panel/table2/plugin.json | 2 -- public/app/plugins/panel/text/plugin.json | 2 +- public/app/plugins/panel/text2/plugin.json | 2 +- 21 files changed, 21 insertions(+), 53 deletions(-) diff --git a/packages/grafana-ui/src/types/panel.ts b/packages/grafana-ui/src/types/panel.ts index ea28ca2fb47..243dd32e273 100644 --- a/packages/grafana-ui/src/types/panel.ts +++ b/packages/grafana-ui/src/types/panel.ts @@ -7,18 +7,9 @@ import { PluginMeta, GrafanaPlugin } from './plugin'; export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string; export interface PanelPluginMeta extends PluginMeta { + skipDataQuery?: boolean; hideFromList?: boolean; sort: number; - - // if length>0 the query tab will show up - // Before 6.2 this could be table and/or series, but 6.2+ supports both transparently - // so it will be deprecated soon - dataFormats?: PanelDataFormat[]; -} - -export enum PanelDataFormat { - Table = 'table', - TimeSeries = 'time_series', } export interface PanelData { diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 1fceca12bfa..2f39961fdc8 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -1,9 +1,10 @@ package api import ( - "github.com/grafana/grafana/pkg/util" "strconv" + "github.com/grafana/grafana/pkg/util" + "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/log" m "github.com/grafana/grafana/pkg/models" @@ -154,15 +155,15 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf } panels[panel.Id] = map[string]interface{}{ - "module": panel.Module, - "baseUrl": panel.BaseUrl, - "name": panel.Name, - "id": panel.Id, - "info": panel.Info, - "hideFromList": panel.HideFromList, - "sort": getPanelSort(panel.Id), - "dataFormats": panel.DataFormats, - "state": panel.State, + "module": panel.Module, + "baseUrl": panel.BaseUrl, + "name": panel.Name, + "id": panel.Id, + "info": panel.Info, + "hideFromList": panel.HideFromList, + "sort": getPanelSort(panel.Id), + "skipDataQuery": panel.SkipDataQuery, + "state": panel.State, } } diff --git a/pkg/plugins/panel_plugin.go b/pkg/plugins/panel_plugin.go index b90fd41e465..f44cd21bf00 100644 --- a/pkg/plugins/panel_plugin.go +++ b/pkg/plugins/panel_plugin.go @@ -4,7 +4,7 @@ import "encoding/json" type PanelPlugin struct { FrontendPluginBase - DataFormats []string `json:"dataFormats"` + SkipDataQuery bool `json:"skipDataQuery"` } func (p *PanelPlugin) Load(decoder *json.Decoder, pluginDir string) error { @@ -16,10 +16,6 @@ func (p *PanelPlugin) Load(decoder *json.Decoder, pluginDir string) error { return err } - if p.DataFormats == nil { - p.DataFormats = []string{"time_series", "table"} - } - Panels[p.Id] = p return nil } diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index 5a6d35a4427..0845dea7e6b 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -222,7 +222,7 @@ export class PanelChrome extends PureComponent { } get wantsQueryExecution() { - return this.props.plugin.meta.dataFormats.length > 0 && !this.hasPanelSnapshot; + return !(this.props.plugin.meta.skipDataQuery || this.hasPanelSnapshot); } renderPanel(width: number, height: number): JSX.Element { diff --git a/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx b/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx index c71ebc43577..80440c9631c 100644 --- a/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx +++ b/public/app/features/dashboard/dashgrid/PanelPluginNotFound.tsx @@ -49,7 +49,6 @@ export function getPanelPluginNotFound(id: string): PanelPlugin { type: PluginType.panel, module: '', baseUrl: '', - dataFormats: [], info: { author: { name: '', diff --git a/public/app/features/dashboard/panel_editor/PanelEditor.tsx b/public/app/features/dashboard/panel_editor/PanelEditor.tsx index fd4a7858e2b..152fcda0e05 100644 --- a/public/app/features/dashboard/panel_editor/PanelEditor.tsx +++ b/public/app/features/dashboard/panel_editor/PanelEditor.tsx @@ -105,7 +105,7 @@ export class PanelEditor extends PureComponent { ]; // handle panels that do not have queries tab - if (plugin.meta.dataFormats.length === 0) { + if (!plugin.meta.skipDataQuery) { // remove queries tab tabs.shift(); // switch tab diff --git a/public/app/features/plugins/__mocks__/pluginMocks.ts b/public/app/features/plugins/__mocks__/pluginMocks.ts index 7106af6f071..c03c140a494 100644 --- a/public/app/features/plugins/__mocks__/pluginMocks.ts +++ b/public/app/features/plugins/__mocks__/pluginMocks.ts @@ -1,4 +1,4 @@ -import { PanelPluginMeta, PluginMeta, PluginType, PanelDataFormat, PanelPlugin, PanelProps } from '@grafana/ui'; +import { PanelPluginMeta, PluginMeta, PluginType, PanelPlugin, PanelProps } from '@grafana/ui'; import { ComponentType } from 'enzyme'; export const getMockPlugins = (amount: number): PluginMeta[] => { @@ -46,7 +46,6 @@ export const getPanelPlugin = ( type: PluginType.panel, name: options.id, sort: options.sort || 1, - dataFormats: [PanelDataFormat.TimeSeries], info: { author: { name: options.id + 'name', diff --git a/public/app/plugins/panel/alertlist/plugin.json b/public/app/plugins/panel/alertlist/plugin.json index e1f427b1611..af82f0870e0 100644 --- a/public/app/plugins/panel/alertlist/plugin.json +++ b/public/app/plugins/panel/alertlist/plugin.json @@ -3,7 +3,7 @@ "name": "Alert List", "id": "alertlist", - "dataFormats": [], + "skipDataQuery": true, "info": { "description": "Shows list of alerts and their current status", diff --git a/public/app/plugins/panel/bargauge/plugin.json b/public/app/plugins/panel/bargauge/plugin.json index 607da8c007a..923acfb767a 100644 --- a/public/app/plugins/panel/bargauge/plugin.json +++ b/public/app/plugins/panel/bargauge/plugin.json @@ -4,8 +4,6 @@ "id": "bargauge", "state": "beta", - "dataFormats": ["time_series"], - "info": { "author": { "name": "Grafana Project", diff --git a/public/app/plugins/panel/dashlist/plugin.json b/public/app/plugins/panel/dashlist/plugin.json index 4915722d2ca..622ad6b396d 100644 --- a/public/app/plugins/panel/dashlist/plugin.json +++ b/public/app/plugins/panel/dashlist/plugin.json @@ -3,7 +3,7 @@ "name": "Dashboard list", "id": "dashlist", - "dataFormats": [], + "skipDataQuery": true, "info": { "description": "List of dynamic links to other dashboards", diff --git a/public/app/plugins/panel/gauge/plugin.json b/public/app/plugins/panel/gauge/plugin.json index 6dde42127be..58437779d25 100644 --- a/public/app/plugins/panel/gauge/plugin.json +++ b/public/app/plugins/panel/gauge/plugin.json @@ -3,8 +3,6 @@ "name": "Gauge", "id": "gauge", - "dataFormats": ["time_series"], - "info": { "author": { "name": "Grafana Project", diff --git a/public/app/plugins/panel/graph/plugin.json b/public/app/plugins/panel/graph/plugin.json index 7aed6f972cd..77ae2adb132 100644 --- a/public/app/plugins/panel/graph/plugin.json +++ b/public/app/plugins/panel/graph/plugin.json @@ -3,8 +3,6 @@ "name": "Graph", "id": "graph", - "dataFormats": ["time_series", "table"], - "info": { "description": "Graph Panel for Grafana", "author": { diff --git a/public/app/plugins/panel/heatmap/plugin.json b/public/app/plugins/panel/heatmap/plugin.json index d72f12f4723..7022958560f 100644 --- a/public/app/plugins/panel/heatmap/plugin.json +++ b/public/app/plugins/panel/heatmap/plugin.json @@ -3,8 +3,6 @@ "name": "Heatmap", "id": "heatmap", - "dataFormats": ["time_series"], - "info": { "description": "Heatmap Panel for Grafana", "author": { diff --git a/public/app/plugins/panel/piechart/plugin.json b/public/app/plugins/panel/piechart/plugin.json index cf9ac759653..f7949a76af4 100644 --- a/public/app/plugins/panel/piechart/plugin.json +++ b/public/app/plugins/panel/piechart/plugin.json @@ -4,8 +4,6 @@ "id": "piechart", "state": "alpha", - "dataFormats": ["time_series"], - "info": { "author": { "name": "Grafana Project", diff --git a/public/app/plugins/panel/pluginlist/plugin.json b/public/app/plugins/panel/pluginlist/plugin.json index 95166f57e9e..84369cecd7c 100644 --- a/public/app/plugins/panel/pluginlist/plugin.json +++ b/public/app/plugins/panel/pluginlist/plugin.json @@ -3,7 +3,7 @@ "name": "Plugin list", "id": "pluginlist", - "dataFormats": [], + "skipDataQuery": true, "info": { "description": "Plugin List for Grafana", diff --git a/public/app/plugins/panel/singlestat/plugin.json b/public/app/plugins/panel/singlestat/plugin.json index 3f803a6b270..96def092827 100644 --- a/public/app/plugins/panel/singlestat/plugin.json +++ b/public/app/plugins/panel/singlestat/plugin.json @@ -3,8 +3,6 @@ "name": "Singlestat", "id": "singlestat", - "dataFormats": ["time_series", "table"], - "info": { "description": "Singlestat Panel for Grafana", "author": { diff --git a/public/app/plugins/panel/singlestat2/plugin.json b/public/app/plugins/panel/singlestat2/plugin.json index 6828399ec2b..670bd67643d 100644 --- a/public/app/plugins/panel/singlestat2/plugin.json +++ b/public/app/plugins/panel/singlestat2/plugin.json @@ -4,8 +4,6 @@ "id": "singlestat2", "state": "alpha", - "dataFormats": ["time_series", "table"], - "info": { "description": "Singlestat Panel for Grafana", "author": { diff --git a/public/app/plugins/panel/table/plugin.json b/public/app/plugins/panel/table/plugin.json index 6177a3d2695..2b96af1af48 100644 --- a/public/app/plugins/panel/table/plugin.json +++ b/public/app/plugins/panel/table/plugin.json @@ -3,8 +3,6 @@ "name": "Table", "id": "table", - "dataFormats": ["table", "time_series"], - "info": { "description": "Table Panel for Grafana", "author": { diff --git a/public/app/plugins/panel/table2/plugin.json b/public/app/plugins/panel/table2/plugin.json index 4fa7728bd55..4855b3880f7 100644 --- a/public/app/plugins/panel/table2/plugin.json +++ b/public/app/plugins/panel/table2/plugin.json @@ -4,8 +4,6 @@ "id": "table2", "state": "alpha", - "dataFormats": ["table"], - "info": { "author": { "name": "Grafana Project", diff --git a/public/app/plugins/panel/text/plugin.json b/public/app/plugins/panel/text/plugin.json index e0f03f580e4..3444f92cd42 100644 --- a/public/app/plugins/panel/text/plugin.json +++ b/public/app/plugins/panel/text/plugin.json @@ -3,7 +3,7 @@ "name": "Text", "id": "text", - "dataFormats": [], + "skipDataQuery": true, "info": { "author": { diff --git a/public/app/plugins/panel/text2/plugin.json b/public/app/plugins/panel/text2/plugin.json index 5afecd424d7..ee63a18555b 100644 --- a/public/app/plugins/panel/text2/plugin.json +++ b/public/app/plugins/panel/text2/plugin.json @@ -4,7 +4,7 @@ "id": "text2", "state": "alpha", - "dataFormats": [], + "skipDataQuery": true, "info": { "author": {