Commit 67c55319 by Ryan McKinley Committed by Dominik Prokop

grafana/data: Add type for secure json in DataSourceAPI (#21772)

parent c3a19c6d
...@@ -33,15 +33,16 @@ export type DataSourceOptionsType<DSType extends DataSourceApi<any, any>> = DSTy ...@@ -33,15 +33,16 @@ export type DataSourceOptionsType<DSType extends DataSourceApi<any, any>> = DSTy
export class DataSourcePlugin< export class DataSourcePlugin<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>, TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType> TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>,
TSecureOptions = {}
> extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> { > extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> {
components: DataSourcePluginComponents<DSType, TQuery, TOptions> = {}; components: DataSourcePluginComponents<DSType, TQuery, TOptions, TSecureOptions> = {};
constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) { constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) {
super(); super();
} }
setConfigEditor(editor: ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>) { setConfigEditor(editor: ComponentType<DataSourcePluginOptionsEditorProps<TOptions, TSecureOptions>>) {
this.components.ConfigEditor = editor; this.components.ConfigEditor = editor;
return this; return this;
} }
...@@ -131,7 +132,8 @@ interface PluginMetaQueryOptions { ...@@ -131,7 +132,8 @@ interface PluginMetaQueryOptions {
export interface DataSourcePluginComponents< export interface DataSourcePluginComponents<
DSType extends DataSourceApi<TQuery, TOptions>, DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery, TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData TOptions extends DataSourceJsonData = DataSourceJsonData,
TSecureOptions = {}
> { > {
QueryCtrl?: any; QueryCtrl?: any;
AnnotationsQueryCtrl?: any; AnnotationsQueryCtrl?: any;
...@@ -141,7 +143,7 @@ export interface DataSourcePluginComponents< ...@@ -141,7 +143,7 @@ export interface DataSourcePluginComponents<
ExploreMetricsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>; ExploreMetricsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreLogsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>; ExploreLogsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreStartPage?: ComponentType<ExploreStartPageProps>; ExploreStartPage?: ComponentType<ExploreStartPageProps>;
ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>; ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<TOptions, TSecureOptions>>;
MetadataInspector?: ComponentType<MetadataInspectorProps<DSType, TQuery, TOptions>>; MetadataInspector?: ComponentType<MetadataInspectorProps<DSType, TQuery, TOptions>>;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment