From dc1a26b10ca1c227972b58a969825635db6e13f8 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Fri, 13 Dec 2019 10:41:51 +0300 Subject: [PATCH] Kibana 7.0.0 URL field formatter doesn't render relative hyperlinks properly (#52874) Closes #35235 --- src/legacy/ui/public/field_editor/field_editor.js | 3 +-- src/plugins/data/common/field_formats/field_format.ts | 4 ++++ src/plugins/data/public/index_patterns/fields/field.ts | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/legacy/ui/public/field_editor/field_editor.js b/src/legacy/ui/public/field_editor/field_editor.js index f3c5990caae64..130d969e5cd02 100644 --- a/src/legacy/ui/public/field_editor/field_editor.js +++ b/src/legacy/ui/public/field_editor/field_editor.js @@ -689,7 +689,6 @@ export class FieldEditor extends PureComponent { } saveField = async () => { - const fieldFormat = this.state.field.format; const field = this.state.field.toActualField(); const { indexPattern } = this.props; const { fieldFormatId } = this.state; @@ -727,7 +726,7 @@ export class FieldEditor extends PureComponent { if (!fieldFormatId) { indexPattern.fieldFormatMap[field.name] = undefined; } else { - indexPattern.fieldFormatMap[field.name] = fieldFormat; + indexPattern.fieldFormatMap[field.name] = field.format; } return indexPattern.save() diff --git a/src/plugins/data/common/field_formats/field_format.ts b/src/plugins/data/common/field_formats/field_format.ts index dd445a33f21c5..85d276767b5a7 100644 --- a/src/plugins/data/common/field_formats/field_format.ts +++ b/src/plugins/data/common/field_formats/field_format.ts @@ -194,6 +194,10 @@ export abstract class FieldFormat { [HTML_CONTEXT_TYPE]: htmlContentTypeSetup(this, this.htmlConvert), }; } + + static isInstanceOfFieldFormat(fieldFormat: any): fieldFormat is FieldFormat { + return Boolean(fieldFormat && fieldFormat.convert); + } } export type IFieldFormat = PublicMethodsOf; diff --git a/src/plugins/data/public/index_patterns/fields/field.ts b/src/plugins/data/public/index_patterns/fields/field.ts index c8c8ac1ffd321..6ed3c2be8f96e 100644 --- a/src/plugins/data/public/index_patterns/fields/field.ts +++ b/src/plugins/data/public/index_patterns/fields/field.ts @@ -94,7 +94,8 @@ export class Field implements IFieldType { if (!type) type = getKbnFieldType('unknown'); let format = spec.format; - if (!format || !(format instanceof FieldFormat)) { + + if (!FieldFormat.isInstanceOfFieldFormat(format)) { const fieldFormats = getFieldFormats(); format =