diff --git a/packages/grafana-data/src/panel/PanelPlugin.ts b/packages/grafana-data/src/panel/PanelPlugin.ts index b33f608dea0..c04898baf6a 100644 --- a/packages/grafana-data/src/panel/PanelPlugin.ts +++ b/packages/grafana-data/src/panel/PanelPlugin.ts @@ -8,6 +8,7 @@ import { PanelProps, PanelTypeChangedHandler, FieldConfigProperty, + PanelPluginDataSupport, } from '../types'; import { FieldConfigEditorBuilder, PanelOptionsEditorBuilder } from '../utils/OptionsUIBuilders'; import { ComponentClass, ComponentType } from 'react'; @@ -106,6 +107,10 @@ export class PanelPlugin< onPanelMigration?: PanelMigrationHandler; onPanelTypeChanged?: PanelTypeChangedHandler; noPadding?: boolean; + dataSupport: PanelPluginDataSupport = { + annotations: false, + alertStates: false, + }; /** * Legacy angular ctrl. If this exists it will be used instead of the panel @@ -259,6 +264,33 @@ export class PanelPlugin< return this; } + /** + * Tells Grafana if the plugin should subscribe to annotation and alertState results. + * + * @example + * ```typescript + * + * import { ShapePanel } from './ShapePanel'; + * + * interface ShapePanelOptions {} + * + * export const plugin = new PanelPlugin(ShapePanel) + * .useFieldConfig({}) + * ... + * ... + * .setDataSupport({ + * annotations: true, + * alertStates: true, + * }); + * ``` + * + * @public + **/ + setDataSupport(support: Partial) { + this.dataSupport = { ...this.dataSupport, ...support }; + return this; + } + /** * Allows specifying which standard field config options panel should use and defining default values * diff --git a/packages/grafana-data/src/types/panel.ts b/packages/grafana-data/src/types/panel.ts index 9db57f751b1..b23fd46e159 100644 --- a/packages/grafana-data/src/types/panel.ts +++ b/packages/grafana-data/src/types/panel.ts @@ -182,3 +182,8 @@ export enum VizOrientation { Vertical = 'vertical', Horizontal = 'horizontal', } + +export interface PanelPluginDataSupport { + annotations: boolean; + alertStates: boolean; +}