mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Fixes issue with adhoc filters when coming from dashboards (#78339)
This commit is contained in:
@@ -3,6 +3,7 @@ import { Unsubscribable } from 'rxjs';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import {
|
||||
AdHocVariableFilter,
|
||||
CoreApp,
|
||||
DataQuery,
|
||||
DataQueryRequest,
|
||||
@@ -49,6 +50,7 @@ export interface GetExploreUrlArguments {
|
||||
dsRef: DataSourceRef | null | undefined;
|
||||
timeRange: TimeRange;
|
||||
scopedVars: ScopedVars | undefined;
|
||||
adhocFilters?: AdHocVariableFilter[];
|
||||
}
|
||||
|
||||
export function generateExploreId() {
|
||||
@@ -59,7 +61,7 @@ export function generateExploreId() {
|
||||
* Returns an Explore-URL that contains a panel's queries and the dashboard time range.
|
||||
*/
|
||||
export async function getExploreUrl(args: GetExploreUrlArguments): Promise<string | undefined> {
|
||||
const { queries, dsRef, timeRange, scopedVars } = args;
|
||||
const { queries, dsRef, timeRange, scopedVars, adhocFilters } = args;
|
||||
const interpolatedQueries = (
|
||||
await Promise.allSettled(
|
||||
queries
|
||||
@@ -72,7 +74,7 @@ export async function getExploreUrl(args: GetExploreUrlArguments): Promise<strin
|
||||
|
||||
return {
|
||||
// interpolate the query using its datasource `interpolateVariablesInQueries` method if defined, othewise return the query as-is.
|
||||
...(queryDs.interpolateVariablesInQueries?.([q], scopedVars ?? {})[0] || q),
|
||||
...(queryDs.interpolateVariablesInQueries?.([q], scopedVars ?? {}, adhocFilters)[0] || q),
|
||||
// But always set the datasource as it's required in Explore.
|
||||
// NOTE: if for some reason the query has the "mixed" datasource, we omit the property;
|
||||
// Upon initialization, Explore use its own logic to determine the datasource.
|
||||
|
||||
Reference in New Issue
Block a user