AdhocFilters: Improve typing and signature of getTagKeys and getTagValues and behaviors (#74962)

* Add adhocFilters to DataQueryRequest

* More changes

* Progress

* Working

* added baseFilters to picker

* Remove unused code

* minor fix
This commit is contained in:
Torkel Ödegaard
2023-09-19 08:24:45 +02:00
committed by GitHub
parent 695c1a08f3
commit 1105b93104
15 changed files with 174 additions and 92 deletions

View File

@@ -14,7 +14,7 @@ import { DataQuery } from './query';
import { RawTimeRange, TimeRange } from './time';
import { CustomVariableSupport, DataSourceVariableSupport, StandardVariableSupport } from './variables';
import { DataSourceRef, WithAccessControlMetadata } from '.';
import { AdHocVariableFilter, DataSourceRef, WithAccessControlMetadata } from '.';
export interface DataSourcePluginOptionsEditorProps<
JSONData extends DataSourceJsonData = DataSourceJsonData,
@@ -287,12 +287,12 @@ abstract class DataSourceApi<
/**
* Get tag keys for adhoc filters
*/
getTagKeys?(options?: any): Promise<MetricFindValue[]>;
getTagKeys?(options?: DataSourceGetTagKeysOptions): Promise<MetricFindValue[]>;
/**
* Get tag values for adhoc filters
*/
getTagValues?(options: any): Promise<MetricFindValue[]>;
getTagValues?(options: DataSourceGetTagValuesOptions): Promise<MetricFindValue[]>;
/**
* Set after constructor call, as the data source instance is the most common thing to pass around
@@ -370,6 +370,35 @@ abstract class DataSourceApi<
getDefaultQuery?(app: CoreApp): Partial<TQuery>;
}
/**
* Options argument to DataSourceAPI.getTagKeys
*/
export interface DataSourceGetTagKeysOptions {
/**
* The other existing filters or base filters. New in v10.3
*/
filters: AdHocVariableFilter[];
/**
* Context time range. New in v10.3
*/
timeRange?: TimeRange;
}
/**
* Options argument to DataSourceAPI.getTagValues
*/
export interface DataSourceGetTagValuesOptions {
key: string;
/**
* The other existing filters or base filters. New in v10.3
*/
filters: AdHocVariableFilter[];
/**
* Context time range. New in v10.3
*/
timeRange?: TimeRange;
}
export interface MetadataInspectorProps<
DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery,

View File

@@ -55,6 +55,10 @@ export interface AdHocVariableModel extends BaseVariableModel {
type: 'adhoc';
datasource: DataSourceRef | null;
filters: AdHocVariableFilter[];
/**
* Filters that are always applied to the lookup of keys. Not shown in the AdhocFilterBuilder UI.
*/
baseFilters?: AdHocVariableFilter[];
}
export interface VariableOption {