DashboardQueryRunner: Add dataSupport to PanelModel & PanelPlugin (#33253)

* DashboardQueryRunner: Add dataSupport to PanelModel & PanelPlugin
Relates to #32834
This commit is contained in:
kay delaney 2021-04-22 11:56:32 +01:00 committed by GitHub
parent dd9f701cd9
commit 57e9b11fda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -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<TOptions>;
onPanelTypeChanged?: PanelTypeChangedHandler<TOptions>;
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<ShapePanelOptions>(ShapePanel)
* .useFieldConfig({})
* ...
* ...
* .setDataSupport({
* annotations: true,
* alertStates: true,
* });
* ```
*
* @public
**/
setDataSupport(support: Partial<PanelPluginDataSupport>) {
this.dataSupport = { ...this.dataSupport, ...support };
return this;
}
/**
* Allows specifying which standard field config options panel should use and defining default values
*

View File

@ -182,3 +182,8 @@ export enum VizOrientation {
Vertical = 'vertical',
Horizontal = 'horizontal',
}
export interface PanelPluginDataSupport {
annotations: boolean;
alertStates: boolean;
}