From b35637136ce63edfd0488b28482ba28574848df6 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 24 Dec 2019 14:12:33 +0300 Subject: [PATCH] [7.5] Kibana 7.0.0 URL field formatter doesn't render relative hyperlinks properly Closes: #35235 (fix for 7.5) --- .../loader/pipeline_helpers/utilities.ts | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts index c12bd222663ae..6840482497bca 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts @@ -129,40 +129,28 @@ export const getFormat: FormatFactory = (mapping = {}) => { }); return new IpRangeFormat(); } else if (isTermsFieldFormat(mapping) && mapping.params) { - const params = mapping.params; + const { params } = mapping; + const convert = (val: string, type: string) => { + if (val === '__other__') { + return params.otherBucketLabel; + } + if (val === '__missing__') { + return params.missingBucketLabel; + } + + const format = getFieldFormat(params.id, params); + const parsedUrl = { + origin: window.location.origin, + pathname: window.location.pathname, + basePath: chrome.getBasePath(), + }; + + return format.getConverterFor(type)(val, undefined, undefined, parsedUrl); + }; + return { - getConverterFor: (type: string) => { - const format = getFieldFormat(params.id, mapping.params); - return (val: string) => { - if (val === '__other__') { - return params.otherBucketLabel; - } - if (val === '__missing__') { - return params.missingBucketLabel; - } - const parsedUrl = { - origin: window.location.origin, - pathname: window.location.pathname, - basePath: chrome.getBasePath(), - }; - return format.convert(val, undefined, undefined, parsedUrl); - }; - }, - convert: (val: string, type: string) => { - const format = getFieldFormat(params.id, mapping.params); - if (val === '__other__') { - return params.otherBucketLabel; - } - if (val === '__missing__') { - return params.missingBucketLabel; - } - const parsedUrl = { - origin: window.location.origin, - pathname: window.location.pathname, - basePath: chrome.getBasePath(), - }; - return format.convert(val, type, undefined, parsedUrl); - }, + convert, + getConverterFor: (type: string) => (val: string) => convert(val, type), }; } else { return getFieldFormat(id, mapping.params);