mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Feature: Enable React based options editors for Datasource plugins (#16748)
This commit is contained in:
@@ -4,15 +4,24 @@ import { PluginMeta } from './plugin';
|
||||
import { TableData, TimeSeries, SeriesData } from './data';
|
||||
import { PanelData } from './panel';
|
||||
|
||||
export class DataSourcePlugin<TQuery extends DataQuery = DataQuery> {
|
||||
export interface DataSourcePluginOptionsEditorProps<TOptions> {
|
||||
options: TOptions;
|
||||
onOptionsChange: (options: TOptions) => void;
|
||||
}
|
||||
export class DataSourcePlugin<TOptions = {}, TQuery extends DataQuery = DataQuery> {
|
||||
DataSourceClass: DataSourceConstructor<TQuery>;
|
||||
components: DataSourcePluginComponents<TQuery>;
|
||||
components: DataSourcePluginComponents<TOptions, TQuery>;
|
||||
|
||||
constructor(DataSourceClass: DataSourceConstructor<TQuery>) {
|
||||
this.DataSourceClass = DataSourceClass;
|
||||
this.components = {};
|
||||
}
|
||||
|
||||
setConfigEditor(editor: React.ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>) {
|
||||
this.components.ConfigEditor = editor;
|
||||
return this;
|
||||
}
|
||||
|
||||
setConfigCtrl(ConfigCtrl: any) {
|
||||
this.components.ConfigCtrl = ConfigCtrl;
|
||||
return this;
|
||||
@@ -59,7 +68,7 @@ export class DataSourcePlugin<TQuery extends DataQuery = DataQuery> {
|
||||
}
|
||||
}
|
||||
|
||||
export interface DataSourcePluginComponents<TQuery extends DataQuery = DataQuery> {
|
||||
export interface DataSourcePluginComponents<TOptions = {}, TQuery extends DataQuery = DataQuery> {
|
||||
QueryCtrl?: any;
|
||||
ConfigCtrl?: any;
|
||||
AnnotationsQueryCtrl?: any;
|
||||
@@ -67,9 +76,10 @@ export interface DataSourcePluginComponents<TQuery extends DataQuery = DataQuery
|
||||
QueryEditor?: ComponentClass<QueryEditorProps<DataSourceApi, TQuery>>;
|
||||
ExploreQueryField?: ComponentClass<ExploreQueryFieldProps<DataSourceApi, TQuery>>;
|
||||
ExploreStartPage?: ComponentClass<ExploreStartPageProps>;
|
||||
ConfigEditor?: React.ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>;
|
||||
}
|
||||
|
||||
interface DataSourceConstructor<TQuery extends DataQuery = DataQuery> {
|
||||
export interface DataSourceConstructor<TQuery extends DataQuery = DataQuery> {
|
||||
new (instanceSettings: DataSourceInstanceSettings, ...args: any[]): DataSourceApi<TQuery>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user