mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* Add onDataSourceChange to optional components - Fixes a bug where the user can select twice and overwrite all queries - Adds handler to control main datasoruce selection to the optional components. * only pass onDatasource change when necessary
35 lines
937 B
TypeScript
35 lines
937 B
TypeScript
import { DataQuery, DataSourceInstanceSettings, TimeRange } from '@grafana/data';
|
|
|
|
interface ActionComponentProps {
|
|
query?: DataQuery;
|
|
queries?: Array<Partial<DataQuery>>;
|
|
onAddQuery?: (q: DataQuery) => void;
|
|
onChangeDataSource?: (ds: DataSourceInstanceSettings) => void;
|
|
timeRange?: TimeRange;
|
|
dataSource?: DataSourceInstanceSettings;
|
|
}
|
|
|
|
type QueryActionComponent = React.ComponentType<ActionComponentProps>;
|
|
|
|
class QueryActionComponents {
|
|
extraRenderActions: QueryActionComponent[] = [];
|
|
|
|
addExtraRenderAction(extra: QueryActionComponent) {
|
|
this.extraRenderActions = this.extraRenderActions.concat(extra);
|
|
}
|
|
|
|
getAllExtraRenderAction(): QueryActionComponent[] {
|
|
return this.extraRenderActions;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @internal and experimental
|
|
*/
|
|
export const GroupActionComponents = new QueryActionComponents();
|
|
|
|
/**
|
|
* @internal and experimental
|
|
*/
|
|
export const RowActionComponents = new QueryActionComponents();
|