mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Templating: Allow percent encoding of variable with custom all (#65266)
* Templating: Allow percent encoding of variable with custom all * Test fix
This commit is contained in:
parent
3cfb7ac0dd
commit
2d7965402e
@ -309,6 +309,25 @@ describe('templateSrv', () => {
|
||||
const target = _templateSrv.replace('${test:queryparam}', {});
|
||||
expect(target).toBe('var-test=All');
|
||||
});
|
||||
|
||||
describe('percentencode option', () => {
|
||||
beforeEach(() => {
|
||||
_templateSrv = initTemplateSrv(key, [
|
||||
{
|
||||
type: 'query',
|
||||
name: 'test',
|
||||
current: { value: '$__all' },
|
||||
allValue: '.+',
|
||||
options: [{ value: 'value1' }, { value: 'value2' }],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should respect percentencode format', () => {
|
||||
const target = _templateSrv.replace('this.${test:percentencode}', {}, 'regex');
|
||||
expect(target).toBe('this..%2B');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('lucene format', () => {
|
||||
|
@ -332,8 +332,8 @@ export class TemplateSrv implements BaseTemplateSrv {
|
||||
if (this.isAllValue(value)) {
|
||||
value = this.getAllValue(variable);
|
||||
text = ALL_VARIABLE_TEXT;
|
||||
// skip formatting of custom all values
|
||||
if (variable.allValue && fmt !== FormatRegistryID.text) {
|
||||
// skip formatting of custom all values unless format set to text or percentencode
|
||||
if (variable.allValue && fmt !== FormatRegistryID.text && fmt !== FormatRegistryID.percentEncode) {
|
||||
return this.replace(value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user