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

This commit is contained in:
Ryan McKinley 2019-05-09 22:46:14 -07:00 committed by Torkel Ödegaard
parent 4a9aff0b00
commit 56702902a1
21 changed files with 21 additions and 53 deletions

View File

@ -7,18 +7,9 @@ import { PluginMeta, GrafanaPlugin } from './plugin';
export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string; export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string;
export interface PanelPluginMeta extends PluginMeta { export interface PanelPluginMeta extends PluginMeta {
skipDataQuery?: boolean;
hideFromList?: boolean; hideFromList?: boolean;
sort: number; 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 { export interface PanelData {

View File

@ -1,9 +1,10 @@
package api package api
import ( import (
"github.com/grafana/grafana/pkg/util"
"strconv" "strconv"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/log" "github.com/grafana/grafana/pkg/log"
m "github.com/grafana/grafana/pkg/models" 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{}{ panels[panel.Id] = map[string]interface{}{
"module": panel.Module, "module": panel.Module,
"baseUrl": panel.BaseUrl, "baseUrl": panel.BaseUrl,
"name": panel.Name, "name": panel.Name,
"id": panel.Id, "id": panel.Id,
"info": panel.Info, "info": panel.Info,
"hideFromList": panel.HideFromList, "hideFromList": panel.HideFromList,
"sort": getPanelSort(panel.Id), "sort": getPanelSort(panel.Id),
"dataFormats": panel.DataFormats, "skipDataQuery": panel.SkipDataQuery,
"state": panel.State, "state": panel.State,
} }
} }

View File

@ -4,7 +4,7 @@ import "encoding/json"
type PanelPlugin struct { type PanelPlugin struct {
FrontendPluginBase FrontendPluginBase
DataFormats []string `json:"dataFormats"` SkipDataQuery bool `json:"skipDataQuery"`
} }
func (p *PanelPlugin) Load(decoder *json.Decoder, pluginDir string) error { 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 return err
} }
if p.DataFormats == nil {
p.DataFormats = []string{"time_series", "table"}
}
Panels[p.Id] = p Panels[p.Id] = p
return nil return nil
} }

View File

@ -222,7 +222,7 @@ export class PanelChrome extends PureComponent<Props, State> {
} }
get wantsQueryExecution() { 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 { renderPanel(width: number, height: number): JSX.Element {

View File

@ -49,7 +49,6 @@ export function getPanelPluginNotFound(id: string): PanelPlugin {
type: PluginType.panel, type: PluginType.panel,
module: '', module: '',
baseUrl: '', baseUrl: '',
dataFormats: [],
info: { info: {
author: { author: {
name: '', name: '',

View File

@ -105,7 +105,7 @@ export class PanelEditor extends PureComponent<PanelEditorProps> {
]; ];
// handle panels that do not have queries tab // handle panels that do not have queries tab
if (plugin.meta.dataFormats.length === 0) { if (!plugin.meta.skipDataQuery) {
// remove queries tab // remove queries tab
tabs.shift(); tabs.shift();
// switch tab // switch tab

View File

@ -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'; import { ComponentType } from 'enzyme';
export const getMockPlugins = (amount: number): PluginMeta[] => { export const getMockPlugins = (amount: number): PluginMeta[] => {
@ -46,7 +46,6 @@ export const getPanelPlugin = (
type: PluginType.panel, type: PluginType.panel,
name: options.id, name: options.id,
sort: options.sort || 1, sort: options.sort || 1,
dataFormats: [PanelDataFormat.TimeSeries],
info: { info: {
author: { author: {
name: options.id + 'name', name: options.id + 'name',

View File

@ -3,7 +3,7 @@
"name": "Alert List", "name": "Alert List",
"id": "alertlist", "id": "alertlist",
"dataFormats": [], "skipDataQuery": true,
"info": { "info": {
"description": "Shows list of alerts and their current status", "description": "Shows list of alerts and their current status",

View File

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

View File

@ -3,7 +3,7 @@
"name": "Dashboard list", "name": "Dashboard list",
"id": "dashlist", "id": "dashlist",
"dataFormats": [], "skipDataQuery": true,
"info": { "info": {
"description": "List of dynamic links to other dashboards", "description": "List of dynamic links to other dashboards",

View File

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

View File

@ -3,8 +3,6 @@
"name": "Graph", "name": "Graph",
"id": "graph", "id": "graph",
"dataFormats": ["time_series", "table"],
"info": { "info": {
"description": "Graph Panel for Grafana", "description": "Graph Panel for Grafana",
"author": { "author": {

View File

@ -3,8 +3,6 @@
"name": "Heatmap", "name": "Heatmap",
"id": "heatmap", "id": "heatmap",
"dataFormats": ["time_series"],
"info": { "info": {
"description": "Heatmap Panel for Grafana", "description": "Heatmap Panel for Grafana",
"author": { "author": {

View File

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

View File

@ -3,7 +3,7 @@
"name": "Plugin list", "name": "Plugin list",
"id": "pluginlist", "id": "pluginlist",
"dataFormats": [], "skipDataQuery": true,
"info": { "info": {
"description": "Plugin List for Grafana", "description": "Plugin List for Grafana",

View File

@ -3,8 +3,6 @@
"name": "Singlestat", "name": "Singlestat",
"id": "singlestat", "id": "singlestat",
"dataFormats": ["time_series", "table"],
"info": { "info": {
"description": "Singlestat Panel for Grafana", "description": "Singlestat Panel for Grafana",
"author": { "author": {

View File

@ -4,8 +4,6 @@
"id": "singlestat2", "id": "singlestat2",
"state": "alpha", "state": "alpha",
"dataFormats": ["time_series", "table"],
"info": { "info": {
"description": "Singlestat Panel for Grafana", "description": "Singlestat Panel for Grafana",
"author": { "author": {

View File

@ -3,8 +3,6 @@
"name": "Table", "name": "Table",
"id": "table", "id": "table",
"dataFormats": ["table", "time_series"],
"info": { "info": {
"description": "Table Panel for Grafana", "description": "Table Panel for Grafana",
"author": { "author": {

View File

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

View File

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

View File

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