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

This commit is contained in:
Ryan McKinley 2020-01-27 22:13:20 -08:00 committed by Dominik Prokop
parent c3a19c6d98
commit 67c5531961

View File

@ -33,15 +33,16 @@ export type DataSourceOptionsType<DSType extends DataSourceApi<any, any>> = DSTy
export class DataSourcePlugin<
DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataSourceQueryType<DSType>,
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>
TOptions extends DataSourceJsonData = DataSourceOptionsType<DSType>,
TSecureOptions = {}
> extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> {
components: DataSourcePluginComponents<DSType, TQuery, TOptions> = {};
components: DataSourcePluginComponents<DSType, TQuery, TOptions, TSecureOptions> = {};
constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) {
super();
}
setConfigEditor(editor: ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>) {
setConfigEditor(editor: ComponentType<DataSourcePluginOptionsEditorProps<TOptions, TSecureOptions>>) {
this.components.ConfigEditor = editor;
return this;
}
@ -131,7 +132,8 @@ interface PluginMetaQueryOptions {
export interface DataSourcePluginComponents<
DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery,
TOptions extends DataSourceJsonData = DataSourceJsonData
TOptions extends DataSourceJsonData = DataSourceJsonData,
TSecureOptions = {}
> {
QueryCtrl?: any;
AnnotationsQueryCtrl?: any;
@ -141,7 +143,7 @@ export interface DataSourcePluginComponents<
ExploreMetricsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreLogsQueryField?: ComponentType<ExploreQueryFieldProps<DSType, TQuery, TOptions>>;
ExploreStartPage?: ComponentType<ExploreStartPageProps>;
ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<TOptions>>;
ConfigEditor?: ComponentType<DataSourcePluginOptionsEditorProps<TOptions, TSecureOptions>>;
MetadataInspector?: ComponentType<MetadataInspectorProps<DSType, TQuery, TOptions>>;
}