Commit 3f957a37 by Dominik Prokop Committed by GitHub

grafana/data: Update plugin config page typings (BREAKING) (#21503)

* Change typyings of plugins config pages

* Update plugin config page types of core plugins
parent dce4d184
...@@ -34,7 +34,7 @@ export class DataSourcePlugin< ...@@ -34,7 +34,7 @@ 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>
> extends GrafanaPlugin<DataSourcePluginMeta> { > extends GrafanaPlugin<DataSourcePluginMeta<TOptions>> {
components: DataSourcePluginComponents<DSType, TQuery, TOptions> = {}; components: DataSourcePluginComponents<DSType, TQuery, TOptions> = {};
constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) { constructor(public DataSourceClass: DataSourceConstructor<DSType, TQuery, TOptions>) {
...@@ -108,7 +108,7 @@ export class DataSourcePlugin< ...@@ -108,7 +108,7 @@ export class DataSourcePlugin<
} }
} }
export interface DataSourcePluginMeta extends PluginMeta { export interface DataSourcePluginMeta<T extends KeyValue = {}> extends PluginMeta<T> {
builtIn?: boolean; // Is this for all builtIn?: boolean; // Is this for all
metrics?: boolean; metrics?: boolean;
logs?: boolean; logs?: boolean;
......
...@@ -13,7 +13,7 @@ export enum PluginType { ...@@ -13,7 +13,7 @@ export enum PluginType {
renderer = 'renderer', renderer = 'renderer',
} }
export interface PluginMeta<T extends {} = KeyValue> { export interface PluginMeta<T extends KeyValue = {}> {
id: string; id: string;
name: string; name: string;
type: PluginType; type: PluginType;
...@@ -108,12 +108,12 @@ export interface PluginMetaInfo { ...@@ -108,12 +108,12 @@ export interface PluginMetaInfo {
version: string; version: string;
} }
export interface PluginConfigPageProps<T extends GrafanaPlugin> { export interface PluginConfigPageProps<T extends PluginMeta> {
plugin: T; plugin: GrafanaPlugin<T>;
query: KeyValue; // The URL query parameters query: KeyValue; // The URL query parameters
} }
export interface PluginConfigPage<T extends GrafanaPlugin> { export interface PluginConfigPage<T extends PluginMeta> {
title: string; // Display title: string; // Display
icon?: string; icon?: string;
id: string; // Unique, in URL id: string; // Unique, in URL
...@@ -132,10 +132,10 @@ export class GrafanaPlugin<T extends PluginMeta = PluginMeta> { ...@@ -132,10 +132,10 @@ export class GrafanaPlugin<T extends PluginMeta = PluginMeta> {
angularConfigCtrl?: any; angularConfigCtrl?: any;
// Show configuration tabs on the plugin page // Show configuration tabs on the plugin page
configPages?: Array<PluginConfigPage<GrafanaPlugin>>; configPages?: Array<PluginConfigPage<T>>;
// Tabs on the plugin page // Tabs on the plugin page
addConfigPage(tab: PluginConfigPage<GrafanaPlugin>) { addConfigPage(tab: PluginConfigPage<T>) {
if (!this.configPages) { if (!this.configPages) {
this.configPages = []; this.configPages = [];
} }
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
// Types // Types
import { PluginConfigPageProps, AppPlugin } from '@grafana/data'; import { PluginConfigPageProps, AppPluginMeta } from '@grafana/data';
import { ExampleAppSettings } from '../types';
interface Props extends PluginConfigPageProps<AppPlugin> {} interface Props extends PluginConfigPageProps<AppPluginMeta<ExampleAppSettings>> {}
export class ExamplePage1 extends PureComponent<Props> { export class ExamplePage1 extends PureComponent<Props> {
constructor(props: Props) { constructor(props: Props) {
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
// Types // Types
import { PluginConfigPageProps, AppPlugin } from '@grafana/data'; import { PluginConfigPageProps, AppPluginMeta } from '@grafana/data';
import { ExampleAppSettings } from '../types';
interface Props extends PluginConfigPageProps<AppPlugin> {} interface Props extends PluginConfigPageProps<AppPluginMeta<ExampleAppSettings>> {}
export class ExamplePage2 extends PureComponent<Props> { export class ExamplePage2 extends PureComponent<Props> {
constructor(props: Props) { constructor(props: Props) {
......
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
// Types // Types
import { PluginConfigPageProps, DataSourcePlugin } from '@grafana/data'; import { PluginConfigPageProps, DataSourcePluginMeta, DataSourceJsonData } from '@grafana/data';
import { TestDataDataSource } from './datasource';
interface Props extends PluginConfigPageProps<DataSourcePlugin<TestDataDataSource>> {} interface Props extends PluginConfigPageProps<DataSourcePluginMeta<DataSourceJsonData>> {}
export class TestInfoTab extends PureComponent<Props> { export class TestInfoTab extends PureComponent<Props> {
constructor(props: Props) { constructor(props: Props) {
......
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