mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Transformations: Fix filter by value error on interpolation (#89418)
* string check before interpolation * refactor
This commit is contained in:
parent
fa3679d29b
commit
13e16a4142
@ -56,8 +56,12 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
||||
interpolatedFilters.push(
|
||||
...filters.map((filter) => {
|
||||
if (filter.config.id === ValueMatcherID.between) {
|
||||
const interpolatedFrom = ctx.interpolate(filter.config.options.from);
|
||||
const interpolatedTo = ctx.interpolate(filter.config.options.to);
|
||||
if (typeof filter.config.options.from === 'string') {
|
||||
filter.config.options.from = ctx.interpolate(filter.config.options.from);
|
||||
}
|
||||
if (typeof filter.config.options.to === 'string') {
|
||||
filter.config.options.to = ctx.interpolate(filter.config.options.to);
|
||||
}
|
||||
|
||||
const newFilter = {
|
||||
...filter,
|
||||
@ -65,8 +69,8 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
||||
...filter.config,
|
||||
options: {
|
||||
...filter.config.options,
|
||||
to: interpolatedTo,
|
||||
from: interpolatedFrom,
|
||||
to: filter.config.options.to,
|
||||
from: filter.config.options.from,
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -76,12 +80,14 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
||||
// Due to colliding syntaxes, interpolating regex filters will cause issues.
|
||||
return filter;
|
||||
} else if (filter.config.options.value) {
|
||||
const interpolatedValue = ctx.interpolate(filter.config.options.value);
|
||||
if (typeof filter.config.options.value === 'string') {
|
||||
filter.config.options.value = ctx.interpolate(filter.config.options.value);
|
||||
}
|
||||
|
||||
const newFilter = {
|
||||
...filter,
|
||||
config: { ...filter.config, options: { ...filter.config.options, value: interpolatedValue } },
|
||||
config: { ...filter.config, options: { ...filter.config.options, value: filter.config.options.value } },
|
||||
};
|
||||
newFilter.config.options.value! = interpolatedValue;
|
||||
return newFilter;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user