mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Do not quote variables when a custom All variable option is used (#49428)
This commit is contained in:
parent
71ffa5e5db
commit
b0300d56ac
@ -81,5 +81,15 @@ describe('When interpolating variables', () => {
|
|||||||
const variable = { ...initialCustomVariableModelState, includeAll: true };
|
const variable = { ...initialCustomVariableModelState, includeAll: true };
|
||||||
expect(interpolateVariable('abc', variable)).toEqual("'abc'");
|
expect(interpolateVariable('abc', variable)).toEqual("'abc'");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not return a quoted value if the all value is modified', () => {
|
||||||
|
const variable = { ...initialCustomVariableModelState, includeAll: true, allValue: 'All' };
|
||||||
|
expect(interpolateVariable('abc', variable)).toEqual('abc');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return a quoted value if multi is selected even if the allValue is set', () => {
|
||||||
|
const variable = { ...initialCustomVariableModelState, includeAll: true, multi: true, allValue: 'All' };
|
||||||
|
expect(interpolateVariable('abc', variable)).toEqual("'abc'");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { map } from 'lodash';
|
import { map } from 'lodash';
|
||||||
|
|
||||||
import { rangeUtil } from '@grafana/data';
|
import { rangeUtil } from '@grafana/data';
|
||||||
|
import { VariableWithMultiSupport } from 'app/features/variables/types';
|
||||||
|
|
||||||
import TimegrainConverter from '../time_grain_converter';
|
import TimegrainConverter from '../time_grain_converter';
|
||||||
import { AzureMonitorOption } from '../types';
|
import { AzureMonitorOption } from '../types';
|
||||||
@ -40,9 +41,12 @@ export const routeNames = {
|
|||||||
resourceGraph: 'resourcegraph',
|
resourceGraph: 'resourcegraph',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function interpolateVariable(value: any, variable: { multi: any; includeAll: any }) {
|
export function interpolateVariable(value: any, variable: VariableWithMultiSupport) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
if (variable.multi || variable.includeAll) {
|
// When enabling multiple responses, quote the value to mimic the array result below
|
||||||
|
// even if only one response is selected. This does not apply if only the "include all"
|
||||||
|
// option is enabled but with a custom value.
|
||||||
|
if (variable.multi || (variable.includeAll && !variable.allValue)) {
|
||||||
return "'" + value + "'";
|
return "'" + value + "'";
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
|
Loading…
Reference in New Issue
Block a user