From 41375346504d0da8ba214f272e7a9bc2bed36777 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Wed, 2 Jun 2021 06:40:37 +0200 Subject: [PATCH] Variables: Support raw values of boolean type (#34727) --- public/app/features/variables/utils.test.ts | 1 + public/app/features/variables/utils.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/public/app/features/variables/utils.test.ts b/public/app/features/variables/utils.test.ts index e6ed4bc3fa1..90836b2d822 100644 --- a/public/app/features/variables/utils.test.ts +++ b/public/app/features/variables/utils.test.ts @@ -169,6 +169,7 @@ describe('ensureStringValues', () => { ${[1, 2]} | ${['1', '2']} ${'1'} | ${'1'} ${['1', '2']} | ${['1', '2']} + ${true} | ${'true'} `('when called with value:$value then result should be:$expected', ({ value, expected }) => { expect(ensureStringValues(value)).toEqual(expected); }); diff --git a/public/app/features/variables/utils.ts b/public/app/features/variables/utils.ts index 2b7c5842769..e62a7850827 100644 --- a/public/app/features/variables/utils.ts +++ b/public/app/features/variables/utils.ts @@ -239,5 +239,9 @@ export function ensureStringValues(value: any | any[]): string | string[] { return value; } + if (typeof value === 'boolean') { + return value.toString(); + } + return ''; }