mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -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 };
|
||||
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 { rangeUtil } from '@grafana/data';
|
||||
import { VariableWithMultiSupport } from 'app/features/variables/types';
|
||||
|
||||
import TimegrainConverter from '../time_grain_converter';
|
||||
import { AzureMonitorOption } from '../types';
|
||||
@ -40,9 +41,12 @@ export const routeNames = {
|
||||
resourceGraph: 'resourcegraph',
|
||||
};
|
||||
|
||||
export function interpolateVariable(value: any, variable: { multi: any; includeAll: any }) {
|
||||
export function interpolateVariable(value: any, variable: VariableWithMultiSupport) {
|
||||
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 + "'";
|
||||
} else {
|
||||
return value;
|
||||
|
Loading…
Reference in New Issue
Block a user