Commit 7146d576 by Ryan McKinley Committed by GitHub

Plugins: move datasource specific meta out of the main meta type (#16803)

parent 945cbf47
...@@ -68,6 +68,24 @@ export class DataSourcePlugin<TOptions = {}, TQuery extends DataQuery = DataQuer ...@@ -68,6 +68,24 @@ export class DataSourcePlugin<TOptions = {}, TQuery extends DataQuery = DataQuer
} }
} }
export interface DataSourcePluginMeta extends PluginMeta {
builtIn?: boolean; // Is this for all
metrics?: boolean;
tables?: boolean;
logs?: boolean;
explore?: boolean;
annotations?: boolean;
mixed?: boolean;
hasQueryHelp?: boolean;
queryOptions?: PluginMetaQueryOptions;
}
interface PluginMetaQueryOptions {
cacheTimeout?: boolean;
maxDataPoints?: boolean;
minInterval?: boolean;
}
export interface DataSourcePluginComponents<TOptions = {}, TQuery extends DataQuery = DataQuery> { export interface DataSourcePluginComponents<TOptions = {}, TQuery extends DataQuery = DataQuery> {
QueryCtrl?: any; QueryCtrl?: any;
ConfigCtrl?: any; ConfigCtrl?: any;
...@@ -137,7 +155,11 @@ export interface DataSourceApi<TQuery extends DataQuery = DataQuery> { ...@@ -137,7 +155,11 @@ export interface DataSourceApi<TQuery extends DataQuery = DataQuery> {
* we attach the components to this instance for easy access * we attach the components to this instance for easy access
*/ */
components?: DataSourcePluginComponents; components?: DataSourcePluginComponents;
meta?: PluginMeta;
/**
* static information about the datasource
*/
meta?: DataSourcePluginMeta;
} }
export interface ExploreDataSourceApi<TQuery extends DataQuery = DataQuery> extends DataSourceApi { export interface ExploreDataSourceApi<TQuery extends DataQuery = DataQuery> extends DataSourceApi {
...@@ -340,7 +362,7 @@ export interface DataSourceInstanceSettings { ...@@ -340,7 +362,7 @@ export interface DataSourceInstanceSettings {
id: number; id: number;
type: string; type: string;
name: string; name: string;
meta: PluginMeta; meta: DataSourcePluginMeta;
url?: string; url?: string;
jsonData: { [str: string]: any }; jsonData: { [str: string]: any };
username?: string; username?: string;
...@@ -359,6 +381,6 @@ export interface DataSourceInstanceSettings { ...@@ -359,6 +381,6 @@ export interface DataSourceInstanceSettings {
export interface DataSourceSelectItem { export interface DataSourceSelectItem {
name: string; name: string;
value: string | null; value: string | null;
meta: PluginMeta; meta: DataSourcePluginMeta;
sort: string; sort: string;
} }
...@@ -24,23 +24,6 @@ export interface PluginMeta { ...@@ -24,23 +24,6 @@ export interface PluginMeta {
// Filled in by the backend // Filled in by the backend
jsonData?: { [str: string]: any }; jsonData?: { [str: string]: any };
enabled?: boolean; enabled?: boolean;
// Datasource-specific
builtIn?: boolean;
metrics?: boolean;
tables?: boolean;
logs?: boolean;
explore?: boolean;
annotations?: boolean;
mixed?: boolean;
hasQueryHelp?: boolean;
queryOptions?: PluginMetaQueryOptions;
}
interface PluginMetaQueryOptions {
cacheTimeout?: boolean;
maxDataPoints?: boolean;
minInterval?: boolean;
} }
export enum PluginIncludeType { export enum PluginIncludeType {
......
import config from 'app/core/config'; import config from 'app/core/config';
import 'app/features/plugins/datasource_srv'; import 'app/features/plugins/datasource_srv';
import { DatasourceSrv } from 'app/features/plugins/datasource_srv'; import { DatasourceSrv } from 'app/features/plugins/datasource_srv';
import { PluginMeta } from '@grafana/ui/src/types'; import { PluginMeta, DataSourcePluginMeta } from '@grafana/ui/src/types';
// Datasource variable $datasource with current value 'BBB' // Datasource variable $datasource with current value 'BBB'
const templateSrv = { const templateSrv = {
...@@ -26,14 +26,14 @@ describe('datasource_srv', () => { ...@@ -26,14 +26,14 @@ describe('datasource_srv', () => {
id: 1, id: 1,
type: 'b', type: 'b',
name: 'buildIn', name: 'buildIn',
meta: { builtIn: true } as PluginMeta, meta: { builtIn: true } as DataSourcePluginMeta,
jsonData: {}, jsonData: {},
}, },
nonBuildIn: { nonBuildIn: {
id: 2, id: 2,
type: 'e', type: 'e',
name: 'external1', name: 'external1',
meta: { builtIn: false } as PluginMeta, meta: { builtIn: false } as DataSourcePluginMeta,
jsonData: {}, jsonData: {},
}, },
nonExplore: { nonExplore: {
......
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