mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 20:24:18 -06:00
Merge pull request #15515 from grafana/13767_fix
fix native annotation filtered by template variable with pipe
This commit is contained in:
commit
baddf42c8e
@ -57,10 +57,17 @@ class GrafanaDatasource {
|
||||
if (!_.isArray(options.annotation.tags) || options.annotation.tags.length === 0) {
|
||||
return this.$q.when([]);
|
||||
}
|
||||
const delimiter = '__delimiter__';
|
||||
const tags = [];
|
||||
for (const t of params.tags) {
|
||||
const renderedValues = this.templateSrv.replace(t, {}, 'pipe');
|
||||
for (const tt of renderedValues.split('|')) {
|
||||
const renderedValues = this.templateSrv.replace(t, {}, value => {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
|
||||
return value.join(delimiter);
|
||||
});
|
||||
for (const tt of renderedValues.split(delimiter)) {
|
||||
tags.push(tt);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ describe('grafana data source', () => {
|
||||
|
||||
const templateSrvStub = {
|
||||
replace: val => {
|
||||
return val.replace('$var2', 'replaced|replaced2').replace('$var', 'replaced');
|
||||
return val.replace('$var2', 'replaced__delimiter__replaced2').replace('$var', 'replaced');
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user