瀏覽代碼

Plugins: Remove dataFormats key and add skipDataQuery (#16984)

Ryan McKinley 6 年之前
父節點
當前提交
56702902a1

+ 1 - 10
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 {

+ 11 - 10
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,
 		}
 	}
 

+ 1 - 5
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
 }

+ 1 - 1
public/app/features/dashboard/dashgrid/PanelChrome.tsx

@@ -222,7 +222,7 @@ export class PanelChrome extends PureComponent<Props, State> {
   }
 
   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 {

+ 0 - 1
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: '',

+ 1 - 1
public/app/features/dashboard/panel_editor/PanelEditor.tsx

@@ -105,7 +105,7 @@ export class PanelEditor extends PureComponent<PanelEditorProps> {
     ];
 
     // 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

+ 1 - 2
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',

+ 1 - 1
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",

+ 0 - 2
public/app/plugins/panel/bargauge/plugin.json

@@ -4,8 +4,6 @@
   "id": "bargauge",
   "state": "beta",
 
-  "dataFormats": ["time_series"],
-
   "info": {
     "author": {
       "name": "Grafana Project",

+ 1 - 1
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",

+ 0 - 2
public/app/plugins/panel/gauge/plugin.json

@@ -3,8 +3,6 @@
   "name": "Gauge",
   "id": "gauge",
 
-  "dataFormats": ["time_series"],
-
   "info": {
     "author": {
       "name": "Grafana Project",

+ 0 - 2
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": {

+ 0 - 2
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": {

+ 0 - 2
public/app/plugins/panel/piechart/plugin.json

@@ -4,8 +4,6 @@
   "id": "piechart",
   "state": "alpha",
 
-  "dataFormats": ["time_series"],
-
   "info": {
     "author": {
       "name": "Grafana Project",

+ 1 - 1
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",

+ 0 - 2
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": {

+ 0 - 2
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": {

+ 0 - 2
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": {

+ 0 - 2
public/app/plugins/panel/table2/plugin.json

@@ -4,8 +4,6 @@
   "id": "table2",
   "state": "alpha",
 
-  "dataFormats": ["table"],
-
   "info": {
     "author": {
       "name": "Grafana Project",

+ 1 - 1
public/app/plugins/panel/text/plugin.json

@@ -3,7 +3,7 @@
   "name": "Text",
   "id": "text",
 
-  "dataFormats": [],
+  "skipDataQuery": true,
 
   "info": {
     "author": {

+ 1 - 1
public/app/plugins/panel/text2/plugin.json

@@ -4,7 +4,7 @@
   "id": "text2",
   "state": "alpha",
 
-  "dataFormats": [],
+  "skipDataQuery": true,
 
   "info": {
     "author": {