From f0d3a448eafab076b474a4aef1281be07ed680db Mon Sep 17 00:00:00 2001 From: Krzysztof Kowalczyk Date: Fri, 13 Dec 2024 18:39:05 +0100 Subject: [PATCH] [FieldFormatters] Add support for rawValue in url label (#204192) ## Summary This PR adds support for ``{{rawValue}}`` in url label. Closes: #188973 --- .../field_formats/common/converters/url.test.ts | 10 +++++++++- src/plugins/field_formats/common/converters/url.ts | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/field_formats/common/converters/url.test.ts b/src/plugins/field_formats/common/converters/url.test.ts index d1c89575b2d4d..9a1fcb7cbef6e 100644 --- a/src/plugins/field_formats/common/converters/url.test.ts +++ b/src/plugins/field_formats/common/converters/url.test.ts @@ -139,7 +139,7 @@ describe('UrlFormat', () => { expect(url.convert('url', TEXT_CONTEXT_TYPE)).toBe('external url'); }); - test('can use the raw value', () => { + test('can use the raw value with {{value}}', () => { const url = new UrlFormat({ labelTemplate: 'external {{value}}', }); @@ -147,6 +147,14 @@ describe('UrlFormat', () => { expect(url.convert('url?', TEXT_CONTEXT_TYPE)).toBe('external url?'); }); + test('can use the raw value with {{rawValue}}', () => { + const url = new UrlFormat({ + labelTemplate: 'external {{rawValue}}', + }); + + expect(url.convert('url?', TEXT_CONTEXT_TYPE)).toBe('external url?'); + }); + test('can use the url', () => { const url = new UrlFormat({ urlTemplate: 'http://google.com/{{value}}', diff --git a/src/plugins/field_formats/common/converters/url.ts b/src/plugins/field_formats/common/converters/url.ts index a0b423a737f08..ffa6973de27a4 100644 --- a/src/plugins/field_formats/common/converters/url.ts +++ b/src/plugins/field_formats/common/converters/url.ts @@ -86,6 +86,7 @@ export class UrlFormat extends FieldFormat { return this.compileTemplate(template)({ value, url, + rawValue: value, }); }