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(
|
interpolatedFilters.push(
|
||||||
...filters.map((filter) => {
|
...filters.map((filter) => {
|
||||||
if (filter.config.id === ValueMatcherID.between) {
|
if (filter.config.id === ValueMatcherID.between) {
|
||||||
const interpolatedFrom = ctx.interpolate(filter.config.options.from);
|
if (typeof filter.config.options.from === 'string') {
|
||||||
const interpolatedTo = ctx.interpolate(filter.config.options.to);
|
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 = {
|
const newFilter = {
|
||||||
...filter,
|
...filter,
|
||||||
@ -65,8 +69,8 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
|||||||
...filter.config,
|
...filter.config,
|
||||||
options: {
|
options: {
|
||||||
...filter.config.options,
|
...filter.config.options,
|
||||||
to: interpolatedTo,
|
to: filter.config.options.to,
|
||||||
from: interpolatedFrom,
|
from: filter.config.options.from,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -76,12 +80,14 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
|||||||
// Due to colliding syntaxes, interpolating regex filters will cause issues.
|
// Due to colliding syntaxes, interpolating regex filters will cause issues.
|
||||||
return filter;
|
return filter;
|
||||||
} else if (filter.config.options.value) {
|
} 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 = {
|
const newFilter = {
|
||||||
...filter,
|
...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;
|
return newFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user