From 4344975654b9148ca7cc2ebf84cd7760e37c45c1 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 2 Jun 2021 01:03:38 -0400 Subject: [PATCH] Variables: Support raw values of boolean type (#34727) (#35075) (cherry picked from commit 41375346504d0da8ba214f272e7a9bc2bed36777) Co-authored-by: Simon Podlipsky --- 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 ''; }