From 2caf8c4f5934eb2f4361a13c478266a5a228f31e Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 7 Apr 2020 23:45:22 -0500 Subject: [PATCH 01/20] partial progress --- ...bytes.test.js.snap => bytes.test.tsx.snap} | 0 .../bytes/{bytes.test.js => bytes.test.tsx} | 6 +- .../editors/bytes/{bytes.js => bytes.ts} | 14 +-- .../editors/bytes/{index.js => index.ts} | 0 ...color.test.js.snap => color.test.tsx.snap} | 0 .../color/{color.test.js => color.test.tsx} | 0 .../editors/color/{color.js => color.tsx} | 47 ++++--- .../editors/color/{index.js => index.ts} | 0 .../{date.test.js.snap => date.test.tsx.snap} | 0 .../date/{date.test.js => date.test.tsx} | 6 +- .../editors/date/{date.js => date.tsx} | 20 +-- .../editors/date/{index.js => index.ts} | 0 ....test.js.snap => date_nanos.test.tsx.snap} | 0 .../{date_nanos.js => date_nanos.tsx} | 20 +-- .../editors/date_nanos/{index.js => index.ts} | 0 ...ult.test.js.snap => default.test.tsx.snap} | 0 .../default/{default.js => default.tsx} | 69 +++++++---- .../editors/default/{index.js => index.ts} | 2 +- ...on.test.js.snap => duration.test.tsx.snap} | 0 .../{duration.test.js => duration.test.tsx} | 0 .../duration/{duration.js => duration.tsx} | 53 +++++--- .../editors/duration/{index.js => index.tsx} | 0 ...mber.test.js.snap => number.test.tsx.snap} | 0 .../editors/number/{index.js => index.ts} | 0 .../{number.test.js => number.test.tsx} | 0 .../editors/number/{number.js => number.tsx} | 18 +-- ...ent.test.js.snap => percent.test.tsx.snap} | 0 .../editors/percent/{index.js => index.ts} | 0 .../percent/{percent.js => percent.tsx} | 14 +-- ...st.js.snap => static_lookup.test.tsx.snap} | 0 .../static_lookup/{index.js => index.ts} | 0 .../{static_lookup.js => static_lookup.tsx} | 21 +++- ...ring.test.js.snap => string.test.tsx.snap} | 0 .../editors/string/{index.js => index.ts} | 0 .../{string.test.js => string.test.tsx} | 0 .../editors/string/{string.js => string.tsx} | 20 +-- ...te.test.js.snap => truncate.test.tsx.snap} | 0 .../editors/truncate/{index.js => index.ts} | 0 .../editors/truncate/sample.js | 1 - .../editors/truncate/sample.ts | 20 +++ .../{truncate.test.js => truncate.test.tsx} | 0 .../truncate/{truncate.js => truncate.tsx} | 18 +-- ...ap => label_template_flyout.test.tsx.snap} | 0 .../{url.test.js.snap => url.test.tsx.snap} | 0 ...snap => url_template_flyout.test.tsx.snap} | 0 .../editors/url/{index.js => index.ts} | 0 ...test.js => label_template_flyout.test.tsx} | 0 ...te_flyout.js => label_template_flyout.tsx} | 2 +- .../editors/url/{url.test.js => url.test.tsx} | 0 .../editors/url/{url.js => url.tsx} | 46 +++++-- ...t.test.js => url_template_flyout.test.tsx} | 0 ...late_flyout.js => url_template_flyout.tsx} | 0 ...r.test.js => field_format_editor.test.tsx} | 0 ...rmat_editor.js => field_format_editor.tsx} | 35 +++--- .../{index.js => index.ts} | 0 .../{register.js => register.ts} | 0 ...les.test.js.snap => samples.test.tsx.snap} | 0 .../samples/{index.js => index.ts} | 0 .../{samples.test.js => samples.test.tsx} | 0 .../samples/{samples.js => samples.tsx} | 24 ++-- ...s.snap => disabled_call_out.test.tsx.snap} | 0 ...js.snap => warning_call_out.test.tsx.snap} | 0 ...out.test.js => disabled_call_out.test.tsx} | 0 ...bled_call_out.js => disabled_call_out.tsx} | 0 .../{index.js => index.ts} | 0 ..._out.test.js => warning_call_out.test.tsx} | 0 ...rning_call_out.js => warning_call_out.tsx} | 0 ...test.js.snap => help_flyout.test.tsx.snap} | 0 ...lp_flyout.test.js => help_flyout.test.tsx} | 0 .../{help_flyout.js => help_flyout.tsx} | 24 ++-- .../scripting_help/{index.js => index.ts} | 0 ...ripting_syntax.js => scripting_syntax.tsx} | 0 .../{test_script.js => test_script.tsx} | 44 ++++--- .../constants/{index.js => index.ts} | 0 ...d_editor.test.js => field_editor.test.tsx} | 22 +--- .../{field_editor.js => field_editor.tsx} | 116 +++++++++++------- .../field_editor/{index.js => index.ts} | 0 ...{copy_field.test.js => copy_field.test.ts} | 0 .../lib/{copy_field.js => copy_field.ts} | 11 +- .../field_editor/lib/{index.js => index.ts} | 0 ...{validate_script.js => validate_script.ts} | 17 ++- src/legacy/ui/public/field_editor/types.ts | 40 ++++++ .../{index.js => index.ts} | 2 +- .../field_formats/field_formats_registry.ts | 2 +- src/plugins/data/public/index.ts | 1 + .../index_patterns/fields/field_list.ts | 1 + 86 files changed, 464 insertions(+), 272 deletions(-) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/{bytes.test.js.snap => bytes.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/{bytes.test.js => bytes.test.tsx} (92%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/{bytes.js => bytes.ts} (86%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/{color.test.js.snap => color.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/{color.test.js => color.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/{color.js => color.tsx} (84%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/__snapshots__/{date.test.js.snap => date.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/{date.test.js => date.test.tsx} (92%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/{date.js => date.tsx} (90%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/{date_nanos.test.js.snap => date_nanos.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/{date_nanos.js => date_nanos.tsx} (89%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/__snapshots__/{default.test.js.snap => default.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/{default.js => default.tsx} (55%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/{index.js => index.ts} (88%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/{duration.test.js.snap => duration.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/{duration.test.js => duration.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/{duration.js => duration.tsx} (78%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/{index.js => index.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/__snapshots__/{number.test.js.snap => number.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/{number.test.js => number.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/{number.js => number.tsx} (88%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/{percent.test.js.snap => percent.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/{percent.js => percent.tsx} (86%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/{static_lookup.test.js.snap => static_lookup.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/{static_lookup.js => static_lookup.tsx} (92%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/__snapshots__/{string.test.js.snap => string.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/{string.test.js => string.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/{string.js => string.tsx} (88%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/{truncate.test.js.snap => truncate.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/{index.js => index.ts} (100%) delete mode 100644 src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.js create mode 100644 src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.ts rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/{truncate.test.js => truncate.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/{truncate.js => truncate.tsx} (87%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/{label_template_flyout.test.js.snap => label_template_flyout.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/{url.test.js.snap => url.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/{url_template_flyout.test.js.snap => url_template_flyout.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{label_template_flyout.test.js => label_template_flyout.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{label_template_flyout.js => label_template_flyout.tsx} (99%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{url.test.js => url.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{url.js => url.tsx} (88%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{url_template_flyout.test.js => url_template_flyout.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/{url_template_flyout.js => url_template_flyout.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/{field_format_editor.test.js => field_format_editor.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/{field_format_editor.js => field_format_editor.tsx} (71%) rename src/legacy/ui/public/field_editor/components/field_format_editor/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/{register.js => register.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/{samples.test.js.snap => samples.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/samples/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/samples/{samples.test.js => samples.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/field_format_editor/samples/{samples.js => samples.tsx} (82%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/{disabled_call_out.test.js.snap => disabled_call_out.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/{warning_call_out.test.js.snap => warning_call_out.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/{disabled_call_out.test.js => disabled_call_out.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/{disabled_call_out.js => disabled_call_out.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/{warning_call_out.test.js => warning_call_out.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_call_outs/{warning_call_out.js => warning_call_out.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/{help_flyout.test.js.snap => help_flyout.test.tsx.snap} (100%) rename src/legacy/ui/public/field_editor/components/scripting_help/{help_flyout.test.js => help_flyout.test.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_help/{help_flyout.js => help_flyout.tsx} (81%) rename src/legacy/ui/public/field_editor/components/scripting_help/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/components/scripting_help/{scripting_syntax.js => scripting_syntax.tsx} (100%) rename src/legacy/ui/public/field_editor/components/scripting_help/{test_script.js => test_script.tsx} (89%) rename src/legacy/ui/public/field_editor/constants/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/{field_editor.test.js => field_editor.test.tsx} (94%) rename src/legacy/ui/public/field_editor/{field_editor.js => field_editor.tsx} (89%) rename src/legacy/ui/public/field_editor/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/lib/__tests__/{copy_field.test.js => copy_field.test.ts} (100%) rename src/legacy/ui/public/field_editor/lib/{copy_field.js => copy_field.ts} (90%) rename src/legacy/ui/public/field_editor/lib/{index.js => index.ts} (100%) rename src/legacy/ui/public/field_editor/lib/{validate_script.js => validate_script.ts} (86%) create mode 100644 src/legacy/ui/public/field_editor/types.ts rename src/legacy/ui/public/scripting_languages/{index.js => index.ts} (100%) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx similarity index 92% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx index fea42dee6b6900..53928ebfbc6c88 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx @@ -24,12 +24,14 @@ import { BytesFormatEditor } from './bytes'; const fieldType = 'number'; const format = { - getConverterFor: jest.fn().mockImplementation(() => input => input * 2), + getConverterFor: jest.fn().mockImplementation(() => (input: number) => input * 2), getParamDefaults: jest.fn().mockImplementation(() => { return { pattern: '0,0.[000]b' }; }), }; -const formatParams = {}; +const formatParams = { + pattern: '', +}; const onChange = jest.fn(); const onError = jest.fn(); diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.ts similarity index 86% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.ts index cb5d0758efcdba..aa0f9ebb6567ae 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.ts @@ -18,16 +18,12 @@ */ import { NumberFormatEditor } from '../number'; +import { defaultState } from '../default'; export class BytesFormatEditor extends NumberFormatEditor { static formatId = 'bytes'; - - constructor(props) { - super(props); - - this.state = { - ...this.state, - sampleInputs: [256, 1024, 5150000, 1990000000], - }; - } + state = { + ...defaultState, + sampleInputs: [256, 1024, 5150000, 1990000000], + }; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.tsx similarity index 84% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.tsx index 4ad04f08915e70..1fdc36d4e85498 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/color.tsx @@ -21,22 +21,37 @@ import React, { Fragment } from 'react'; import { EuiBasicTable, EuiButton, EuiColorPicker, EuiFieldText, EuiSpacer } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, FormatEditorProps } from '../default'; import { fieldFormats } from '../../../../../../../../plugins/data/public'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface Color { + range?: string; + regex?: string; + text: string; + background: string; +} -export class ColorFormatEditor extends DefaultFormatEditor { - constructor(props) { +interface IndexedColor extends Color { + index: number; +} + +interface ColorFormatEditorFormatParams { + colors: Color[]; +} + +export class ColorFormatEditor extends DefaultFormatEditor { + static formatId = 'color'; + constructor(props: FormatEditorProps) { super(props); this.onChange({ fieldType: props.fieldType, }); } - onColorChange = (newColorParams, index) => { + onColorChange = (newColorParams: Partial, index: number) => { const colors = [...this.props.formatParams.colors]; colors[index] = { ...colors[index], @@ -54,7 +69,7 @@ export class ColorFormatEditor extends DefaultFormatEditor { }); }; - removeColor = index => { + removeColor = (index: number) => { const colors = [...this.props.formatParams.colors]; colors.splice(index, 1); this.onChange({ @@ -86,7 +101,7 @@ export class ColorFormatEditor extends DefaultFormatEditor { defaultMessage="Pattern (regular expression)" /> ), - render: (value, item) => { + render: (value: string, item: IndexedColor) => { return ( ), - render: (value, item) => { + render: (value: string, item: IndexedColor) => { return ( ), - render: (color, item) => { + render: (color: string, item: IndexedColor) => { return ( ), - render: (color, item) => { + render: (color: string, item: IndexedColor) => { return ( ), - render: item => { + render: (item: IndexedColor) => { return (
{ + onClick: (item: IndexedColor) => { this.removeColor(item.index); }, type: 'icon', @@ -230,5 +249,3 @@ export class ColorFormatEditor extends DefaultFormatEditor { ); } } - -ColorFormatEditor.formatId = 'color'; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/__snapshots__/date.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/__snapshots__/date.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/__snapshots__/date.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/__snapshots__/date.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.tsx similarity index 92% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.tsx index 3aa60aa29fcb8f..d912ee06294044 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.test.tsx @@ -24,12 +24,14 @@ import { DateFormatEditor } from './date'; const fieldType = 'date'; const format = { - getConverterFor: jest.fn().mockImplementation(() => input => `converted date for ${input}`), + getConverterFor: jest + .fn() + .mockImplementation(() => (input: string) => `converted date for ${input}`), getParamDefaults: jest.fn().mockImplementation(() => { return { pattern: 'MMMM Do YYYY, HH:mm:ss.SSS' }; }), }; -const formatParams = {}; +const formatParams = { pattern: '' }; const onChange = jest.fn(); const onError = jest.fn(); diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.tsx similarity index 90% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.tsx index 69cdb159dd4aa9..8bbb379f5df5d6 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/date.tsx @@ -22,18 +22,20 @@ import moment from 'moment'; import { EuiCode, EuiFieldText, EuiFormRow, EuiIcon, EuiLink } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface DateFormatEditorFormatParams { + pattern: string; +} -export class DateFormatEditor extends DefaultFormatEditor { +export class DateFormatEditor extends DefaultFormatEditor { static formatId = 'date'; - - constructor(props) { - super(props); - this.state.sampleInputs = [ + state = { + ...defaultState, + sampleInputs: [ Date.now(), moment() .startOf('year') @@ -41,8 +43,8 @@ export class DateFormatEditor extends DefaultFormatEditor { moment() .endOf('year') .valueOf(), - ]; - } + ], + }; render() { const { format, formatParams } = this.props; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.tsx similarity index 89% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.tsx index 0660d06dda9df8..bfce3c973a1fa0 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/date_nanos.tsx @@ -21,23 +21,25 @@ import React, { Fragment } from 'react'; import { EuiCode, EuiFieldText, EuiFormRow, EuiIcon, EuiLink } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface DateNanosFormatEditorFormatParams { + pattern: string; +} -export class DateNanosFormatEditor extends DefaultFormatEditor { +export class DateNanosFormatEditor extends DefaultFormatEditor { static formatId = 'date_nanos'; - - constructor(props) { - super(props); - this.state.sampleInputs = [ + state = { + ...defaultState, + sampleInputs: [ '2015-01-01T12:10:30.123456789Z', '2019-05-08T06:55:21.567891234Z', '2019-08-06T17:22:30.987654321Z', - ]; - } + ], + }; render() { const { format, formatParams } = this.props; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/__snapshots__/default.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/__snapshots__/default.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/__snapshots__/default.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/__snapshots__/default.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx similarity index 55% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx index 6c4cfc9eb21066..80c09a8ea3af25 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx @@ -17,13 +17,17 @@ * under the License. */ -import { PureComponent } from 'react'; -import PropTypes from 'prop-types'; +import React, { PureComponent, ReactText } from 'react'; import { i18n } from '@kbn/i18n'; -export const convertSampleInput = (converter, inputs) => { +import { Sample, ConverterType } from '../../../../types'; + +export const convertSampleInput = ( + converter: (input: string | number) => string, + inputs: Array +) => { let error = null; - let samples = []; + let samples: Sample[] = []; try { samples = inputs.map(input => { @@ -45,33 +49,50 @@ export const convertSampleInput = (converter, inputs) => { }; }; -export class DefaultFormatEditor extends PureComponent { - static propTypes = { - fieldType: PropTypes.string.isRequired, - format: PropTypes.object.isRequired, - formatParams: PropTypes.object.isRequired, - onChange: PropTypes.func.isRequired, - onError: PropTypes.func.isRequired, - }; +interface SampleInputs { + [key: string]: Array; +} - constructor(props) { - super(props); - this.state = { - sampleInputs: [], - sampleConverterType: 'text', - error: null, - samples: [], - }; - } +export interface FormatEditorProps

{ + fieldType: string; // todo change to enum + format: any; // todo DecoratedFieldFormat + formatParams: { type?: string } & P; // todo + onChange: (newParams: any) => void; // todo + onError: (error: any) => void; // todo +} + +export interface FormatEditorState { + sampleInputs: ReactText[]; + sampleConverterType?: ConverterType; + error: any; + samples: Sample[]; + sampleInputsByType: SampleInputs; +} + +export const defaultState = { + sampleInputs: [] as ReactText[], + sampleConverterType: ConverterType.TEXT, + error: null, + samples: [] as Sample[], + sampleInputsByType: {}, +}; + +export class DefaultFormatEditor

extends PureComponent< + FormatEditorProps

, + FormatEditorState & S +> { + state = defaultState as FormatEditorState & S; - static getDerivedStateFromProps(nextProps, state) { + static getDerivedStateFromProps(nextProps: FormatEditorProps<{}>, state: FormatEditorState) { const { format, formatParams, onError } = nextProps; const { sampleInputsByType, sampleInputs, sampleConverterType } = state; const converter = format.getConverterFor(sampleConverterType); const type = typeof sampleInputsByType === 'object' && formatParams.type; - const inputs = type ? sampleInputsByType[formatParams.type] || [] : sampleInputs; + const inputs = type ? sampleInputsByType[formatParams.type as string] || [] : sampleInputs; + // console.log('inputs', inputs); const output = convertSampleInput(converter, inputs); + // console.log('getDerivedStateFromProps', nextProps, state); onError(output.error); return output; } @@ -85,6 +106,6 @@ export class DefaultFormatEditor extends PureComponent { }; render() { - return null; + return <>; } } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.ts similarity index 88% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.ts index 506002df4fd075..a6575f296864d4 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/index.ts @@ -17,4 +17,4 @@ * under the License. */ -export { DefaultFormatEditor } from './default'; +export { DefaultFormatEditor, defaultState, FormatEditorProps, FormatEditorState } from './default'; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx similarity index 78% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx index 2b2ae7c8fabb8c..469be14e0dfa11 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx @@ -21,23 +21,42 @@ import React, { Fragment } from 'react'; import { EuiFieldNumber, EuiFormRow, EuiSelect } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { + DefaultFormatEditor, + defaultState, + FormatEditorProps, + FormatEditorState, +} from '../default'; import { FormatEditorSamples } from '../../samples'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { i18n } from '@kbn/i18n'; +interface DurationFormatEditorState { + hasDecimalError: boolean; +} -export class DurationFormatEditor extends DefaultFormatEditor { - static formatId = 'duration'; +interface DurationFormatEditorFormatParams { + outputPrecision: number; + inputFormat: any; + outputFormat: any; // todo +} - constructor(props) { - super(props); - this.state.sampleInputs = [-123, 1, 12, 123, 658, 1988, 3857, 123292, 923528271]; - this.state.hasDecimalError = false; - } +export class DurationFormatEditor extends DefaultFormatEditor< + DurationFormatEditorFormatParams, + DurationFormatEditorState +> { + static formatId = 'duration'; + state = { + ...defaultState, + sampleInputs: [-123, 1, 12, 123, 658, 1988, 3857, 123292, 923528271], + hasDecimalError: false, + }; - static getDerivedStateFromProps(nextProps, state) { + static getDerivedStateFromProps( + nextProps: FormatEditorProps, + state: FormatEditorState & DurationFormatEditorState + ) { const output = super.getDerivedStateFromProps(nextProps, state); let error = null; @@ -77,10 +96,10 @@ export class DurationFormatEditor extends DefaultFormatEditor { > { + options={format.type.inputFormats.map(fmt => { return { - value: format.kind, - text: format.text, + value: fmt.kind, + text: fmt.text, }; })} onChange={e => { @@ -100,10 +119,10 @@ export class DurationFormatEditor extends DefaultFormatEditor { > { + options={format.type.outputFormats.map(fmt => { return { - value: format.method, - text: format.text, + value: fmt.method, + text: fmt.text, }; })} onChange={e => { diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/index.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/index.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/__snapshots__/number.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.tsx similarity index 88% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.tsx index 509508590780fd..9279eef7aedebf 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/number/number.tsx @@ -21,19 +21,21 @@ import React, { Fragment } from 'react'; import { EuiCode, EuiFieldText, EuiFormRow, EuiIcon, EuiLink } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; -import { FormattedMessage } from '@kbn/i18n/react'; +export interface NumberFormatEditorParams { + pattern: string; +} -export class NumberFormatEditor extends DefaultFormatEditor { +export class NumberFormatEditor extends DefaultFormatEditor { static formatId = 'number'; - - constructor(props) { - super(props); - this.state.sampleInputs = [10000, 12.345678, -1, -999, 0.52]; - } + state = { + ...defaultState, + sampleInputs: [10000, 12.345678, -1, -999, 0.52], + }; render() { const { format, formatParams } = this.props; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.tsx similarity index 86% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.tsx index 26effb8d800956..050c7a8a6cf0a2 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/percent.tsx @@ -18,16 +18,12 @@ */ import { NumberFormatEditor } from '../number'; +import { defaultState } from '../default'; export class PercentFormatEditor extends NumberFormatEditor { static formatId = 'percent'; - - constructor(props) { - super(props); - - this.state = { - ...this.state, - sampleInputs: [0.1, 0.99999, 1, 100, 1000], - }; - } + state = { + ...defaultState, + sampleInputs: [0.1, 0.99999, 1, 100, 1000], + }; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx similarity index 92% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx index 31ff99696da017..48a3c8b187a160 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx @@ -21,12 +21,19 @@ import React, { Fragment } from 'react'; import { EuiBasicTable, EuiButton, EuiFieldText, EuiFormRow, EuiSpacer } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; - import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor } from '../default'; -export class StaticLookupFormatEditor extends DefaultFormatEditor { +interface StaticLookupFormatEditorFormatParams { + lookupEntries: Array<{}>; + unknownKeyValue: string; +} + +export class StaticLookupFormatEditor extends DefaultFormatEditor< + StaticLookupFormatEditorFormatParams +> { + static formatId = 'static_lookup'; onLookupChange = (newLookupParams, index) => { const lookupEntries = [...this.props.formatParams.lookupEntries]; lookupEntries[index] = { @@ -45,7 +52,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor { }); }; - removeLookup = index => { + removeLookup = (index: number) => { const lookupEntries = [...this.props.formatParams.lookupEntries]; lookupEntries.splice(index, 1); this.onChange({ @@ -114,6 +121,10 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor { }, }, { + field: 'actions', + name: i18n.translate('common.ui.fieldEditor.staticLookup.actions', { + defaultMessage: 'actions', + }), actions: [ { name: i18n.translate('common.ui.fieldEditor.staticLookup.deleteAria', { @@ -172,5 +183,3 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor { ); } } - -StaticLookupFormatEditor.formatId = 'static_lookup'; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/__snapshots__/string.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/__snapshots__/string.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/__snapshots__/string.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/__snapshots__/string.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx similarity index 88% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx index d3de10e3e532ce..cb78b9cd04ec4d 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx @@ -21,26 +21,28 @@ import React, { Fragment } from 'react'; import { EuiFormRow, EuiSelect } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface StringFormatEditorFormatParams { + transform: string; +} -export class StringFormatEditor extends DefaultFormatEditor { +export class StringFormatEditor extends DefaultFormatEditor { static formatId = 'string'; - - constructor(props) { - super(props); - this.state.sampleInputs = [ + state = { + ...defaultState, + sampleInputs: [ 'A Quick Brown Fox.', 'STAY CALM!', 'com.organizations.project.ClassName', 'hostname.net', 'SGVsbG8gd29ybGQ=', '%EC%95%88%EB%85%95%20%ED%82%A4%EB%B0%94%EB%82%98', - ]; - } + ], + }; render() { const { format, formatParams } = this.props; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/__snapshots__/truncate.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.js deleted file mode 100644 index 5009ba5844eda4..00000000000000 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.js +++ /dev/null @@ -1 +0,0 @@ -export const sample = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae sem consequat, sollicitudin enim a, feugiat mi. Curabitur congue laoreet elit, eu dictum nisi commodo ut. Nullam congue sem a blandit commodo. Suspendisse eleifend sodales leo ac hendrerit. Nam fringilla tempor fermentum. Ut tristique pharetra sapien sit amet pharetra. Ut turpis massa, viverra id erat quis, fringilla vehicula risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus tincidunt gravida gravida. Praesent et ligula viverra, semper lacus in, tristique elit. Cras ac eleifend diam. Nulla facilisi. Morbi id sagittis magna. Sed fringilla, magna in suscipit aliquet."; // eslint-disable-line diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.ts b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.ts new file mode 100644 index 00000000000000..3d7bba0fce9077 --- /dev/null +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/sample.ts @@ -0,0 +1,20 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export const sample = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae sem consequat, sollicitudin enim a, feugiat mi. Curabitur congue laoreet elit, eu dictum nisi commodo ut. Nullam congue sem a blandit commodo. Suspendisse eleifend sodales leo ac hendrerit. Nam fringilla tempor fermentum. Ut tristique pharetra sapien sit amet pharetra. Ut turpis massa, viverra id erat quis, fringilla vehicula risus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus tincidunt gravida gravida. Praesent et ligula viverra, semper lacus in, tristique elit. Cras ac eleifend diam. Nulla facilisi. Morbi id sagittis magna. Sed fringilla, magna in suscipit aliquet."; // eslint-disable-line diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.tsx similarity index 87% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.tsx index 9a9b6c954b78d0..9fd44c5f9655de 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.tsx @@ -21,21 +21,23 @@ import React, { Fragment } from 'react'; import { EuiFieldNumber, EuiFormRow } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, defaultState } from '../default'; import { FormatEditorSamples } from '../../samples'; import { sample } from './sample'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface TruncateFormatEditorFormatParams { + fieldLength: number; +} -export class TruncateFormatEditor extends DefaultFormatEditor { +export class TruncateFormatEditor extends DefaultFormatEditor { static formatId = 'truncate'; - - constructor(props) { - super(props); - this.state.sampleInputs = [sample]; - } + state = { + ...defaultState, + sampleInputs: [sample], + }; render() { const { formatParams, onError } = this.props; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/label_template_flyout.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/label_template_flyout.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/label_template_flyout.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/label_template_flyout.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx similarity index 99% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx index 3f91f6f4253adb..f95eb197a3a8b0 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx @@ -132,7 +132,7 @@ export const LabelTemplateFlyout = ({ isVisible = false, onClose = () => {} }) = * Justification for dangerouslySetInnerHTML: * Example output produces anchor link. */ - dangerouslySetInnerHTML={{ __html: value }} //eslint-disable-line react/no-danger + dangerouslySetInnerHTML={{ __html: value }} // eslint-disable-line react/no-danger /> ); }, diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx similarity index 88% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx index d4a4293b456698..02caead6f73470 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx @@ -28,7 +28,9 @@ import { EuiFieldNumber, } from '@elastic/eui'; -import { DefaultFormatEditor } from '../default'; +import chrome from 'ui/chrome'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { DefaultFormatEditor, FormatEditorProps } from '../default'; import { FormatEditorSamples } from '../../samples'; @@ -36,15 +38,37 @@ import { LabelTemplateFlyout } from './label_template_flyout'; import { UrlTemplateFlyout } from './url_template_flyout'; -import chrome from 'ui/chrome'; +import { ConverterType } from '../../../../types'; + import './icons'; -import { FormattedMessage } from '@kbn/i18n/react'; +interface OnChangeParam { + type: string; + width?: string; + height?: string; + urlTemplate?: string; +} + +interface UrlFormatEditorFormatParams { + openLinkInCurrentTab: boolean; + urlTemplate: string; + labelTemplate: string; + width: string; + height: string; +} + +interface UrlFormatEditorFormatState { + showLabelTemplateHelp: boolean; + showUrlTemplateHelp: boolean; +} -export class UrlFormatEditor extends DefaultFormatEditor { +export class UrlFormatEditor extends DefaultFormatEditor< + UrlFormatEditorFormatParams, + UrlFormatEditorFormatState +> { static formatId = 'url'; - constructor(props) { + constructor(props: FormatEditorProps) { super(props); const bp = chrome.getBasePath(); this.iconPattern = `${bp}/bundles/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/icons/{{value}}.png`; @@ -55,23 +79,23 @@ export class UrlFormatEditor extends DefaultFormatEditor { img: ['go', 'stop', ['de', 'ne', 'us', 'ni'], 'cv'], audio: ['hello.mp3'], }, - sampleConverterType: 'html', + sampleConverterType: ConverterType.HTML, showUrlTemplateHelp: false, showLabelTemplateHelp: false, }; } - sanitizeNumericValue = val => { - const sanitizedValue = parseInt(val); + sanitizeNumericValue = (val: string) => { + const sanitizedValue = parseInt(val, 10); if (isNaN(sanitizedValue)) { return ''; } return sanitizedValue; }; - onTypeChange = newType => { + onTypeChange = (newType: string) => { const { urlTemplate, width, height } = this.props.formatParams; - const params = { + const params: OnChangeParam = { type: newType, }; if (newType === 'img') { @@ -81,7 +105,7 @@ export class UrlFormatEditor extends DefaultFormatEditor { params.urlTemplate = this.iconPattern; } } else if (newType !== 'img' && urlTemplate === this.iconPattern) { - params.urlTemplate = null; + params.urlTemplate = undefined; } this.onChange(params); }; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.js b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url_template_flyout.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.js b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx similarity index 71% rename from src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx index 204554ad94644c..750b7fb8dfa2be 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx @@ -18,27 +18,26 @@ */ import React, { PureComponent, Fragment } from 'react'; -import PropTypes from 'prop-types'; -export class FieldFormatEditor extends PureComponent { - static propTypes = { - fieldType: PropTypes.string.isRequired, - fieldFormat: PropTypes.object.isRequired, - fieldFormatId: PropTypes.string.isRequired, - fieldFormatParams: PropTypes.object.isRequired, - fieldFormatEditors: PropTypes.object.isRequired, - onChange: PropTypes.func.isRequired, - onError: PropTypes.func.isRequired, - }; +interface FieldFormatEditorProps { + fieldType: string; + fieldFormat: any; // todo + fieldFormatId: string; + fieldFormatParams: any; // todo + fieldFormatEditors: any; // todo + onChange: () => void; + onError: () => void; +} - constructor(props) { - super(props); - this.state = { - EditorComponent: null, - }; - } +interface FieldFormatEditorState { + EditorComponent?: React.FC; // todo +} - static getDerivedStateFromProps(nextProps) { +export class FieldFormatEditor extends PureComponent< + FieldFormatEditorProps, + FieldFormatEditorState +> { + static getDerivedStateFromProps(nextProps: FieldFormatEditorProps) { return { EditorComponent: nextProps.fieldFormatEditors.getEditor(nextProps.fieldFormatId) || null, }; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/register.js b/src/legacy/ui/public/field_editor/components/field_format_editor/register.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/register.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/register.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/index.js b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/samples/index.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/samples/index.ts diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.js b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.js b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx similarity index 82% rename from src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.js rename to src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx index b3345f085882c4..b1f9dab9ec484a 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.js +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx @@ -18,26 +18,22 @@ */ import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; import { EuiBasicTable, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +import { Sample } from '../../../types'; -export class FormatEditorSamples extends PureComponent { +interface FormatEditorSamplesProps { + samples: Sample[]; + sampleType: 'html' | 'text'; +} + +export class FormatEditorSamples extends PureComponent { static defaultProps = { sampleType: 'text', }; - static propTypes = { - samples: PropTypes.arrayOf( - PropTypes.shape({ - input: PropTypes.any.isRequired, - output: PropTypes.any.isRequired, - }) - ).isRequired, - sampleType: PropTypes.oneOf(['html', 'text']), - }; render() { const { samples, sampleType } = this.props; @@ -48,7 +44,7 @@ export class FormatEditorSamples extends PureComponent { name: i18n.translate('common.ui.fieldEditor.samples.inputHeader', { defaultMessage: 'Input', }), - render: input => { + render: (input: any) => { return typeof input === 'object' ? JSON.stringify(input) : input; }, }, @@ -57,14 +53,14 @@ export class FormatEditorSamples extends PureComponent { name: i18n.translate('common.ui.fieldEditor.samples.outputHeader', { defaultMessage: 'Output', }), - render: output => { + render: (output: string) => { return sampleType === 'html' ? (

) : (
{output}
diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/disabled_call_out.test.js.snap b/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/disabled_call_out.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/disabled_call_out.test.js.snap rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/disabled_call_out.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.js.snap b/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.js.snap rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.test.js b/src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.test.js rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.js b/src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.js rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/disabled_call_out.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/index.js b/src/legacy/ui/public/field_editor/components/scripting_call_outs/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/index.js rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/index.ts diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.js b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.js rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.js b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.js rename to src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.js.snap b/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.js.snap rename to src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.js b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.js rename to src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.js b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx similarity index 81% rename from src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.js rename to src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx index c512b5f5f2019c..7664007d3d440a 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.js +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx @@ -18,14 +18,26 @@ */ import React from 'react'; -import PropTypes from 'prop-types'; import { EuiFlyout, EuiFlyoutBody, EuiTabbedContent } from '@elastic/eui'; import { ScriptingSyntax } from './scripting_syntax'; import { TestScript } from './test_script'; -export const ScriptingHelpFlyout = ({ +import { IndexPattern } from '../../../../../../plugins/data/public'; +import { ExecuteScriptParams } from '../../types'; + +interface ScriptingHelpFlyoutProps { + indexPattern: IndexPattern; + lang: string; + name?: string; + script?: string; + executeScript: (params: ExecuteScriptParams) => void; + isVisible: boolean; + onClose: () => void; +} + +export const ScriptingHelpFlyout: React.FC = ({ isVisible = false, onClose = () => {}, indexPattern, @@ -67,11 +79,3 @@ export const ScriptingHelpFlyout = ({ }; ScriptingHelpFlyout.displayName = 'ScriptingHelpFlyout'; - -ScriptingHelpFlyout.propTypes = { - indexPattern: PropTypes.object.isRequired, - lang: PropTypes.string.isRequired, - name: PropTypes.string, - script: PropTypes.string, - executeScript: PropTypes.func.isRequired, -}; diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/index.js b/src/legacy/ui/public/field_editor/components/scripting_help/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_help/index.js rename to src/legacy/ui/public/field_editor/components/scripting_help/index.ts diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.js b/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx similarity index 100% rename from src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.js rename to src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.js b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx similarity index 89% rename from src/legacy/ui/public/field_editor/components/scripting_help/test_script.js rename to src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx index 12bf5c1cce0043..cfa2b1cb4b0276 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.js +++ b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx @@ -18,7 +18,6 @@ */ import React, { Component, Fragment } from 'react'; -import PropTypes from 'prop-types'; import { EuiButton, @@ -29,6 +28,7 @@ import { EuiSpacer, EuiTitle, EuiCallOut, + EuiComboBoxOptionOption, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; import { i18n } from '@kbn/i18n'; @@ -38,9 +38,27 @@ const { SearchBar } = npStart.plugins.data.ui; const { uiSettings } = npStart.core; -import { esQuery } from '../../../../../../plugins/data/public'; +import { esQuery, IndexPattern } from '../../../../../../plugins/data/public'; +import { ExecuteScriptParams } from '../../types'; + +interface TestScriptProps { + indexPattern: IndexPattern; + lang: string; + name?: string; + script?: string; + executeScript: (params: ExecuteScriptParams) => void; +} + +interface TestScriptState { + isLoading: boolean; + additionalFields: any[]; +} + +export class TestScript extends Component { + defaultProps = { + name: 'myScriptedField', + }; -export class TestScript extends Component { state = { isLoading: false, additionalFields: [], @@ -52,7 +70,8 @@ export class TestScript extends Component { } } - previewScript = async searchContext => { + // todo type this + previewScript = async (searchContext?: any) => { const { indexPattern, lang, name, script, executeScript } = this.props; if (!script || script.length === 0) { @@ -160,7 +179,7 @@ export class TestScript extends Component { renderToolbar() { const fieldsByTypeMap = new Map(); - const fields = []; + const fields: EuiComboBoxOptionOption[] = []; this.props.indexPattern.fields .filter(field => { @@ -180,7 +199,7 @@ export class TestScript extends Component { fieldsByTypeMap.forEach((fieldsList, fieldType) => { fields.push({ label: fieldType, - options: fieldsList.sort().map(fieldName => { + options: fieldsList.sort().map((fieldName: string) => { return { value: fieldName, label: fieldName }; }), }); @@ -214,6 +233,7 @@ export class TestScript extends Component {
({ getDeprecatedScriptingLanguages: () => ['testlang'], })); -jest.mock('ui/documentation_links', () => ({ - getDocLink: doc => `(docLink for ${doc})`, -})); - -jest.mock('ui/notify', () => ({ - toastNotifications: { - addSuccess: jest.fn(), - }, -})); - jest.mock('./components/scripting_call_outs', () => ({ ScriptingDisabledCallOut: 'scripting-disabled-callOut', ScriptingWarningCallOut: 'scripting-warning-callOut', @@ -87,12 +77,12 @@ const fields = [ }, ]; fields.getByName = name => { - const fields = { + const flds = { foobar: { name: 'foobar', }, }; - return fields[name]; + return flds[name]; }; class Format { @@ -150,10 +140,10 @@ describe('FieldEditor', () => { }; indexPattern.fields.push(testField); indexPattern.fields.getByName = name => { - const fields = { + const flds = { [testField.name]: testField, }; - return fields[name]; + return flds[name]; }; const component = shallowWithI18nProvider( @@ -174,10 +164,10 @@ describe('FieldEditor', () => { }; indexPattern.fields.push(testField); indexPattern.fields.getByName = name => { - const fields = { + const flds = { [testField.name]: testField, }; - return fields[name]; + return flds[name]; }; const component = shallowWithI18nProvider( diff --git a/src/legacy/ui/public/field_editor/field_editor.js b/src/legacy/ui/public/field_editor/field_editor.tsx similarity index 89% rename from src/legacy/ui/public/field_editor/field_editor.js rename to src/legacy/ui/public/field_editor/field_editor.tsx index 43461c4c689be6..93d90cb6f8e8f1 100644 --- a/src/legacy/ui/public/field_editor/field_editor.js +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -18,19 +18,15 @@ */ import React, { PureComponent, Fragment } from 'react'; -import PropTypes from 'prop-types'; import { intersection, union, get } from 'lodash'; +// todo move into ui/field_editor import { GetEnabledScriptingLanguagesProvider, getDeprecatedScriptingLanguages, getSupportedScriptingLanguages, } from 'ui/scripting_languages'; -import { getDocLink } from 'ui/documentation_links'; - -import { toastNotifications } from 'ui/notify'; - import { npStart } from 'ui/new_platform'; import { @@ -56,6 +52,11 @@ import { EUI_MODAL_CONFIRM_BUTTON, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { IndexPattern, IFieldType, KBN_FIELD_TYPES } from '../../../../plugins/data/public'; +import { IFieldFormatType } from '../../../../plugins/data/common'; +import { Field } from '../../../../plugins/data/public'; import { ScriptingDisabledCallOut, ScriptingWarningCallOut, @@ -68,20 +69,19 @@ import { FieldFormatEditor } from './components/field_format_editor'; import { FIELD_TYPES_BY_LANG, DEFAULT_FIELD_TYPES } from './constants'; import { copyField, executeScript, isScriptValid } from './lib'; -import { i18n } from '@kbn/i18n'; -import { FormattedMessage } from '@kbn/i18n/react'; - // This loads Ace editor's "groovy" mode, used below to highlight the script. import 'brace/mode/groovy'; const getFieldFormats = () => npStart.plugins.data.fieldFormats; -const getFieldTypeFormatsList = (field, defaultFieldFormat) => { +const getFieldTypeFormatsList = (field: IFieldType, defaultFieldFormat: IFieldFormatType) => { const fieldFormats = getFieldFormats(); - const formatsByType = fieldFormats.getByFieldType(field.type).map(({ id, title }) => ({ - id, - title, - })); + const formatsByType = fieldFormats + .getByFieldType(field.type as KBN_FIELD_TYPES) + .map(({ id, title }) => ({ + id, + title, + })); return [ { @@ -95,26 +95,47 @@ const getFieldTypeFormatsList = (field, defaultFieldFormat) => { ]; }; -export class FieldEditor extends PureComponent { - static propTypes = { - indexPattern: PropTypes.object.isRequired, - field: PropTypes.object.isRequired, - helpers: PropTypes.shape({ - Field: PropTypes.func.isRequired, - getConfig: PropTypes.func.isRequired, - $http: PropTypes.func.isRequired, - fieldFormatEditors: PropTypes.object.isRequired, - redirectAway: PropTypes.func.isRequired, - }), +export interface FieldEditorState { + isReady: boolean; + isCreating: boolean; + isDeprecatedLang: boolean; + scriptingLangs: string[]; + fieldTypes: any[]; // todo + fieldTypeFormats: any[]; + existingFieldNames: string[]; + field: any; + fieldFormatId?: string; + fieldFormatParams: any; + showScriptingHelp: boolean; + showDeleteModal: boolean; + hasFormatError: boolean; + hasScriptError: boolean; + isSaving: boolean; + errors?: string[]; +} + +export interface FieldEdiorProps { + indexPattern: IndexPattern; + field: Field; + helpers: { + Field: any; + getConfig: () => any; + $http: () => any; + fieldFormatEditors: any; + redirectAway: () => void; }; +} - constructor(props) { +export class FieldEditor extends PureComponent { + supportedLangs: string[] = []; + deprecatedLangs: string[] = []; + constructor(props: FieldEdiorProps) { super(props); const { field, indexPattern, - helpers: { Field }, + helpers: { Field: FieldClass }, } = props; this.state = { @@ -124,8 +145,8 @@ export class FieldEditor extends PureComponent { scriptingLangs: [], fieldTypes: [], fieldTypeFormats: [], - existingFieldNames: indexPattern.fields.map(f => f.name), - field: copyField(field, indexPattern, Field), + existingFieldNames: indexPattern.fields.map((f: IFieldType) => f.name), + field: copyField(field, indexPattern, FieldClass), fieldFormatId: undefined, fieldFormatParams: {}, showScriptingHelp: false, @@ -144,7 +165,7 @@ export class FieldEditor extends PureComponent { const { field } = this.state; const { indexPattern } = this.props; - const getEnabledScriptingLanguages = new GetEnabledScriptingLanguagesProvider($http); + const getEnabledScriptingLanguages = GetEnabledScriptingLanguagesProvider($http); const enabledLangs = await getEnabledScriptingLanguages(); const scriptingLangs = intersection( enabledLangs, @@ -160,28 +181,28 @@ export class FieldEditor extends PureComponent { this.setState({ isReady: true, - isCreating: !indexPattern.fields.getByName(field.name), + isCreating: !indexPattern.fields.find(f => f.name === field.name), isDeprecatedLang: this.deprecatedLangs.includes(field.lang), errors: [], scriptingLangs, fieldTypes, - fieldTypeFormats: getFieldTypeFormatsList(field, DefaultFieldFormat), + fieldTypeFormats: getFieldTypeFormatsList(field, DefaultFieldFormat as IFieldFormatType), fieldFormatId: get(indexPattern, ['fieldFormatMap', field.name, 'type', 'id']), fieldFormatParams: field.format.params(), }); } - onFieldChange = (fieldName, value) => { + onFieldChange = (fieldName: string, value: string | number) => { const { field } = this.state; field[fieldName] = value; this.forceUpdate(); }; - onTypeChange = type => { + onTypeChange = (type: KBN_FIELD_TYPES) => { const { getConfig } = this.props.helpers; const { field } = this.state; const fieldFormats = getFieldFormats(); - const DefaultFieldFormat = fieldFormats.getDefaultType(type); + const DefaultFieldFormat = fieldFormats.getDefaultType(type) as IFieldFormatType; field.type = type; field.format = new DefaultFieldFormat(null, getConfig); @@ -193,7 +214,7 @@ export class FieldEditor extends PureComponent { }); }; - onLangChange = lang => { + onLangChange = (lang: string) => { const { field } = this.state; const fieldTypes = get(FIELD_TYPES_BY_LANG, lang, DEFAULT_FIELD_TYPES); field.lang = lang; @@ -204,12 +225,12 @@ export class FieldEditor extends PureComponent { }); }; - onFormatChange = (formatId, params) => { + onFormatChange = (formatId: string, params?: any) => { const fieldFormats = getFieldFormats(); const { field, fieldTypeFormats } = this.state; const FieldFormat = fieldFormats.getType( formatId || fieldTypeFormats[0]?.defaultFieldFormat.id - ); + ) as IFieldFormatType; field.format = new FieldFormat(params, this.props.helpers.getConfig); @@ -219,12 +240,12 @@ export class FieldEditor extends PureComponent { }); }; - onFormatParamsChange = newParams => { + onFormatParamsChange = (newParams: { fieldType: string; [key: string]: any }) => { const { fieldFormatId } = this.state; - this.onFormatChange(fieldFormatId, newParams); + this.onFormatChange(fieldFormatId as string, newParams); }; - onFormatParamsError = error => { + onFormatParamsError = (error: string) => { this.setState({ hasFormatError: !!error, }); @@ -317,7 +338,10 @@ export class FieldEditor extends PureComponent { values={{ language: {field.lang}, painlessLink: ( - + { - this.onTypeChange(e.target.value); + this.onTypeChange(e.target.value as KBN_FIELD_TYPES); }} /> @@ -499,7 +523,7 @@ export class FieldEditor extends PureComponent { ); } - onScriptChange = value => { + onScriptChange = (value: string) => { this.setState({ hasScriptError: false, }); @@ -721,7 +745,7 @@ export class FieldEditor extends PureComponent { defaultMessage: "Deleted '{fieldName}'", values: { fieldName: field.name }, }); - toastNotifications.addSuccess(message); + npStart.core.notifications.toasts.addSuccess(message); redirectAway(); }); } else { @@ -756,7 +780,7 @@ export class FieldEditor extends PureComponent { } const { redirectAway } = this.props.helpers; - const index = indexPattern.fields.findIndex(f => f.name === field.name); + const index = indexPattern.fields.findIndex((f: IFieldType) => f.name === field.name); if (index > -1) { indexPattern.fields.update(field); @@ -775,7 +799,7 @@ export class FieldEditor extends PureComponent { defaultMessage: "Saved '{fieldName}'", values: { fieldName: field.name }, }); - toastNotifications.addSuccess(message); + npStart.core.notifications.toasts.addSuccess(message); redirectAway(); }); }; diff --git a/src/legacy/ui/public/field_editor/index.js b/src/legacy/ui/public/field_editor/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/index.js rename to src/legacy/ui/public/field_editor/index.ts diff --git a/src/legacy/ui/public/field_editor/lib/__tests__/copy_field.test.js b/src/legacy/ui/public/field_editor/lib/__tests__/copy_field.test.ts similarity index 100% rename from src/legacy/ui/public/field_editor/lib/__tests__/copy_field.test.js rename to src/legacy/ui/public/field_editor/lib/__tests__/copy_field.test.ts diff --git a/src/legacy/ui/public/field_editor/lib/copy_field.js b/src/legacy/ui/public/field_editor/lib/copy_field.ts similarity index 90% rename from src/legacy/ui/public/field_editor/lib/copy_field.js rename to src/legacy/ui/public/field_editor/lib/copy_field.ts index bfc1cb8480d5d4..99c5c6ca8c8557 100644 --- a/src/legacy/ui/public/field_editor/lib/copy_field.js +++ b/src/legacy/ui/public/field_editor/lib/copy_field.ts @@ -18,6 +18,7 @@ */ import { has } from 'lodash'; +import { IndexPattern, Field, KBN_FIELD_TYPES } from '../../../../../plugins/data/public'; /** * Fully clones a Field object, so that modifications can be performed on @@ -29,10 +30,10 @@ import { has } from 'lodash'; * * @param {object} field - Field object to copy * @param {object} indexPattern - index pattern object the field belongs to - * @param {object} Field - Field object type + * @param {object} FieldObj - Field object type * @return {object} the cloned object */ -export const copyField = (field, indexPattern, Field) => { +export const copyField = (field: Field, indexPattern: IndexPattern, FieldObj: Field) => { const changes = {}; const newFieldProps = { // When we are ready to save the copied field back into the index pattern, @@ -40,7 +41,7 @@ export const copyField = (field, indexPattern, Field) => { // its original properties with our "changes" applied. toActualField: { value: () => { - return new Field(indexPattern, { + return new FieldObj(indexPattern, { ...field.$$spec, ...changes, }); @@ -69,10 +70,10 @@ export const copyField = (field, indexPattern, Field) => { newFieldProps[prop] = { enumerable: desc.enumerable, - get: function() { + get() { return has(changes, prop) ? changes[prop] : field[prop]; }, - set: function(v) { + set(v) { changes[prop] = v; }, }; diff --git a/src/legacy/ui/public/field_editor/lib/index.js b/src/legacy/ui/public/field_editor/lib/index.ts similarity index 100% rename from src/legacy/ui/public/field_editor/lib/index.js rename to src/legacy/ui/public/field_editor/lib/index.ts diff --git a/src/legacy/ui/public/field_editor/lib/validate_script.js b/src/legacy/ui/public/field_editor/lib/validate_script.ts similarity index 86% rename from src/legacy/ui/public/field_editor/lib/validate_script.js rename to src/legacy/ui/public/field_editor/lib/validate_script.ts index 47e2091565c30b..1f9e6c0768545f 100644 --- a/src/legacy/ui/public/field_editor/lib/validate_script.js +++ b/src/legacy/ui/public/field_editor/lib/validate_script.ts @@ -18,6 +18,7 @@ */ import { kfetch } from 'ui/kfetch'; +import { ExecuteScriptParams } from '../types'; export const executeScript = async ({ name, @@ -26,7 +27,7 @@ export const executeScript = async ({ indexPatternTitle, query, additionalFields = [], -}) => { +}: ExecuteScriptParams) => { // Using _msearch because _search with index name in path dorks everything up const header = { index: indexPatternTitle, @@ -50,10 +51,12 @@ export const executeScript = async ({ }; if (additionalFields.length > 0) { + // @ts-ignore search._source = additionalFields; } if (query) { + // @ts-ignore search.query = query; } @@ -63,7 +66,17 @@ export const executeScript = async ({ return esResp.responses[0]; }; -export const isScriptValid = async ({ name, lang, script, indexPatternTitle }) => { +export const isScriptValid = async ({ + name, + lang, + script, + indexPatternTitle, +}: { + name: string; + lang: string; + script: string; + indexPatternTitle: string; +}) => { const scriptResponse = await executeScript({ name, lang, script, indexPatternTitle }); if (scriptResponse.status !== 200) { diff --git a/src/legacy/ui/public/field_editor/types.ts b/src/legacy/ui/public/field_editor/types.ts new file mode 100644 index 00000000000000..3405ccb10d0926 --- /dev/null +++ b/src/legacy/ui/public/field_editor/types.ts @@ -0,0 +1,40 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { ReactText } from 'react'; + +export interface Sample { + input: ReactText; + output: string; +} + +// incomplete +export interface ExecuteScriptParams { + name: string; + lang: string; + script: string; + indexPatternTitle: string; + query?: string; + additionalFields?: string[]; +} + +export enum ConverterType { + TEXT, + HTML, +} diff --git a/src/legacy/ui/public/scripting_languages/index.js b/src/legacy/ui/public/scripting_languages/index.ts similarity index 100% rename from src/legacy/ui/public/scripting_languages/index.js rename to src/legacy/ui/public/scripting_languages/index.ts index 2f43a44d660686..c1638ad0cabf63 100644 --- a/src/legacy/ui/public/scripting_languages/index.js +++ b/src/legacy/ui/public/scripting_languages/index.ts @@ -17,9 +17,9 @@ * under the License. */ +import { i18n } from '@kbn/i18n'; import chrome from '../chrome'; import { toastNotifications } from '../notify'; -import { i18n } from '@kbn/i18n'; export function getSupportedScriptingLanguages() { return ['painless']; diff --git a/src/plugins/data/common/field_formats/field_formats_registry.ts b/src/plugins/data/common/field_formats/field_formats_registry.ts index 15b1687e223123..237cc7de3fc76d 100644 --- a/src/plugins/data/common/field_formats/field_formats_registry.ts +++ b/src/plugins/data/common/field_formats/field_formats_registry.ts @@ -110,7 +110,7 @@ export class FieldFormatsRegistry { */ getDefaultType = ( fieldType: KBN_FIELD_TYPES, - esTypes: ES_FIELD_TYPES[] + esTypes?: ES_FIELD_TYPES[] ): IFieldFormatType | undefined => { const config = this.getDefaultConfig(fieldType, esTypes); diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index efafea44167d46..3238d3927b10dd 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -255,6 +255,7 @@ export { AggregationRestrictions as IndexPatternAggRestrictions, // TODO: exported only in stub_index_pattern test. Move into data plugin and remove export. FieldList as IndexPatternFieldList, + Field, } from './index_patterns'; export { diff --git a/src/plugins/data/public/index_patterns/fields/field_list.ts b/src/plugins/data/public/index_patterns/fields/field_list.ts index 03214a8c96427a..397858e2efb321 100644 --- a/src/plugins/data/public/index_patterns/fields/field_list.ts +++ b/src/plugins/data/public/index_patterns/fields/field_list.ts @@ -29,6 +29,7 @@ export interface IFieldList extends Array { getByType(type: Field['type']): Field[]; add(field: FieldSpec): void; remove(field: IFieldType): void; + update(field: FieldSpec): void; } export class FieldList extends Array implements IFieldList { From 326925b2532cdd64914b6944e07f3e84ac955101 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 14 Apr 2020 12:36:56 -0500 Subject: [PATCH 02/20] partial progress on tyypescripting --- .../editors/default/default.tsx | 5 +- .../editors/duration/duration.tsx | 18 ++++- .../editors/static_lookup/static_lookup.tsx | 16 ++-- .../editors/string/string.tsx | 7 +- .../editors/url/label_template_flyout.tsx | 75 ++++++++++--------- .../field_format_editor/editors/url/url.tsx | 13 +++- .../field_format_editor.tsx | 16 +++- .../field_format_editor/samples/samples.tsx | 10 +-- .../ui/public/field_editor/field_editor.tsx | 7 +- src/legacy/ui/public/field_editor/types.ts | 2 +- ...mat_editors.js => field_format_editors.ts} | 5 -- .../ui/public/scripting_languages/index.ts | 4 +- 12 files changed, 108 insertions(+), 70 deletions(-) rename src/legacy/ui/public/registry/{field_format_editors.js => field_format_editors.ts} (88%) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx index 80c09a8ea3af25..599728b48d2e2e 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx @@ -23,8 +23,8 @@ import { i18n } from '@kbn/i18n'; import { Sample, ConverterType } from '../../../../types'; export const convertSampleInput = ( - converter: (input: string | number) => string, - inputs: Array + converter: (input: string | number | Array) => string, + inputs: Array> ) => { let error = null; let samples: Sample[] = []; @@ -59,6 +59,7 @@ export interface FormatEditorProps

{ formatParams: { type?: string } & P; // todo onChange: (newParams: any) => void; // todo onError: (error: any) => void; // todo + basePath: string; } export interface FormatEditorState { diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx index 469be14e0dfa11..291992503a7a51 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx @@ -36,10 +36,20 @@ interface DurationFormatEditorState { hasDecimalError: boolean; } +interface InputFormat { + kind: string; + text: string; +} + +interface OutputFormat { + method: string; + text: string; +} + interface DurationFormatEditorFormatParams { outputPrecision: number; - inputFormat: any; - outputFormat: any; // todo + inputFormat: string; + outputFormat: string; } export class DurationFormatEditor extends DefaultFormatEditor< @@ -96,7 +106,7 @@ export class DurationFormatEditor extends DefaultFormatEditor< > { + options={format.type.inputFormats.map((fmt: InputFormat) => { return { value: fmt.kind, text: fmt.text, @@ -119,7 +129,7 @@ export class DurationFormatEditor extends DefaultFormatEditor< > { + options={format.type.outputFormats.map((fmt: OutputFormat) => { return { value: fmt.method, text: fmt.text, diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx index 48a3c8b187a160..7abe99015cfa9f 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx @@ -26,15 +26,21 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { DefaultFormatEditor } from '../default'; interface StaticLookupFormatEditorFormatParams { - lookupEntries: Array<{}>; + lookupEntries: Array<{ key: string; value: string }>; unknownKeyValue: string; } +interface StaticLookupItem { + key: string; + value: string; + index: number; +} + export class StaticLookupFormatEditor extends DefaultFormatEditor< StaticLookupFormatEditorFormatParams > { static formatId = 'static_lookup'; - onLookupChange = (newLookupParams, index) => { + onLookupChange = (newLookupParams: { value?: string; key?: string }, index: number) => { const lookupEntries = [...this.props.formatParams.lookupEntries]; lookupEntries[index] = { ...lookupEntries[index], @@ -80,7 +86,7 @@ export class StaticLookupFormatEditor extends DefaultFormatEditor< name: ( ), - render: (value, item) => { + render: (value: number, item: StaticLookupItem) => { return ( ), - render: (value, item) => { + render: (value: number, item: StaticLookupItem) => { return ( { + onClick: (item: StaticLookupItem) => { this.removeLookup(item.index); }, type: 'icon', diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx index cb78b9cd04ec4d..f13fe44ee4280c 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.tsx @@ -30,6 +30,11 @@ interface StringFormatEditorFormatParams { transform: string; } +interface TransformOptions { + kind: string; + text: string; +} + export class StringFormatEditor extends DefaultFormatEditor { static formatId = 'string'; state = { @@ -63,7 +68,7 @@ export class StringFormatEditor extends DefaultFormatEditor { + options={format.type.transformOptions.map((option: TransformOptions) => { return { value: option.kind, text: option.text, diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx index f95eb197a3a8b0..1ce7bec579e164 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/label_template_flyout.tsx @@ -24,6 +24,43 @@ import { EuiBasicTable, EuiCode, EuiFlyout, EuiFlyoutBody, EuiText } from '@elas import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; +interface LabelTemplateExampleItem { + input: string | number; + urlTemplate: string; + labelTemplate: string; + output: string; +} + +const items: LabelTemplateExampleItem[] = [ + { + input: 1234, + urlTemplate: 'http://company.net/profiles?user_id={{value}}', + labelTemplate: i18n.translate('common.ui.fieldEditor.labelTemplate.example.idLabel', { + defaultMessage: 'User #{value}', + values: { value: '{{value}}' }, + }), + output: + '' + + i18n.translate('common.ui.fieldEditor.labelTemplate.example.output.idLabel', { + defaultMessage: 'User', + }) + + ' #1234', + }, + { + input: '/assets/main.css', + urlTemplate: 'http://site.com{{rawValue}}', + labelTemplate: i18n.translate('common.ui.fieldEditor.labelTemplate.example.pathLabel', { + defaultMessage: 'View Asset', + }), + output: + '' + + i18n.translate('common.ui.fieldEditor.labelTemplate.example.output.pathLabel', { + defaultMessage: 'View Asset', + }) + + '', + }, +]; + export const LabelTemplateFlyout = ({ isVisible = false, onClose = () => {} }) => { return isVisible ? ( @@ -66,40 +103,8 @@ export const LabelTemplateFlyout = ({ isVisible = false, onClose = () => {} }) = defaultMessage="Examples" /> - ' + - i18n.translate('common.ui.fieldEditor.labelTemplate.example.output.idLabel', { - defaultMessage: 'User', - }) + - ' #1234', - }, - { - input: '/assets/main.css', - urlTemplate: 'http://site.com{{rawValue}}', - labelTemplate: i18n.translate( - 'common.ui.fieldEditor.labelTemplate.example.pathLabel', - { defaultMessage: 'View Asset' } - ), - output: - '' + - i18n.translate('common.ui.fieldEditor.labelTemplate.example.output.pathLabel', { - defaultMessage: 'View Asset', - }) + - '', - }, - ]} + + items={items} columns={[ { field: 'input', @@ -125,7 +130,7 @@ export const LabelTemplateFlyout = ({ isVisible = false, onClose = () => {} }) = name: i18n.translate('common.ui.fieldEditor.labelTemplate.outputHeader', { defaultMessage: 'Output', }), - render: value => { + render: (value: LabelTemplateExampleItem['output']) => { return ( { static formatId = 'url'; + iconPattern: string; constructor(props: FormatEditorProps) { super(props); - const bp = chrome.getBasePath(); - this.iconPattern = `${bp}/bundles/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/icons/{{value}}.png`; + + this.iconPattern = `${props.basePath}/bundles/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/icons/{{value}}.png`; this.state = { ...this.state, sampleInputsByType: { @@ -193,7 +198,7 @@ export class UrlFormatEditor extends DefaultFormatEditor< { + options={format.type.urlTypes.map((type: UrlType) => { return { value: type.kind, text: type.text, diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx index 750b7fb8dfa2be..2b939b4c0c0229 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx @@ -25,12 +25,20 @@ interface FieldFormatEditorProps { fieldFormatId: string; fieldFormatParams: any; // todo fieldFormatEditors: any; // todo - onChange: () => void; - onError: () => void; + onChange: (change: { fieldType: string; [key: string]: any }) => void; // todo define next to caller + onError: (error: string) => void; +} + +interface EditorComponentProps { + fieldType: FieldFormatEditorProps['fieldType']; + format: FieldFormatEditorProps['fieldFormat']; + formatParams: FieldFormatEditorProps['fieldFormatParams']; + onChange: FieldFormatEditorProps['onChange']; + onError: FieldFormatEditorProps['onError']; } interface FieldFormatEditorState { - EditorComponent?: React.FC; // todo + EditorComponent?: React.FC; } export class FieldFormatEditor extends PureComponent< @@ -39,7 +47,7 @@ export class FieldFormatEditor extends PureComponent< > { static getDerivedStateFromProps(nextProps: FieldFormatEditorProps) { return { - EditorComponent: nextProps.fieldFormatEditors.getEditor(nextProps.fieldFormatId) || null, + EditorComponent: nextProps.fieldFormatEditors.byFormatId[nextProps.fieldFormatId] || null, }; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx index b1f9dab9ec484a..b11de6e9e52f59 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx @@ -23,16 +23,16 @@ import { EuiBasicTable, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Sample } from '../../../types'; +import { Sample, ConverterType } from '../../../types'; interface FormatEditorSamplesProps { samples: Sample[]; - sampleType: 'html' | 'text'; + sampleType: ConverterType; } export class FormatEditorSamples extends PureComponent { static defaultProps = { - sampleType: 'text', + sampleType: ConverterType.TEXT, }; render() { @@ -54,7 +54,7 @@ export class FormatEditorSamples extends PureComponent defaultMessage: 'Output', }), render: (output: string) => { - return sampleType === 'html' ? ( + return sampleType === ConverterType.HTML ? (

} > - className="kbnFieldFormatEditor__samples" compressed={true} items={samples} diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 991017203c8fed..ae2dcd6c6414bd 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -19,6 +19,7 @@ import React, { PureComponent, Fragment } from 'react'; import { intersection, union, get } from 'lodash'; +import { HttpStart } from 'src/core/public'; // todo move into ui/field_editor import { @@ -119,7 +120,7 @@ export interface FieldEdiorProps { field: Field; helpers: { getConfig: () => any; - $http: () => any; + getHttpStart: () => HttpStart; fieldFormatEditors: any; redirectAway: () => void; }; @@ -156,11 +157,11 @@ export class FieldEditor extends PureComponent { return $http .get(chrome.addBasePath('/api/kibana/scripts/languages')) From b0bf4c73c8a6b5f1e6d891bd75265e83882e7d83 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 20 Apr 2020 17:18:50 -0500 Subject: [PATCH 03/20] typescript fixes --- ...plugin-plugins-data-public.field.__spec.md | 11 ++ ...lugins-data-public.field._constructor_.md} | 4 +- ...-plugins-data-public.field.aggregatable.md | 11 ++ ...-plugin-plugins-data-public.field.count.md | 11 ++ ...n-plugins-data-public.field.displayname.md | 11 ++ ...lugin-plugins-data-public.field.estypes.md | 11 ++ ...in-plugins-data-public.field.filterable.md | 11 ++ ...plugin-plugins-data-public.field.format.md | 11 ++ ...-plugins-data-public.field.indexpattern.md | 11 ++ ...a-plugin-plugins-data-public.field.lang.md | 11 ++ ...kibana-plugin-plugins-data-public.field.md | 40 ++++++ ...a-plugin-plugins-data-public.field.name.md | 11 ++ ...plugin-plugins-data-public.field.script.md | 11 ++ ...ugin-plugins-data-public.field.scripted.md | 11 ++ ...in-plugins-data-public.field.searchable.md | 11 ++ ...ugin-plugins-data-public.field.sortable.md | 11 ++ ...lugin-plugins-data-public.field.subtype.md | 11 ++ ...a-plugin-plugins-data-public.field.type.md | 11 ++ ...-plugins-data-public.field.visualizable.md | 11 ++ ...ns-data-public.indexpatternfield.__spec.md | 11 -- ...a-public.indexpatternfield.aggregatable.md | 11 -- ...ins-data-public.indexpatternfield.count.md | 11 -- ...ta-public.indexpatternfield.displayname.md | 11 -- ...s-data-public.indexpatternfield.estypes.md | 11 -- ...ata-public.indexpatternfield.filterable.md | 11 -- ...ns-data-public.indexpatternfield.format.md | 11 -- ...a-public.indexpatternfield.indexpattern.md | 11 -- ...gins-data-public.indexpatternfield.lang.md | 11 -- ...n-plugins-data-public.indexpatternfield.md | 40 ------ ...gins-data-public.indexpatternfield.name.md | 11 -- ...ns-data-public.indexpatternfield.script.md | 11 -- ...-data-public.indexpatternfield.scripted.md | 11 -- ...ata-public.indexpatternfield.searchable.md | 11 -- ...-data-public.indexpatternfield.sortable.md | 11 -- ...s-data-public.indexpatternfield.subtype.md | 11 -- ...gins-data-public.indexpatternfield.type.md | 11 -- ...a-public.indexpatternfield.visualizable.md | 11 -- .../kibana-plugin-plugins-data-public.md | 2 +- .../create_edit_field/create_edit_field.tsx | 63 +++++---- .../edit_index_pattern/edit_index_pattern.js | 2 +- .../components/scripting_help/test_script.tsx | 32 +++-- .../ui/public/field_editor/field_editor.tsx | 2 +- src/legacy/ui/public/field_editor/types.ts | 2 +- src/plugins/data/public/public.api.md | 132 +++++++++--------- 44 files changed, 353 insertions(+), 340 deletions(-) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.__spec.md rename docs/development/plugins/data/public/{kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md => kibana-plugin-plugins-data-public.field._constructor_.md} (68%) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.aggregatable.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.count.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.displayname.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.estypes.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.filterable.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.format.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.indexpattern.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.lang.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.name.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.script.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.scripted.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.searchable.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.sortable.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.subtype.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.type.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.visualizable.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.__spec.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.count.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.displayname.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.estypes.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.filterable.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.format.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.lang.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.name.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.script.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.scripted.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.searchable.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.sortable.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.type.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.__spec.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.__spec.md new file mode 100644 index 00000000000000..43ff9a930b974d --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.__spec.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [$$spec](./kibana-plugin-plugins-data-public.field.__spec.md) + +## Field.$$spec property + +Signature: + +```typescript +$$spec: FieldSpec; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field._constructor_.md similarity index 68% rename from docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md rename to docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field._constructor_.md index cf7470c035a533..c3b2ac8d30b5a9 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field._constructor_.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [(constructor)](./kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md) +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [(constructor)](./kibana-plugin-plugins-data-public.field._constructor_.md) -## IndexPatternField.(constructor) +## Field.(constructor) Constructs a new instance of the `Field` class diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.aggregatable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.aggregatable.md new file mode 100644 index 00000000000000..fcfd7d73c8b0ce --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.aggregatable.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [aggregatable](./kibana-plugin-plugins-data-public.field.aggregatable.md) + +## Field.aggregatable property + +Signature: + +```typescript +aggregatable?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.count.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.count.md new file mode 100644 index 00000000000000..4f51d88a3046ed --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.count.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [count](./kibana-plugin-plugins-data-public.field.count.md) + +## Field.count property + +Signature: + +```typescript +count?: number; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.displayname.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.displayname.md new file mode 100644 index 00000000000000..0846a7595cf907 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.displayname.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [displayName](./kibana-plugin-plugins-data-public.field.displayname.md) + +## Field.displayName property + +Signature: + +```typescript +displayName?: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.estypes.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.estypes.md new file mode 100644 index 00000000000000..efe1bceb43361a --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.estypes.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [esTypes](./kibana-plugin-plugins-data-public.field.estypes.md) + +## Field.esTypes property + +Signature: + +```typescript +esTypes?: string[]; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.filterable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.filterable.md new file mode 100644 index 00000000000000..fd7be589e87a79 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.filterable.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [filterable](./kibana-plugin-plugins-data-public.field.filterable.md) + +## Field.filterable property + +Signature: + +```typescript +filterable?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.format.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.format.md new file mode 100644 index 00000000000000..431e043d1fecc6 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.format.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [format](./kibana-plugin-plugins-data-public.field.format.md) + +## Field.format property + +Signature: + +```typescript +format: any; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.indexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.indexpattern.md new file mode 100644 index 00000000000000..59420747e0958e --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.indexpattern.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [indexPattern](./kibana-plugin-plugins-data-public.field.indexpattern.md) + +## Field.indexPattern property + +Signature: + +```typescript +indexPattern?: IndexPattern; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.lang.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.lang.md new file mode 100644 index 00000000000000..d51857090356fe --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.lang.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [lang](./kibana-plugin-plugins-data-public.field.lang.md) + +## Field.lang property + +Signature: + +```typescript +lang?: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md new file mode 100644 index 00000000000000..84c22c47a5e2fc --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md @@ -0,0 +1,40 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) + +## Field class + +Signature: + +```typescript +export declare class Field implements IFieldType +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(indexPattern, spec, shortDotsEnable)](./kibana-plugin-plugins-data-public.field._constructor_.md) | | Constructs a new instance of the Field class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [$$spec](./kibana-plugin-plugins-data-public.field.__spec.md) | | FieldSpec | | +| [aggregatable](./kibana-plugin-plugins-data-public.field.aggregatable.md) | | boolean | | +| [count](./kibana-plugin-plugins-data-public.field.count.md) | | number | | +| [displayName](./kibana-plugin-plugins-data-public.field.displayname.md) | | string | | +| [esTypes](./kibana-plugin-plugins-data-public.field.estypes.md) | | string[] | | +| [filterable](./kibana-plugin-plugins-data-public.field.filterable.md) | | boolean | | +| [format](./kibana-plugin-plugins-data-public.field.format.md) | | any | | +| [indexPattern](./kibana-plugin-plugins-data-public.field.indexpattern.md) | | IndexPattern | | +| [lang](./kibana-plugin-plugins-data-public.field.lang.md) | | string | | +| [name](./kibana-plugin-plugins-data-public.field.name.md) | | string | | +| [script](./kibana-plugin-plugins-data-public.field.script.md) | | string | | +| [scripted](./kibana-plugin-plugins-data-public.field.scripted.md) | | boolean | | +| [searchable](./kibana-plugin-plugins-data-public.field.searchable.md) | | boolean | | +| [sortable](./kibana-plugin-plugins-data-public.field.sortable.md) | | boolean | | +| [subType](./kibana-plugin-plugins-data-public.field.subtype.md) | | IFieldSubType | | +| [type](./kibana-plugin-plugins-data-public.field.type.md) | | string | | +| [visualizable](./kibana-plugin-plugins-data-public.field.visualizable.md) | | boolean | | + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.name.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.name.md new file mode 100644 index 00000000000000..d2a9b9b86aefc9 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.name.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [name](./kibana-plugin-plugins-data-public.field.name.md) + +## Field.name property + +Signature: + +```typescript +name: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.script.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.script.md new file mode 100644 index 00000000000000..676ff9bdfc35a7 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.script.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [script](./kibana-plugin-plugins-data-public.field.script.md) + +## Field.script property + +Signature: + +```typescript +script?: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.scripted.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.scripted.md new file mode 100644 index 00000000000000..1f6c8105e3f618 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.scripted.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [scripted](./kibana-plugin-plugins-data-public.field.scripted.md) + +## Field.scripted property + +Signature: + +```typescript +scripted?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.searchable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.searchable.md new file mode 100644 index 00000000000000..186d344f503788 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.searchable.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [searchable](./kibana-plugin-plugins-data-public.field.searchable.md) + +## Field.searchable property + +Signature: + +```typescript +searchable?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.sortable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.sortable.md new file mode 100644 index 00000000000000..0cd4b14d0e1e5c --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.sortable.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [sortable](./kibana-plugin-plugins-data-public.field.sortable.md) + +## Field.sortable property + +Signature: + +```typescript +sortable?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.subtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.subtype.md new file mode 100644 index 00000000000000..bef3b2131fa475 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.subtype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [subType](./kibana-plugin-plugins-data-public.field.subtype.md) + +## Field.subType property + +Signature: + +```typescript +subType?: IFieldSubType; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.type.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.type.md new file mode 100644 index 00000000000000..490615edcf097e --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.type.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [type](./kibana-plugin-plugins-data-public.field.type.md) + +## Field.type property + +Signature: + +```typescript +type: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.visualizable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.visualizable.md new file mode 100644 index 00000000000000..f32a5c456dc5db --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.visualizable.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [visualizable](./kibana-plugin-plugins-data-public.field.visualizable.md) + +## Field.visualizable property + +Signature: + +```typescript +visualizable?: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.__spec.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.__spec.md deleted file mode 100644 index f52a3324af36f7..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.__spec.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [$$spec](./kibana-plugin-plugins-data-public.indexpatternfield.__spec.md) - -## IndexPatternField.$$spec property - -Signature: - -```typescript -$$spec: FieldSpec; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md deleted file mode 100644 index 267c8f786b5dd2..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [aggregatable](./kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md) - -## IndexPatternField.aggregatable property - -Signature: - -```typescript -aggregatable?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.count.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.count.md deleted file mode 100644 index 8e848276f21c4c..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.count.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [count](./kibana-plugin-plugins-data-public.indexpatternfield.count.md) - -## IndexPatternField.count property - -Signature: - -```typescript -count?: number; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.displayname.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.displayname.md deleted file mode 100644 index ed9630f92fc975..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.displayname.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [displayName](./kibana-plugin-plugins-data-public.indexpatternfield.displayname.md) - -## IndexPatternField.displayName property - -Signature: - -```typescript -displayName?: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.estypes.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.estypes.md deleted file mode 100644 index dec74df099d43a..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.estypes.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [esTypes](./kibana-plugin-plugins-data-public.indexpatternfield.estypes.md) - -## IndexPatternField.esTypes property - -Signature: - -```typescript -esTypes?: string[]; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.filterable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.filterable.md deleted file mode 100644 index 4290c4a2f86b3b..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.filterable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [filterable](./kibana-plugin-plugins-data-public.indexpatternfield.filterable.md) - -## IndexPatternField.filterable property - -Signature: - -```typescript -filterable?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.format.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.format.md deleted file mode 100644 index d5df8ed628cb08..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.format.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [format](./kibana-plugin-plugins-data-public.indexpatternfield.format.md) - -## IndexPatternField.format property - -Signature: - -```typescript -format: any; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md deleted file mode 100644 index d1a1ee0905c6e3..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [indexPattern](./kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md) - -## IndexPatternField.indexPattern property - -Signature: - -```typescript -indexPattern?: IndexPattern; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.lang.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.lang.md deleted file mode 100644 index f731be8f613cfa..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.lang.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [lang](./kibana-plugin-plugins-data-public.indexpatternfield.lang.md) - -## IndexPatternField.lang property - -Signature: - -```typescript -lang?: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md deleted file mode 100644 index df0de6ce0e5419..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.md +++ /dev/null @@ -1,40 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) - -## IndexPatternField class - -Signature: - -```typescript -export declare class Field implements IFieldType -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(indexPattern, spec, shortDotsEnable)](./kibana-plugin-plugins-data-public.indexpatternfield._constructor_.md) | | Constructs a new instance of the Field class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [$$spec](./kibana-plugin-plugins-data-public.indexpatternfield.__spec.md) | | FieldSpec | | -| [aggregatable](./kibana-plugin-plugins-data-public.indexpatternfield.aggregatable.md) | | boolean | | -| [count](./kibana-plugin-plugins-data-public.indexpatternfield.count.md) | | number | | -| [displayName](./kibana-plugin-plugins-data-public.indexpatternfield.displayname.md) | | string | | -| [esTypes](./kibana-plugin-plugins-data-public.indexpatternfield.estypes.md) | | string[] | | -| [filterable](./kibana-plugin-plugins-data-public.indexpatternfield.filterable.md) | | boolean | | -| [format](./kibana-plugin-plugins-data-public.indexpatternfield.format.md) | | any | | -| [indexPattern](./kibana-plugin-plugins-data-public.indexpatternfield.indexpattern.md) | | IndexPattern | | -| [lang](./kibana-plugin-plugins-data-public.indexpatternfield.lang.md) | | string | | -| [name](./kibana-plugin-plugins-data-public.indexpatternfield.name.md) | | string | | -| [script](./kibana-plugin-plugins-data-public.indexpatternfield.script.md) | | string | | -| [scripted](./kibana-plugin-plugins-data-public.indexpatternfield.scripted.md) | | boolean | | -| [searchable](./kibana-plugin-plugins-data-public.indexpatternfield.searchable.md) | | boolean | | -| [sortable](./kibana-plugin-plugins-data-public.indexpatternfield.sortable.md) | | boolean | | -| [subType](./kibana-plugin-plugins-data-public.indexpatternfield.subtype.md) | | IFieldSubType | | -| [type](./kibana-plugin-plugins-data-public.indexpatternfield.type.md) | | string | | -| [visualizable](./kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md) | | boolean | | - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.name.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.name.md deleted file mode 100644 index cb24621e732093..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.name.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [name](./kibana-plugin-plugins-data-public.indexpatternfield.name.md) - -## IndexPatternField.name property - -Signature: - -```typescript -name: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.script.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.script.md deleted file mode 100644 index 132ba25a476374..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.script.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [script](./kibana-plugin-plugins-data-public.indexpatternfield.script.md) - -## IndexPatternField.script property - -Signature: - -```typescript -script?: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.scripted.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.scripted.md deleted file mode 100644 index 1dd6bc865a75d9..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.scripted.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [scripted](./kibana-plugin-plugins-data-public.indexpatternfield.scripted.md) - -## IndexPatternField.scripted property - -Signature: - -```typescript -scripted?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.searchable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.searchable.md deleted file mode 100644 index 42f984d851435b..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.searchable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [searchable](./kibana-plugin-plugins-data-public.indexpatternfield.searchable.md) - -## IndexPatternField.searchable property - -Signature: - -```typescript -searchable?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.sortable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.sortable.md deleted file mode 100644 index 72d225185140be..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.sortable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [sortable](./kibana-plugin-plugins-data-public.indexpatternfield.sortable.md) - -## IndexPatternField.sortable property - -Signature: - -```typescript -sortable?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md deleted file mode 100644 index 2d807f8a5739ce..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.subtype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [subType](./kibana-plugin-plugins-data-public.indexpatternfield.subtype.md) - -## IndexPatternField.subType property - -Signature: - -```typescript -subType?: IFieldSubType; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.type.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.type.md deleted file mode 100644 index c8483c9b83c9a1..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.type.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [type](./kibana-plugin-plugins-data-public.indexpatternfield.type.md) - -## IndexPatternField.type property - -Signature: - -```typescript -type: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md deleted file mode 100644 index dd661ae779c117..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) > [visualizable](./kibana-plugin-plugins-data-public.indexpatternfield.visualizable.md) - -## IndexPatternField.visualizable property - -Signature: - -```typescript -visualizable?: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index bf29c883e4eb96..3713827f75386d 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -11,9 +11,9 @@ | [AggParamType](./kibana-plugin-plugins-data-public.aggparamtype.md) | | | [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) | A registry to store which are used to filter down available fields for a specific visualization and . | | [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) | A registry to store which are used to filter down available aggregations for a specific visualization and . | +| [Field](./kibana-plugin-plugins-data-public.field.md) | | | [FilterManager](./kibana-plugin-plugins-data-public.filtermanager.md) | | | [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) | | -| [IndexPatternField](./kibana-plugin-plugins-data-public.indexpatternfield.md) | | | [IndexPatternFieldList](./kibana-plugin-plugins-data-public.indexpatternfieldlist.md) | | | [IndexPatternSelect](./kibana-plugin-plugins-data-public.indexpatternselect.md) | | | [OptionedParamType](./kibana-plugin-plugins-data-public.optionedparamtype.md) | | diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx index 4839870f0f3c8a..da3a6ec12c1dbb 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx @@ -23,6 +23,7 @@ import { FieldEditor } from 'ui/field_editor'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { HttpStart } from 'src/core/public'; import { IndexHeader } from '../index_header'; import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public'; import { ChromeDocTitle, NotificationsStart } from '../../../../../../../../../core/public'; @@ -37,7 +38,7 @@ interface CreateEditFieldProps extends RouteComponentProps { services: { notifications: NotificationsStart; docTitle: ChromeDocTitle; - http: Function; + getHttpStart: () => HttpStart; }; } @@ -68,16 +69,14 @@ export const CreateEditField = withRouter( const url = `/management/kibana/index_patterns/${indexPattern.id}`; - if (mode === 'edit') { - if (!field) { - const message = i18n.translate('kbn.management.editIndexPattern.scripted.noFieldLabel', { - defaultMessage: - "'{indexPatternTitle}' index pattern doesn't have a scripted field called '{fieldName}'", - values: { indexPatternTitle: indexPattern.title, fieldName }, - }); - services.notifications.toasts.addWarning(message); - history.push(url); - } + if (mode === 'edit' && !field) { + const message = i18n.translate('kbn.management.editIndexPattern.scripted.noFieldLabel', { + defaultMessage: + "'{indexPatternTitle}' index pattern doesn't have a scripted field called '{fieldName}'", + values: { indexPatternTitle: indexPattern.title, fieldName }, + }); + services.notifications.toasts.addWarning(message); + history.push(url); } const docFieldName = field?.name || newFieldPlaceholder; @@ -88,24 +87,28 @@ export const CreateEditField = withRouter( history.push(`${url}?_a=(tab:${field?.scripted ? TAB_SCRIPTED_FIELDS : TAB_INDEXED_FIELDS})`); }; - return ( - - - - - - - - - ); + if (field) { + return ( + + + + + + + + + ); + } else { + return <>; + } } ); diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js index 3239a17f109e43..d0c5ceb91309c2 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/edit_index_pattern.js @@ -448,7 +448,7 @@ const renderCreateEditField = ($scope, $route, getConfig, $http, fieldFormatEdit fieldFormatEditors={fieldFormatEditors} getConfig={getConfig} services={{ - http: $http, + getHttpStart: () => $http, notifications: npStart.core.notifications, docTitle: npStart.core.chrome.docTitle, }} diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx index cfa2b1cb4b0276..b9d2e3d3bef216 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx @@ -46,12 +46,20 @@ interface TestScriptProps { lang: string; name?: string; script?: string; - executeScript: (params: ExecuteScriptParams) => void; + executeScript: ( + params: ExecuteScriptParams + ) => { status: number; hits: { hits: any[] }; error?: any }; // todo +} + +interface AdditionalField { + value: string; + label: string; } interface TestScriptState { isLoading: boolean; - additionalFields: any[]; + additionalFields: AdditionalField[]; + previewData?: any; } export class TestScript extends Component { @@ -62,6 +70,7 @@ export class TestScript extends Component { state = { isLoading: false, additionalFields: [], + previewData: undefined, }; componentDidMount() { @@ -88,20 +97,18 @@ export class TestScript extends Component { query = esQuery.buildEsQuery( this.props.indexPattern, searchContext.query, - null, + [], esQueryConfigs ); } const scriptResponse = await executeScript({ - name, + name: name as string, lang, script, indexPatternTitle: indexPattern.title, query, - additionalFields: this.state.additionalFields.map(option => { - return option.value; - }), + additionalFields: this.state.additionalFields.map((option: AdditionalField) => option.value), }); if (scriptResponse.status !== 200) { @@ -122,15 +129,14 @@ export class TestScript extends Component { }); }; - onAdditionalFieldsChange = selectedOptions => { + onAdditionalFieldsChange = (selectedOptions: AdditionalField[]) => { this.setState({ additionalFields: selectedOptions, }); }; - renderPreview() { - const { previewData } = this.state; - + // todo + renderPreview(previewData: { error: any } | undefined) { if (!previewData) { return null; } @@ -225,7 +231,7 @@ export class TestScript extends Component { })} options={fields} selectedOptions={this.state.additionalFields} - onChange={this.onAdditionalFieldsChange} + onChange={selected => this.onAdditionalFieldsChange(selected as AdditionalField[])} data-test-subj="additionalFieldsSelect" fullWidth /> @@ -281,7 +287,7 @@ export class TestScript extends Component { {this.renderToolbar()} - {this.renderPreview()} + {this.renderPreview(this.state.previewData)} ); } diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index ae2dcd6c6414bd..83ed7b9d239bc6 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -119,7 +119,7 @@ export interface FieldEdiorProps { indexPattern: IndexPattern; field: Field; helpers: { - getConfig: () => any; + getConfig: (key: string) => any; getHttpStart: () => HttpStart; fieldFormatEditors: any; redirectAway: () => void; diff --git a/src/legacy/ui/public/field_editor/types.ts b/src/legacy/ui/public/field_editor/types.ts index 1e773bc10b436f..4cd40cafc79660 100644 --- a/src/legacy/ui/public/field_editor/types.ts +++ b/src/legacy/ui/public/field_editor/types.ts @@ -30,7 +30,7 @@ export interface ExecuteScriptParams { lang: string; script: string; indexPatternTitle: string; - query?: string; + query?: any; // todo additionalFields?: string[]; } diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 427c4f7864554d..35e6256648d4f3 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -460,6 +460,53 @@ export interface FetchOptions { searchStrategyId?: string; } +// Warning: (ae-missing-release-tag) "Field" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +class Field implements IFieldType { + // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts + // + // (undocumented) + $$spec: FieldSpec; + constructor(indexPattern: IndexPattern, spec: FieldSpec | Field, shortDotsEnable?: boolean); + // (undocumented) + aggregatable?: boolean; + // (undocumented) + count?: number; + // (undocumented) + displayName?: string; + // (undocumented) + esTypes?: string[]; + // (undocumented) + filterable?: boolean; + // (undocumented) + format: any; + // (undocumented) + indexPattern?: IndexPattern; + // (undocumented) + lang?: string; + // (undocumented) + name: string; + // (undocumented) + script?: string; + // (undocumented) + scripted?: boolean; + // (undocumented) + searchable?: boolean; + // (undocumented) + sortable?: boolean; + // (undocumented) + subType?: IFieldSubType; + // (undocumented) + type: string; + // (undocumented) + visualizable?: boolean; +} + +export { Field } + +export { Field as IndexPatternField } + // Warning: (ae-missing-release-tag) "FieldFormatConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -834,17 +881,17 @@ export class IndexPattern implements IIndexPattern { }[]; }; // (undocumented) - getFieldByName(name: string): IndexPatternField | void; + getFieldByName(name: string): Field | void; // (undocumented) - getNonScriptedFields(): IndexPatternField[]; + getNonScriptedFields(): Field[]; // (undocumented) - getScriptedFields(): IndexPatternField[]; + getScriptedFields(): Field[]; // (undocumented) getSourceFiltering(): { excludes: any[]; }; // (undocumented) - getTimeField(): IndexPatternField | undefined; + getTimeField(): Field | undefined; // (undocumented) id?: string; // (undocumented) @@ -921,58 +968,15 @@ export interface IndexPatternAttributes { typeMeta: string; } -// Warning: (ae-missing-release-tag) "Field" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export class IndexPatternField implements IFieldType { - // Warning: (ae-forgotten-export) The symbol "FieldSpec" needs to be exported by the entry point index.d.ts - // - // (undocumented) - $$spec: FieldSpec; - constructor(indexPattern: IndexPattern, spec: FieldSpec | IndexPatternField, shortDotsEnable?: boolean); - // (undocumented) - aggregatable?: boolean; - // (undocumented) - count?: number; - // (undocumented) - displayName?: string; - // (undocumented) - esTypes?: string[]; - // (undocumented) - filterable?: boolean; - // (undocumented) - format: any; - // (undocumented) - indexPattern?: IndexPattern; - // (undocumented) - lang?: string; - // (undocumented) - name: string; - // (undocumented) - script?: string; - // (undocumented) - scripted?: boolean; - // (undocumented) - searchable?: boolean; - // (undocumented) - sortable?: boolean; - // (undocumented) - subType?: IFieldSubType; - // (undocumented) - type: string; - // (undocumented) - visualizable?: boolean; -} - // Warning: (ae-missing-release-tag) "FieldList" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export class IndexPatternFieldList extends Array implements IFieldList { +export class IndexPatternFieldList extends Array implements IFieldList { constructor(indexPattern: IndexPattern, specs?: FieldSpec[], shortDotsEnable?: boolean); // (undocumented) add: (field: Record) => void; // (undocumented) - getByName: (name: string) => IndexPatternField | undefined; + getByName: (name: string) => Field | undefined; // (undocumented) getByType: (type: string) => any[]; // (undocumented) @@ -1874,21 +1878,21 @@ export type TSearchStrategyProvider = (context: ISearc // src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:382:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:387:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:399:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:383:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:388:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:400:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts // src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromEvent" needs to be exported by the entry point index.d.ts From 2010228172bcc94c755fff141163ca228df91576 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 20 Apr 2020 23:37:48 -0500 Subject: [PATCH 04/20] fix field format editor --- .../field_format_editor/field_format_editor.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx index 2b939b4c0c0229..36a9a5a255923d 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/field_format_editor.tsx @@ -38,13 +38,20 @@ interface EditorComponentProps { } interface FieldFormatEditorState { - EditorComponent?: React.FC; + EditorComponent: React.FC; } export class FieldFormatEditor extends PureComponent< FieldFormatEditorProps, FieldFormatEditorState > { + constructor(props: FieldFormatEditorProps) { + super(props); + this.state = { + EditorComponent: props.fieldFormatEditors.byFormatId[props.fieldFormatId], + }; + } + static getDerivedStateFromProps(nextProps: FieldFormatEditorProps) { return { EditorComponent: nextProps.fieldFormatEditors.byFormatId[nextProps.fieldFormatId] || null, From 32c277f449d94a07f2f5416956b82b48b060b1bb Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 21 Apr 2020 07:52:42 -0500 Subject: [PATCH 05/20] merge --- .../data/public/kibana-plugin-plugins-data-public.search.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md index 78ac05b9fd3861..9a22339fd05307 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.search.md @@ -27,8 +27,9 @@ search: { InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError; InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError; isDateHistogramBucketAggConfig: typeof isDateHistogramBucketAggConfig; + isNumberType: (agg: import("./search").AggConfig) => boolean; isStringType: (agg: import("./search").AggConfig) => boolean; - isType: (type: string) => (agg: import("./search").AggConfig) => boolean; + isType: (...types: string[]) => (agg: import("./search").AggConfig) => boolean; isValidEsInterval: typeof isValidEsInterval; isValidInterval: typeof isValidInterval; parentPipelineType: string; From f604c33526b19cd13e6e59503b7951e6326da872 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Tue, 21 Apr 2020 10:41:38 -0500 Subject: [PATCH 06/20] revert use of enum for converter type --- .../field_format_editor/editors/default/default.tsx | 8 +++----- .../components/field_format_editor/editors/url/url.tsx | 4 +--- .../components/field_format_editor/samples/samples.tsx | 8 ++++---- src/legacy/ui/public/field_editor/types.ts | 5 ----- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx index 599728b48d2e2e..0a1c9766170cba 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx @@ -20,7 +20,7 @@ import React, { PureComponent, ReactText } from 'react'; import { i18n } from '@kbn/i18n'; -import { Sample, ConverterType } from '../../../../types'; +import { Sample } from '../../../../types'; export const convertSampleInput = ( converter: (input: string | number | Array) => string, @@ -64,7 +64,7 @@ export interface FormatEditorProps

{ export interface FormatEditorState { sampleInputs: ReactText[]; - sampleConverterType?: ConverterType; + sampleConverterType?: string; error: any; samples: Sample[]; sampleInputsByType: SampleInputs; @@ -72,7 +72,7 @@ export interface FormatEditorState { export const defaultState = { sampleInputs: [] as ReactText[], - sampleConverterType: ConverterType.TEXT, + sampleConverterType: 'text', error: null, samples: [] as Sample[], sampleInputsByType: {}, @@ -91,9 +91,7 @@ export class DefaultFormatEditor

extends PureComponent< const converter = format.getConverterFor(sampleConverterType); const type = typeof sampleInputsByType === 'object' && formatParams.type; const inputs = type ? sampleInputsByType[formatParams.type as string] || [] : sampleInputs; - // console.log('inputs', inputs); const output = convertSampleInput(converter, inputs); - // console.log('getDerivedStateFromProps', nextProps, state); onError(output.error); return output; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx index c81b2c8830cdfb..73a130d442eb0f 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/url.tsx @@ -37,8 +37,6 @@ import { LabelTemplateFlyout } from './label_template_flyout'; import { UrlTemplateFlyout } from './url_template_flyout'; -import { ConverterType } from '../../../../types'; - import './icons'; interface OnChangeParam { @@ -84,7 +82,7 @@ export class UrlFormatEditor extends DefaultFormatEditor< img: ['go', 'stop', ['de', 'ne', 'us', 'ni'], 'cv'], audio: ['hello.mp3'], }, - sampleConverterType: ConverterType.HTML, + sampleConverterType: 'html', showUrlTemplateHelp: false, showLabelTemplateHelp: false, }; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx index b11de6e9e52f59..1c63caeb14d403 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx @@ -23,16 +23,16 @@ import { EuiBasicTable, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { Sample, ConverterType } from '../../../types'; +import { Sample } from '../../../types'; interface FormatEditorSamplesProps { samples: Sample[]; - sampleType: ConverterType; + sampleType: string; } export class FormatEditorSamples extends PureComponent { static defaultProps = { - sampleType: ConverterType.TEXT, + sampleType: 'text', }; render() { @@ -54,7 +54,7 @@ export class FormatEditorSamples extends PureComponent defaultMessage: 'Output', }), render: (output: string) => { - return sampleType === ConverterType.HTML ? ( + return sampleType === 'html' ? (

Date: Wed, 22 Apr 2020 11:22:44 -0500 Subject: [PATCH 07/20] less any --- .../kibana-plugin-plugins-data-public.md | 2 + .../editors/default/default.tsx | 18 +- .../editors/duration/duration.tsx | 8 +- .../field_format_editor.tsx | 4 +- .../field_format_editor/samples/samples.tsx | 2 +- .../components/scripting_help/help_flyout.tsx | 4 +- .../components/scripting_help/test_script.tsx | 12 +- .../ui/public/field_editor/field_editor.tsx | 2 +- .../field_editor/lib/validate_script.ts | 10 +- src/legacy/ui/public/field_editor/types.ts | 12 +- .../data/common/field_formats/field_format.ts | 4 +- src/plugins/data/public/index.ts | 3 + src/plugins/data/public/public.api.md | 154 +++++++++++++----- 13 files changed, 165 insertions(+), 70 deletions(-) diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index 3713827f75386d..564e092d046fa1 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -11,7 +11,9 @@ | [AggParamType](./kibana-plugin-plugins-data-public.aggparamtype.md) | | | [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) | A registry to store which are used to filter down available fields for a specific visualization and . | | [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) | A registry to store which are used to filter down available aggregations for a specific visualization and . | +| [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) | | | [Field](./kibana-plugin-plugins-data-public.field.md) | | +| [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) | | | [FilterManager](./kibana-plugin-plugins-data-public.filtermanager.md) | | | [IndexPattern](./kibana-plugin-plugins-data-public.indexpattern.md) | | | [IndexPatternFieldList](./kibana-plugin-plugins-data-public.indexpatternfieldlist.md) | | diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx index 0a1c9766170cba..ff29426d16513d 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx @@ -20,13 +20,15 @@ import React, { PureComponent, ReactText } from 'react'; import { i18n } from '@kbn/i18n'; +import { FieldFormat, FieldFormatsContentType } from 'src/plugins/data/public'; import { Sample } from '../../../../types'; +import { FieldFormatEditorProps } from '../../field_format_editor'; export const convertSampleInput = ( converter: (input: string | number | Array) => string, inputs: Array> ) => { - let error = null; + let error; let samples: Sample[] = []; try { @@ -54,17 +56,19 @@ interface SampleInputs { } export interface FormatEditorProps

{ - fieldType: string; // todo change to enum - format: any; // todo DecoratedFieldFormat - formatParams: { type?: string } & P; // todo + fieldType: string; + format: FieldFormat; + formatParams: { type?: string } & P; onChange: (newParams: any) => void; // todo - onError: (error: any) => void; // todo + // onChange: FieldFormatEditorProps['onChange']; + // onError: (error: any) => void; // todo + onError: FieldFormatEditorProps['onError']; basePath: string; } export interface FormatEditorState { sampleInputs: ReactText[]; - sampleConverterType?: string; + sampleConverterType: FieldFormatsContentType; error: any; samples: Sample[]; sampleInputsByType: SampleInputs; @@ -72,7 +76,7 @@ export interface FormatEditorState { export const defaultState = { sampleInputs: [] as ReactText[], - sampleConverterType: 'text', + sampleConverterType: 'text' as FieldFormatsContentType, error: null, samples: [] as Sample[], sampleInputsByType: {}, diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx index 291992503a7a51..96fd845e3caee2 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx @@ -18,6 +18,7 @@ */ import React, { Fragment } from 'react'; +import { DurationFormat } from 'src/plugins/data/public'; import { EuiFieldNumber, EuiFormRow, EuiSelect } from '@elastic/eui'; @@ -70,7 +71,10 @@ export class DurationFormatEditor extends DefaultFormatEditor< const output = super.getDerivedStateFromProps(nextProps, state); let error = null; - if (!nextProps.format.isHuman() && nextProps.formatParams.outputPrecision > 20) { + if ( + !(nextProps.format as DurationFormat).isHuman() && + nextProps.formatParams.outputPrecision > 20 + ) { error = i18n.translate('common.ui.fieldEditor.durationErrorMessage', { defaultMessage: 'Decimal places must be between 0 and 20', }); @@ -141,7 +145,7 @@ export class DurationFormatEditor extends DefaultFormatEditor< isInvalid={!!error} /> - {!format.isHuman() ? ( + {!(format as DurationFormat).isHuman() ? ( void; // todo define next to caller - onError: (error: string) => void; + onError: (error?: string) => void; } interface EditorComponentProps { diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx index 1c63caeb14d403..d63674bf4d2053 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.tsx @@ -44,7 +44,7 @@ export class FormatEditorSamples extends PureComponent name: i18n.translate('common.ui.fieldEditor.samples.inputHeader', { defaultMessage: 'Input', }), - render: (input: any) => { + render: (input: {} | string) => { return typeof input === 'object' ? JSON.stringify(input) : input; }, }, diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx index 7664007d3d440a..2b1ed3895dee9f 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx @@ -25,14 +25,14 @@ import { ScriptingSyntax } from './scripting_syntax'; import { TestScript } from './test_script'; import { IndexPattern } from '../../../../../../plugins/data/public'; -import { ExecuteScriptParams } from '../../types'; +import { ExecuteScript } from '../../types'; interface ScriptingHelpFlyoutProps { indexPattern: IndexPattern; lang: string; name?: string; script?: string; - executeScript: (params: ExecuteScriptParams) => void; + executeScript: ExecuteScript; isVisible: boolean; onClose: () => void; } diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx index b9d2e3d3bef216..19a3395e4599dc 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx @@ -38,17 +38,15 @@ const { SearchBar } = npStart.plugins.data.ui; const { uiSettings } = npStart.core; -import { esQuery, IndexPattern } from '../../../../../../plugins/data/public'; -import { ExecuteScriptParams } from '../../types'; +import { esQuery, IndexPattern, Query } from '../../../../../../plugins/data/public'; +import { ExecuteScript } from '../../types'; interface TestScriptProps { indexPattern: IndexPattern; lang: string; name?: string; script?: string; - executeScript: ( - params: ExecuteScriptParams - ) => { status: number; hits: { hits: any[] }; error?: any }; // todo + executeScript: ExecuteScript; } interface AdditionalField { @@ -80,7 +78,7 @@ export class TestScript extends Component { } // todo type this - previewScript = async (searchContext?: any) => { + previewScript = async (searchContext?: { query?: Query | undefined }) => { const { indexPattern, lang, name, script, executeScript } = this.props; if (!script || script.length === 0) { @@ -96,7 +94,7 @@ export class TestScript extends Component { const esQueryConfigs = esQuery.getEsQueryConfig(uiSettings); query = esQuery.buildEsQuery( this.props.indexPattern, - searchContext.query, + searchContext.query || [], [], esQueryConfigs ); diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 83ed7b9d239bc6..9e9071dd6241bc 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -241,7 +241,7 @@ export class FieldEditor extends PureComponent { + onFormatParamsError = (error?: string) => { this.setState({ hasFormatError: !!error, }); diff --git a/src/legacy/ui/public/field_editor/lib/validate_script.ts b/src/legacy/ui/public/field_editor/lib/validate_script.ts index 1f9e6c0768545f..5a0561f914058d 100644 --- a/src/legacy/ui/public/field_editor/lib/validate_script.ts +++ b/src/legacy/ui/public/field_editor/lib/validate_script.ts @@ -18,7 +18,8 @@ */ import { kfetch } from 'ui/kfetch'; -import { ExecuteScriptParams } from '../types'; +import { Query } from 'src/plugins/data/public'; +import { ExecuteScriptParams, ExecuteScriptResult } from '../types'; export const executeScript = async ({ name, @@ -27,7 +28,7 @@ export const executeScript = async ({ indexPatternTitle, query, additionalFields = [], -}: ExecuteScriptParams) => { +}: ExecuteScriptParams): Promise => { // Using _msearch because _search with index name in path dorks everything up const header = { index: indexPatternTitle, @@ -37,7 +38,7 @@ export const executeScript = async ({ const search = { query: { match_all: {}, - }, + } as Query['query'], script_fields: { [name]: { script: { @@ -46,17 +47,16 @@ export const executeScript = async ({ }, }, }, + _source: undefined as string[] | undefined, size: 10, timeout: '30s', }; if (additionalFields.length > 0) { - // @ts-ignore search._source = additionalFields; } if (query) { - // @ts-ignore search.query = query; } diff --git a/src/legacy/ui/public/field_editor/types.ts b/src/legacy/ui/public/field_editor/types.ts index dfb716cec688cf..326f2a7ba4b8dd 100644 --- a/src/legacy/ui/public/field_editor/types.ts +++ b/src/legacy/ui/public/field_editor/types.ts @@ -18,18 +18,26 @@ */ import { ReactText } from 'react'; +import { Query } from 'src/plugins/data/public'; export interface Sample { input: ReactText | ReactText[]; output: string; } -// incomplete export interface ExecuteScriptParams { name: string; lang: string; script: string; indexPatternTitle: string; - query?: any; // todo + query?: Query['query']; additionalFields?: string[]; } + +export interface ExecuteScriptResult { + status: number; + hits: { hits: any[] }; + error?: any; +} + +export type ExecuteScript = (params: ExecuteScriptParams) => Promise; diff --git a/src/plugins/data/common/field_formats/field_format.ts b/src/plugins/data/common/field_formats/field_format.ts index 49baa8c074da8e..693301c36350d5 100644 --- a/src/plugins/data/common/field_formats/field_format.ts +++ b/src/plugins/data/common/field_formats/field_format.ts @@ -127,12 +127,12 @@ export abstract class FieldFormat { */ getConverterFor( contentType: FieldFormatsContentType = DEFAULT_CONTEXT_TYPE - ): FieldFormatConvertFunction | null { + ): FieldFormatConvertFunction { if (!this.convertObject) { this.convertObject = this.setupContentType(); } - return this.convertObject[contentType] || null; + return this.convertObject[contentType]; } /** diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 4fa6b506ea5960..e119d0ecdb7798 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -170,6 +170,8 @@ import { serializeFieldFormat, } from '../common/field_formats'; +export { DurationFormat }; + import { DateFormat } from './field_formats'; export { baseFormattersPublic } from './field_formats'; @@ -209,6 +211,7 @@ export { FieldFormatsGetConfigFn, FieldFormatConfig, FieldFormatId, + FieldFormat, } from '../common'; /* diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index f19a509209491b..63d16c45044358 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -285,6 +285,44 @@ export interface DateRangeKey { to: number; } +// Warning: (ae-missing-release-tag) "DurationFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export class DurationFormat extends FieldFormat { + // (undocumented) + allowsNumericalAggregations: boolean; + // (undocumented) + static fieldType: KBN_FIELD_TYPES; + // (undocumented) + getParamDefaults(): { + inputFormat: string; + outputFormat: string; + outputPrecision: number; + }; + // Warning: (ae-forgotten-export) The symbol "FIELD_FORMAT_IDS" needs to be exported by the entry point index.d.ts + // + // (undocumented) + static id: FIELD_FORMAT_IDS; + // (undocumented) + static inputFormats: { + text: string; + kind: string; + }[]; + // (undocumented) + isHuman(): boolean; + // (undocumented) + static outputFormats: { + text: string; + method: string; + }[]; + // Warning: (ae-forgotten-export) The symbol "TextContextTypeConvert" needs to be exported by the entry point index.d.ts + // + // (undocumented) + textConvert: TextContextTypeConvert; + // (undocumented) + static title: string; +} + // @public (undocumented) export enum ES_FIELD_TYPES { // (undocumented) @@ -507,6 +545,47 @@ export { Field } export { Field as IndexPatternField } +// Warning: (ae-missing-release-tag) "FieldFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export abstract class FieldFormat { + // Warning: (ae-forgotten-export) The symbol "IFieldFormatMetaParams" needs to be exported by the entry point index.d.ts + constructor(_params?: IFieldFormatMetaParams, getConfig?: FieldFormatsGetConfigFn); + // Warning: (ae-forgotten-export) The symbol "HtmlContextTypeOptions" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "TextContextTypeOptions" needs to be exported by the entry point index.d.ts + convert(value: any, contentType?: FieldFormatsContentType, options?: HtmlContextTypeOptions | TextContextTypeOptions): string; + // Warning: (ae-forgotten-export) The symbol "FieldFormatConvert" needs to be exported by the entry point index.d.ts + convertObject: FieldFormatConvert | undefined; + static fieldType: string | string[]; + // Warning: (ae-forgotten-export) The symbol "IFieldFormatType" needs to be exported by the entry point index.d.ts + // + // (undocumented) + static from(convertFn: FieldFormatConvertFunction): IFieldFormatType; + // (undocumented) + protected getConfig: FieldFormatsGetConfigFn | undefined; + // Warning: (ae-forgotten-export) The symbol "FieldFormatConvertFunction" needs to be exported by the entry point index.d.ts + getConverterFor(contentType?: FieldFormatsContentType): FieldFormatConvertFunction; + getParamDefaults(): Record; + // Warning: (ae-forgotten-export) The symbol "HtmlContextTypeConvert" needs to be exported by the entry point index.d.ts + htmlConvert: HtmlContextTypeConvert | undefined; + static id: string; + // (undocumented) + static isInstanceOfFieldFormat(fieldFormat: any): fieldFormat is FieldFormat; + param(name: string): any; + params(): Record; + // (undocumented) + protected readonly _params: any; + // (undocumented) + setupContentType(): FieldFormatConvert; + textConvert: TextContextTypeConvert | undefined; + static title: string; + toJSON(): { + id: unknown; + params: _.Dictionary | undefined; + }; + type: any; +} + // Warning: (ae-missing-release-tag) "FieldFormatConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -519,7 +598,6 @@ export interface FieldFormatConfig { params: Record; } -// Warning: (ae-forgotten-export) The symbol "FIELD_FORMAT_IDS" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "FieldFormatId" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -1856,44 +1934,42 @@ export type TSearchStrategyProvider = (context: ISearc // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "getEsQueryConfig" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "luceneStringToDsl" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "decorateQuery" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "FieldFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "DateNanosFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:234:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:407:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:415:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "DateNanosFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:387:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:387:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:387:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:387:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:395:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:406:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:414:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:415:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:418:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts // src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromEvent" needs to be exported by the entry point index.d.ts From 3983dff2707640fb15be837a9323a0346514a2f8 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 22 Apr 2020 11:23:47 -0500 Subject: [PATCH 08/20] less any --- ...ationformat.allowsnumericalaggregations.md | 11 +++++ ...ns-data-public.durationformat.fieldtype.md | 11 +++++ ...-public.durationformat.getparamdefaults.md | 23 ++++++++++ ...n-plugins-data-public.durationformat.id.md | 11 +++++ ...data-public.durationformat.inputformats.md | 14 ++++++ ...gins-data-public.durationformat.ishuman.md | 15 ++++++ ...ugin-plugins-data-public.durationformat.md | 31 +++++++++++++ ...ata-public.durationformat.outputformats.md | 14 ++++++ ...-data-public.durationformat.textconvert.md | 11 +++++ ...lugins-data-public.durationformat.title.md | 11 +++++ ...s-data-public.fieldformat._constructor_.md | 21 +++++++++ ...plugins-data-public.fieldformat._params.md | 11 +++++ ...plugins-data-public.fieldformat.convert.md | 26 +++++++++++ ...s-data-public.fieldformat.convertobject.md | 13 ++++++ ...ugins-data-public.fieldformat.fieldtype.md | 13 ++++++ ...in-plugins-data-public.fieldformat.from.md | 22 +++++++++ ...ugins-data-public.fieldformat.getconfig.md | 11 +++++ ...data-public.fieldformat.getconverterfor.md | 24 ++++++++++ ...ata-public.fieldformat.getparamdefaults.md | 17 +++++++ ...ins-data-public.fieldformat.htmlconvert.md | 13 ++++++ ...ugin-plugins-data-public.fieldformat.id.md | 13 ++++++ ...lic.fieldformat.isinstanceoffieldformat.md | 22 +++++++++ ...-plugin-plugins-data-public.fieldformat.md | 46 +++++++++++++++++++ ...n-plugins-data-public.fieldformat.param.md | 24 ++++++++++ ...-plugins-data-public.fieldformat.params.md | 17 +++++++ ...ata-public.fieldformat.setupcontenttype.md | 15 ++++++ ...ins-data-public.fieldformat.textconvert.md | 13 ++++++ ...n-plugins-data-public.fieldformat.title.md | 13 ++++++ ...-plugins-data-public.fieldformat.tojson.md | 25 ++++++++++ ...in-plugins-data-public.fieldformat.type.md | 13 ++++++ 30 files changed, 524 insertions(+) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._constructor_.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._params.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convert.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convertobject.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.fieldtype.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.from.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconfig.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.id.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.param.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.params.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.textconvert.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.title.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.tojson.md create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.type.md diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md new file mode 100644 index 00000000000000..3215ecf9283087 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [allowsNumericalAggregations](./kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md) + +## DurationFormat.allowsNumericalAggregations property + +Signature: + +```typescript +allowsNumericalAggregations: boolean; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md new file mode 100644 index 00000000000000..848df3222d0aa7 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [fieldType](./kibana-plugin-plugins-data-public.durationformat.fieldtype.md) + +## DurationFormat.fieldType property + +Signature: + +```typescript +static fieldType: KBN_FIELD_TYPES; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md new file mode 100644 index 00000000000000..8d05f92eecbacf --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [getParamDefaults](./kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md) + +## DurationFormat.getParamDefaults() method + +Signature: + +```typescript +getParamDefaults(): { + inputFormat: string; + outputFormat: string; + outputPrecision: number; + }; +``` +Returns: + +`{ + inputFormat: string; + outputFormat: string; + outputPrecision: number; + }` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md new file mode 100644 index 00000000000000..e7459846c86861 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [id](./kibana-plugin-plugins-data-public.durationformat.id.md) + +## DurationFormat.id property + +Signature: + +```typescript +static id: FIELD_FORMAT_IDS; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md new file mode 100644 index 00000000000000..8733ee8e2857d9 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [inputFormats](./kibana-plugin-plugins-data-public.durationformat.inputformats.md) + +## DurationFormat.inputFormats property + +Signature: + +```typescript +static inputFormats: { + text: string; + kind: string; + }[]; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md new file mode 100644 index 00000000000000..c916168251f396 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [isHuman](./kibana-plugin-plugins-data-public.durationformat.ishuman.md) + +## DurationFormat.isHuman() method + +Signature: + +```typescript +isHuman(): boolean; +``` +Returns: + +`boolean` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md new file mode 100644 index 00000000000000..a6f4a1c903c78a --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md @@ -0,0 +1,31 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) + +## DurationFormat class + +Signature: + +```typescript +export declare class DurationFormat extends FieldFormat +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [allowsNumericalAggregations](./kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md) | | boolean | | +| [fieldType](./kibana-plugin-plugins-data-public.durationformat.fieldtype.md) | static | KBN_FIELD_TYPES | | +| [id](./kibana-plugin-plugins-data-public.durationformat.id.md) | static | FIELD_FORMAT_IDS | | +| [inputFormats](./kibana-plugin-plugins-data-public.durationformat.inputformats.md) | static | {
text: string;
kind: string;
}[] | | +| [outputFormats](./kibana-plugin-plugins-data-public.durationformat.outputformats.md) | static | {
text: string;
method: string;
}[] | | +| [textConvert](./kibana-plugin-plugins-data-public.durationformat.textconvert.md) | | TextContextTypeConvert | | +| [title](./kibana-plugin-plugins-data-public.durationformat.title.md) | static | string | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getParamDefaults()](./kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md) | | | +| [isHuman()](./kibana-plugin-plugins-data-public.durationformat.ishuman.md) | | | + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md new file mode 100644 index 00000000000000..555f6a453a3354 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md @@ -0,0 +1,14 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [outputFormats](./kibana-plugin-plugins-data-public.durationformat.outputformats.md) + +## DurationFormat.outputFormats property + +Signature: + +```typescript +static outputFormats: { + text: string; + method: string; + }[]; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md new file mode 100644 index 00000000000000..56da40f2be3eec --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [textConvert](./kibana-plugin-plugins-data-public.durationformat.textconvert.md) + +## DurationFormat.textConvert property + +Signature: + +```typescript +textConvert: TextContextTypeConvert; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md new file mode 100644 index 00000000000000..b20aa0c7c0e2f8 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [title](./kibana-plugin-plugins-data-public.durationformat.title.md) + +## DurationFormat.title property + +Signature: + +```typescript +static title: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._constructor_.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._constructor_.md new file mode 100644 index 00000000000000..e38da6600696c9 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._constructor_.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [(constructor)](./kibana-plugin-plugins-data-public.fieldformat._constructor_.md) + +## FieldFormat.(constructor) + +Constructs a new instance of the `FieldFormat` class + +Signature: + +```typescript +constructor(_params?: IFieldFormatMetaParams, getConfig?: FieldFormatsGetConfigFn); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| \_params | IFieldFormatMetaParams | | +| getConfig | FieldFormatsGetConfigFn | | + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._params.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._params.md new file mode 100644 index 00000000000000..ac3f256a9afc30 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat._params.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [\_params](./kibana-plugin-plugins-data-public.fieldformat._params.md) + +## FieldFormat.\_params property + +Signature: + +```typescript +protected readonly _params: any; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convert.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convert.md new file mode 100644 index 00000000000000..0535585cb4718c --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convert.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [convert](./kibana-plugin-plugins-data-public.fieldformat.convert.md) + +## FieldFormat.convert() method + +Convert a raw value to a formatted string + +Signature: + +```typescript +convert(value: any, contentType?: FieldFormatsContentType, options?: HtmlContextTypeOptions | TextContextTypeOptions): string; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| value | any | | +| contentType | FieldFormatsContentType | | +| options | HtmlContextTypeOptions | TextContextTypeOptions | | + +Returns: + +`string` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convertobject.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convertobject.md new file mode 100644 index 00000000000000..436124ac083871 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.convertobject.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [convertObject](./kibana-plugin-plugins-data-public.fieldformat.convertobject.md) + +## FieldFormat.convertObject property + + {FieldFormatConvert} have to remove the private because of https://github.com/Microsoft/TypeScript/issues/17293 + +Signature: + +```typescript +convertObject: FieldFormatConvert | undefined; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.fieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.fieldtype.md new file mode 100644 index 00000000000000..1d109a599d2d9c --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.fieldtype.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [fieldType](./kibana-plugin-plugins-data-public.fieldformat.fieldtype.md) + +## FieldFormat.fieldType property + + {string} - Field Format Type + +Signature: + +```typescript +static fieldType: string | string[]; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.from.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.from.md new file mode 100644 index 00000000000000..ee4f76830ea42d --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.from.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [from](./kibana-plugin-plugins-data-public.fieldformat.from.md) + +## FieldFormat.from() method + +Signature: + +```typescript +static from(convertFn: FieldFormatConvertFunction): IFieldFormatType; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| convertFn | FieldFormatConvertFunction | | + +Returns: + +`IFieldFormatType` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconfig.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconfig.md new file mode 100644 index 00000000000000..446e0c237ce132 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconfig.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [getConfig](./kibana-plugin-plugins-data-public.fieldformat.getconfig.md) + +## FieldFormat.getConfig property + +Signature: + +```typescript +protected getConfig: FieldFormatsGetConfigFn | undefined; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md new file mode 100644 index 00000000000000..f4eeb5eed06a09 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [getConverterFor](./kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md) + +## FieldFormat.getConverterFor() method + +Get a convert function that is bound to a specific contentType + +Signature: + +```typescript +getConverterFor(contentType?: FieldFormatsContentType): FieldFormatConvertFunction; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| contentType | FieldFormatsContentType | | + +Returns: + +`FieldFormatConvertFunction` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md new file mode 100644 index 00000000000000..59afdc25df350a --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [getParamDefaults](./kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md) + +## FieldFormat.getParamDefaults() method + +Get parameter defaults {object} - parameter defaults + +Signature: + +```typescript +getParamDefaults(): Record; +``` +Returns: + +`Record` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md new file mode 100644 index 00000000000000..945ac7ededff64 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [htmlConvert](./kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md) + +## FieldFormat.htmlConvert property + + {htmlConvert} have to remove the protected because of https://github.com/Microsoft/TypeScript/issues/17293 + +Signature: + +```typescript +htmlConvert: HtmlContextTypeConvert | undefined; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.id.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.id.md new file mode 100644 index 00000000000000..91c3ff4f2d9a30 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.id.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [id](./kibana-plugin-plugins-data-public.fieldformat.id.md) + +## FieldFormat.id property + + {string} - Field Format Id + +Signature: + +```typescript +static id: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md new file mode 100644 index 00000000000000..c6afa27fe59528 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [isInstanceOfFieldFormat](./kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md) + +## FieldFormat.isInstanceOfFieldFormat() method + +Signature: + +```typescript +static isInstanceOfFieldFormat(fieldFormat: any): fieldFormat is FieldFormat; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fieldFormat | any | | + +Returns: + +`fieldFormat is FieldFormat` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.md new file mode 100644 index 00000000000000..b53e301c46c1cf --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.md @@ -0,0 +1,46 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) + +## FieldFormat class + +Signature: + +```typescript +export declare abstract class FieldFormat +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(\_params, getConfig)](./kibana-plugin-plugins-data-public.fieldformat._constructor_.md) | | Constructs a new instance of the FieldFormat class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [\_params](./kibana-plugin-plugins-data-public.fieldformat._params.md) | | any | | +| [convertObject](./kibana-plugin-plugins-data-public.fieldformat.convertobject.md) | | FieldFormatConvert | undefined | {FieldFormatConvert} have to remove the private because of https://github.com/Microsoft/TypeScript/issues/17293 | +| [fieldType](./kibana-plugin-plugins-data-public.fieldformat.fieldtype.md) | static | string | string[] | {string} - Field Format Type | +| [getConfig](./kibana-plugin-plugins-data-public.fieldformat.getconfig.md) | | FieldFormatsGetConfigFn | undefined | | +| [htmlConvert](./kibana-plugin-plugins-data-public.fieldformat.htmlconvert.md) | | HtmlContextTypeConvert | undefined | {htmlConvert} have to remove the protected because of https://github.com/Microsoft/TypeScript/issues/17293 | +| [id](./kibana-plugin-plugins-data-public.fieldformat.id.md) | static | string | {string} - Field Format Id | +| [textConvert](./kibana-plugin-plugins-data-public.fieldformat.textconvert.md) | | TextContextTypeConvert | undefined | {textConvert} have to remove the protected because of https://github.com/Microsoft/TypeScript/issues/17293 | +| [title](./kibana-plugin-plugins-data-public.fieldformat.title.md) | static | string | {string} - Field Format Title | +| [type](./kibana-plugin-plugins-data-public.fieldformat.type.md) | | any | {Function} - ref to child class | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [convert(value, contentType, options)](./kibana-plugin-plugins-data-public.fieldformat.convert.md) | | Convert a raw value to a formatted string | +| [from(convertFn)](./kibana-plugin-plugins-data-public.fieldformat.from.md) | static | | +| [getConverterFor(contentType)](./kibana-plugin-plugins-data-public.fieldformat.getconverterfor.md) | | Get a convert function that is bound to a specific contentType | +| [getParamDefaults()](./kibana-plugin-plugins-data-public.fieldformat.getparamdefaults.md) | | Get parameter defaults {object} - parameter defaults | +| [isInstanceOfFieldFormat(fieldFormat)](./kibana-plugin-plugins-data-public.fieldformat.isinstanceoffieldformat.md) | static | | +| [param(name)](./kibana-plugin-plugins-data-public.fieldformat.param.md) | | Get the value of a param. This value may be a default value. | +| [params()](./kibana-plugin-plugins-data-public.fieldformat.params.md) | | Get all of the params in a single object {object} | +| [setupContentType()](./kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md) | | | +| [toJSON()](./kibana-plugin-plugins-data-public.fieldformat.tojson.md) | | Serialize this format to a simple POJO, with only the params that are not default {object} | + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.param.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.param.md new file mode 100644 index 00000000000000..1e7fd9d161429b --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.param.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [param](./kibana-plugin-plugins-data-public.fieldformat.param.md) + +## FieldFormat.param() method + +Get the value of a param. This value may be a default value. + +Signature: + +```typescript +param(name: string): any; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| name | string | | + +Returns: + +`any` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.params.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.params.md new file mode 100644 index 00000000000000..5825af4925d066 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.params.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [params](./kibana-plugin-plugins-data-public.fieldformat.params.md) + +## FieldFormat.params() method + +Get all of the params in a single object {object} + +Signature: + +```typescript +params(): Record; +``` +Returns: + +`Record` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md new file mode 100644 index 00000000000000..41f5f2446f22aa --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [setupContentType](./kibana-plugin-plugins-data-public.fieldformat.setupcontenttype.md) + +## FieldFormat.setupContentType() method + +Signature: + +```typescript +setupContentType(): FieldFormatConvert; +``` +Returns: + +`FieldFormatConvert` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.textconvert.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.textconvert.md new file mode 100644 index 00000000000000..57ccca9136081f --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.textconvert.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [textConvert](./kibana-plugin-plugins-data-public.fieldformat.textconvert.md) + +## FieldFormat.textConvert property + + {textConvert} have to remove the protected because of https://github.com/Microsoft/TypeScript/issues/17293 + +Signature: + +```typescript +textConvert: TextContextTypeConvert | undefined; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.title.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.title.md new file mode 100644 index 00000000000000..b19246758f080b --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.title.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [title](./kibana-plugin-plugins-data-public.fieldformat.title.md) + +## FieldFormat.title property + + {string} - Field Format Title + +Signature: + +```typescript +static title: string; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.tojson.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.tojson.md new file mode 100644 index 00000000000000..5fa7d4841537b9 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.tojson.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [toJSON](./kibana-plugin-plugins-data-public.fieldformat.tojson.md) + +## FieldFormat.toJSON() method + +Serialize this format to a simple POJO, with only the params that are not default + + {object} + +Signature: + +```typescript +toJSON(): { + id: unknown; + params: _.Dictionary | undefined; + }; +``` +Returns: + +`{ + id: unknown; + params: _.Dictionary | undefined; + }` + diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.type.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.type.md new file mode 100644 index 00000000000000..394a2e3cc9afbf --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.fieldformat.type.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) > [type](./kibana-plugin-plugins-data-public.fieldformat.type.md) + +## FieldFormat.type property + + {Function} - ref to child class + +Signature: + +```typescript +type: any; +``` From 4e5cfe6c4db17668f496accec0bab55498b0f478 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Wed, 22 Apr 2020 23:22:37 -0500 Subject: [PATCH 09/20] typescript tests, partial progress --- .../editors/bytes/bytes.test.tsx | 4 +- .../editors/color/color.test.tsx | 10 +++- .../editors/date/date.test.tsx | 4 +- ...date_nanos.test.js => date_nanos.test.tsx} | 12 +++- .../{default.test.js => default.test.tsx} | 15 ++--- .../editors/duration/duration.test.tsx | 17 ++++-- .../editors/number/number.test.tsx | 10 +++- .../{percent.test.js => percent.test.tsx} | 10 +++- ..._lookup.test.js => static_lookup.test.tsx} | 17 ++++-- .../editors/static_lookup/static_lookup.tsx | 2 +- .../editors/string/string.test.tsx | 10 +++- .../editors/truncate/truncate.test.tsx | 16 ++++-- .../editors/url/url.test.tsx | 29 +++++++--- .../field_format_editor.test.tsx | 5 +- .../field_format_editor.tsx | 9 +-- .../samples/samples.test.tsx | 2 +- .../warning_call_out.test.tsx | 2 +- .../scripting_help/help_flyout.test.tsx | 15 +++-- .../public/field_editor/field_editor.test.tsx | 24 ++++---- .../ui/public/field_editor/field_editor.tsx | 56 ++++++++++++++----- 20 files changed, 182 insertions(+), 87 deletions(-) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/{date_nanos.test.js => date_nanos.test.tsx} (83%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/{default.test.js => default.test.tsx} (91%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/{percent.test.js => percent.test.tsx} (84%) rename src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/{static_lookup.test.js => static_lookup.test.tsx} (74%) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx index 53928ebfbc6c88..40443ec2621823 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/bytes.test.tsx @@ -21,6 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { BytesFormatEditor } from './bytes'; +import { FieldFormat } from 'src/plugins/data/public'; const fieldType = 'number'; const format = { @@ -43,8 +44,9 @@ describe('BytesFormatEditor', () => { it('should render normally', async () => { const component = shallow( { it('should render string type normally (regex field)', async () => { const component = shallowWithI18nProvider( { it('should render other type normally (range field)', async () => { const component = shallowWithI18nProvider( { it('should render multiple colors', async () => { const component = shallowWithI18nProvider( { it('should render normally', async () => { const component = shallow( input => `converted date for ${input}`), + getConverterFor: jest + .fn() + .mockImplementation(() => (input: string) => `converted date for ${input}`), getParamDefaults: jest.fn().mockImplementation(() => { return { pattern: 'MMM D, YYYY @ HH:mm:ss.SSSSSSSSS' }; }), }; -const formatParams = {}; +const formatParams = { + pattern: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -41,8 +46,9 @@ describe('DateFormatEditor', () => { it('should render normally', async () => { const component = shallow( { describe('convertSampleInput', () => { - const converter = input => { + const converter = (input: number) => { if (isNaN(input)) { - throw { - message: 'Input is not a number', - }; + throw new Error('Input is not a number'); } else { - return input * 2; + return (input * 2).toString(); } }; @@ -70,6 +68,7 @@ describe('DefaultFormatEditor', () => { it('should render nothing', async () => { const component = shallow( { it('should call prop onChange()', async () => { const component = shallow( { /> ); - component.instance().onChange(); + (component.instance() as DefaultFormatEditor).onChange(); expect(onChange).toBeCalled(); }); it('should call prop onError() if converter throws an error', async () => { const newFormat = { getConverterFor: jest.fn().mockImplementation(() => () => { - throw { message: 'Test error message' }; + throw new Error('Test error message'); }), }; shallow( input => `converted duration for ${input}`), + getConverterFor: jest + .fn() + .mockImplementation(() => (input: string) => `converted duration for ${input}`), getParamDefaults: jest.fn().mockImplementation(() => { return { inputFormat: 'seconds', @@ -52,7 +55,11 @@ const format = { ], }, }; -const formatParams = {}; +const formatParams = { + outputPrecision: 2, + inputFormat: '', + outputFormat: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -64,8 +71,9 @@ describe('DurationFormatEditor', () => { it('should render human readable output normally', async () => { const component = shallow( { }; const component = shallow( input => input * 2), + getConverterFor: jest.fn().mockImplementation(() => (input: number) => input * 2), getParamDefaults: jest.fn().mockImplementation(() => { return { pattern: '0,0.[000]' }; }), }; -const formatParams = {}; +const formatParams = { + pattern: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -41,8 +44,9 @@ describe('NumberFormatEditor', () => { it('should render normally', async () => { const component = shallow( input => input * 2), + getConverterFor: jest.fn().mockImplementation(() => (input: number) => input * 2), getParamDefaults: jest.fn().mockImplementation(() => { return { pattern: '0,0.[000]%' }; }), }; -const formatParams = {}; +const formatParams = { + pattern: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -41,8 +44,9 @@ describe('PercentFormatEditor', () => { it('should render normally', async () => { const component = shallow( { it('should render normally', async () => { const component = shallowWithI18nProvider( { it('should render multiple lookup entries and unknown key value', async () => { const component = shallowWithI18nProvider( diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx index 7abe99015cfa9f..f998e271b6c999 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.tsx @@ -25,7 +25,7 @@ import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { DefaultFormatEditor } from '../default'; -interface StaticLookupFormatEditorFormatParams { +export interface StaticLookupFormatEditorFormatParams { lookupEntries: Array<{ key: string; value: string }>; unknownKeyValue: string; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx index 80334e3801e8bf..d0fa0935b26640 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/string/string.test.tsx @@ -19,12 +19,13 @@ import React from 'react'; import { shallow } from 'enzyme'; +import { FieldFormat } from 'src/plugins/data/public'; import { StringFormatEditor } from './string'; const fieldType = 'string'; const format = { - getConverterFor: jest.fn().mockImplementation(() => input => input.toUpperCase()), + getConverterFor: jest.fn().mockImplementation(() => (input: string) => input.toUpperCase()), getParamDefaults: jest.fn().mockImplementation(() => { return { transform: 'upper' }; }), @@ -37,7 +38,9 @@ const format = { ], }, }; -const formatParams = {}; +const formatParams = { + transform: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -49,8 +52,9 @@ describe('StringFormatEditor', () => { it('should render normally', async () => { const component = shallow( input => input.substring(0, 10)), + getConverterFor: jest.fn().mockImplementation(() => (input: string) => input.substring(0, 10)), getParamDefaults: jest.fn().mockImplementation(() => { return { fieldLength: 10 }; }), }; -const formatParams = {}; +const formatParams = { + fieldLength: 5, +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -47,8 +50,9 @@ describe('TruncateFormatEditor', () => { it('should render normally', async () => { const component = shallow( { it('should fire error, when input is invalid', async () => { const component = shallow( { it('should fire change, when input changed and is valid', async () => { const component = shallow( input => `converted url for ${input}`), + getConverterFor: jest + .fn() + .mockImplementation(() => (input: string) => `converted url for ${input}`), type: { urlTypes: [ { kind: 'a', text: 'Link' }, @@ -33,7 +36,13 @@ const format = { ], }, }; -const formatParams = {}; +const formatParams = { + openLinkInCurrentTab: true, + urlTemplate: '', + labelTemplate: '', + width: '', + height: '', +}; const onChange = jest.fn(); const onError = jest.fn(); @@ -49,8 +58,9 @@ describe('UrlFormatEditor', () => { it('should render normally', async () => { const component = shallow( { it('should render url template help', async () => { const component = shallow( ); - component.instance().showUrlTemplateHelp(); + (component.instance() as UrlFormatEditor).showUrlTemplateHelp(); component.update(); expect(component).toMatchSnapshot(); }); @@ -79,15 +90,16 @@ describe('UrlFormatEditor', () => { it('should render label template help', async () => { const component = shallow( ); - component.instance().showLabelTemplateHelp(); + (component.instance() as UrlFormatEditor).showLabelTemplateHelp(); component.update(); expect(component).toMatchSnapshot(); }); @@ -95,8 +107,9 @@ describe('UrlFormatEditor', () => { it('should render width and height fields if image', async () => { const component = shallow( { const component = shallow( { const component = shallow( void; // todo define next to caller + fieldFormatParams: { [key: string]: unknown }; + fieldFormatEditors: any; + onChange: (change: { fieldType: string; [key: string]: any }) => void; onError: (error?: string) => void; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx index 8e18f1f5f4de8b..01f405e9aff1f0 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/samples.test.tsx @@ -28,7 +28,7 @@ describe('FormatEditorSamples', () => { foo, bar' }, ]} /> diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx index 48094f63f8fe82..f39e8bffafab2d 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.test.tsx @@ -23,7 +23,7 @@ import { shallow } from 'enzyme'; import { ScriptingWarningCallOut } from './warning_call_out'; jest.mock('ui/documentation_links', () => ({ - getDocLink: doc => `(docLink for ${doc})`, + getDocLink: (doc: string) => `(docLink for ${doc})`, })); describe('ScriptingWarningCallOut', () => { diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx index 2fac8c7641ddb8..9937215e2b81b4 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx @@ -22,8 +22,12 @@ import { shallow } from 'enzyme'; import { ScriptingHelpFlyout } from './help_flyout'; +import { IndexPattern } from '../../../../../../plugins/data/public'; + +import { ExecuteScript } from '../../types'; + jest.mock('ui/documentation_links', () => ({ - getDocLink: doc => `(docLink for ${doc})`, + getDocLink: (doc: string) => `(docLink for ${doc})`, })); jest.mock('./test_script', () => ({ @@ -32,7 +36,7 @@ jest.mock('./test_script', () => ({ }, })); -const indexPatternMock = {}; +const indexPatternMock = {} as IndexPattern; describe('ScriptingHelpFlyout', () => { it('should render normally', async () => { @@ -41,7 +45,8 @@ describe('ScriptingHelpFlyout', () => { isVisible={true} indexPattern={indexPatternMock} lang="painless" - executeScript={() => {}} + executeScript={((() => {}) as unknown) as ExecuteScript} + onClose={() => {}} /> ); @@ -51,9 +56,11 @@ describe('ScriptingHelpFlyout', () => { it('should render nothing if not visible', async () => { const component = shallow( {}} + executeScript={((() => {}) as unknown) as ExecuteScript} + onClose={() => {}} /> ); diff --git a/src/legacy/ui/public/field_editor/field_editor.test.tsx b/src/legacy/ui/public/field_editor/field_editor.test.tsx index 7f62802fed8167..7a08c88552629e 100644 --- a/src/legacy/ui/public/field_editor/field_editor.test.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.test.tsx @@ -23,6 +23,7 @@ import React from 'react'; import { npStart } from 'ui/new_platform'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; +import { Field, IndexPattern } from 'src/plugins/data/public'; jest.mock('brace/mode/groovy', () => ({})); jest.mock('ui/new_platform'); @@ -71,18 +72,15 @@ jest.mock('./components/field_format_editor', () => ({ FieldFormatEditor: 'field-format-editor', })); -const fields = [ +const fields: Field[] = [ { name: 'foobar', - }, + } as Field, ]; -fields.getByName = name => { - const flds = { - foobar: { - name: 'foobar', - }, - }; - return flds[name]; + +// @ts-ignore +fields.getByName = (name: string) => { + return fields.find(field => field.name === name); }; class Format { @@ -107,7 +105,7 @@ const helpers = { }; describe('FieldEditor', () => { - let indexPattern; + let indexPattern: IndexPattern; beforeEach(() => { indexPattern = { @@ -138,7 +136,7 @@ describe('FieldEditor', () => { name: 'test', script: 'doc.test.value', }; - indexPattern.fields.push(testField); + indexPattern.fields.push(testField as Field); indexPattern.fields.getByName = name => { const flds = { [testField.name]: testField, @@ -186,7 +184,7 @@ describe('FieldEditor', () => { ); await new Promise(resolve => process.nextTick(resolve)); - component.instance().onFieldChange('name', 'foobar'); + (component.instance() as FieldEditor).onFieldChange('name', 'foobar'); component.update(); expect(component).toMatchSnapshot(); }); @@ -205,7 +203,7 @@ describe('FieldEditor', () => { ); await new Promise(resolve => process.nextTick(resolve)); - component.instance().onFieldChange('name', 'foobar'); + (component.instance() as FieldEditor).onFieldChange('name', 'foobar'); component.update(); expect(component).toMatchSnapshot(); }); diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 9e9071dd6241bc..520de13c57bdb2 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -55,7 +55,12 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { IndexPattern, IFieldType, KBN_FIELD_TYPES } from '../../../../plugins/data/public'; +import { + IndexPattern, + IFieldType, + KBN_FIELD_TYPES, + ES_FIELD_TYPES, +} from '../../../../plugins/data/public'; import { IFieldFormatType } from '../../../../plugins/data/common'; import { Field } from '../../../../plugins/data/public'; import { @@ -67,6 +72,8 @@ import { ScriptingHelpFlyout } from './components/scripting_help'; import { FieldFormatEditor } from './components/field_format_editor'; +import { DefaultFormatEditor } from './components/field_format_editor/editors/default'; + import { FIELD_TYPES_BY_LANG, DEFAULT_FIELD_TYPES } from './constants'; import { executeScript, isScriptValid } from './lib'; @@ -96,17 +103,30 @@ const getFieldTypeFormatsList = (field: IFieldType, defaultFieldFormat: IFieldFo ]; }; +interface FieldTypeFormat { + id: string; + title: string; +} + +interface InitialFieldTypeFormat extends FieldTypeFormat { + defaultFieldFormat: IFieldFormatType; +} + +interface FieldClone extends Field { + format: any; +} + export interface FieldEditorState { isReady: boolean; isCreating: boolean; isDeprecatedLang: boolean; scriptingLangs: string[]; - fieldTypes: any[]; // todo - fieldTypeFormats: any[]; + fieldTypes: string[]; + fieldTypeFormats: FieldTypeFormat[]; existingFieldNames: string[]; - field: any; + field: FieldClone; fieldFormatId?: string; - fieldFormatParams: any; + fieldFormatParams: { [key: string]: unknown }; showScriptingHelp: boolean; showDeleteModal: boolean; hasFormatError: boolean; @@ -121,7 +141,7 @@ export interface FieldEdiorProps { helpers: { getConfig: (key: string) => any; getHttpStart: () => HttpStart; - fieldFormatEditors: any; + fieldFormatEditors: DefaultFormatEditor[]; redirectAway: () => void; }; } @@ -167,18 +187,21 @@ export class FieldEditor extends PureComponent f.name === field.name), - isDeprecatedLang: this.deprecatedLangs.includes(field.lang), + isDeprecatedLang: this.deprecatedLangs.includes(field.lang || ''), errors: [], scriptingLangs, fieldTypes, @@ -190,6 +213,7 @@ export class FieldEditor extends PureComponent { const { field } = this.state; + // @ts-ignore field[fieldName] = value; this.forceUpdate(); }; @@ -225,7 +249,7 @@ export class FieldEditor extends PureComponent ({ type, indices: Array.isArray(indices) ? indices.join(', ') : 'Index names unavailable', @@ -445,7 +471,7 @@ export class FieldEditor extends PureComponent Date: Thu, 23 Apr 2020 10:55:05 -0500 Subject: [PATCH 10/20] typescript fixes --- ...in-plugins-data-public.ifieldformattype.md | 15 +++++ .../kibana-plugin-plugins-data-public.md | 1 + ...plugin-plugins-data-server.plugin.setup.md | 4 +- .../editors/default/default.test.tsx | 13 ++-- .../editors/default/default.tsx | 5 +- .../static_lookup/static_lookup.test.tsx | 2 +- .../editors/truncate/truncate.test.tsx | 7 ++- .../public/field_editor/field_editor.test.tsx | 63 ++++++++++++++----- src/plugins/data/public/index.ts | 1 + src/plugins/data/public/public.api.md | 55 +++++++++------- src/plugins/data/server/server.api.md | 2 +- 11 files changed, 113 insertions(+), 55 deletions(-) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldformattype.md diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldformattype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldformattype.md new file mode 100644 index 00000000000000..f076314f965219 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.ifieldformattype.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [IFieldFormatType](./kibana-plugin-plugins-data-public.ifieldformattype.md) + +## IFieldFormatType type + +Signature: + +```typescript +export declare type IFieldFormatType = (new (params?: any, getConfig?: FieldFormatsGetConfigFn) => FieldFormat) & { + id: FieldFormatId; + title: string; + fieldType: string | string[]; +}; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index 303d8ee466d961..84bc89fef5bfaf 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -132,6 +132,7 @@ | [IAggType](./kibana-plugin-plugins-data-public.iaggtype.md) | | | [IFieldFormat](./kibana-plugin-plugins-data-public.ifieldformat.md) | | | [IFieldFormatsRegistry](./kibana-plugin-plugins-data-public.ifieldformatsregistry.md) | | +| [IFieldFormatType](./kibana-plugin-plugins-data-public.ifieldformattype.md) | | | [IFieldParamType](./kibana-plugin-plugins-data-public.ifieldparamtype.md) | | | [IMetricAggType](./kibana-plugin-plugins-data-public.imetricaggtype.md) | | | [IndexPatternAggRestrictions](./kibana-plugin-plugins-data-public.indexpatternaggrestrictions.md) | | diff --git a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.setup.md b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.setup.md index 5c2f542204079c..e28bd0e09fb798 100644 --- a/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.setup.md +++ b/docs/development/plugins/data/server/kibana-plugin-plugins-data-server.plugin.setup.md @@ -9,7 +9,7 @@ ```typescript setup(core: CoreSetup, { usageCollection }: DataPluginSetupDependencies): { fieldFormats: { - register: (customFieldFormat: import("../common").IFieldFormatType) => number; + register: (customFieldFormat: import("../public").IFieldFormatType) => number; }; search: ISearchSetup; }; @@ -26,7 +26,7 @@ setup(core: CoreSetup, { usageCollection }: DataPluginSetupDependencies): { `{ fieldFormats: { - register: (customFieldFormat: import("../common").IFieldFormatType) => number; + register: (customFieldFormat: import("../public").IFieldFormatType) => number; }; search: ISearchSetup; }` diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx index 3a836c61e174ac..670ad142c5bfd8 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx @@ -19,8 +19,9 @@ import React from 'react'; import { shallow } from 'enzyme'; +import { FieldFormat } from 'src/plugins/data/public'; -import { DefaultFormatEditor, convertSampleInput } from './default'; +import { DefaultFormatEditor, convertSampleInput, ConvertSampleInputParams } from './default'; const fieldType = 'number'; const format = { @@ -32,8 +33,8 @@ const onError = jest.fn(); describe('DefaultFormatEditor', () => { describe('convertSampleInput', () => { - const converter = (input: number) => { - if (isNaN(input)) { + const converter = (input: ConvertSampleInputParams) => { + if (typeof input !== 'number') { throw new Error('Input is not a number'); } else { return (input * 2).toString(); @@ -70,7 +71,7 @@ describe('DefaultFormatEditor', () => { { { ; + export const convertSampleInput = ( - converter: (input: string | number | Array) => string, + converter: (input: ConvertSampleInputParams) => string, inputs: Array> ) => { let error; @@ -61,7 +63,6 @@ export interface FormatEditorProps

{ formatParams: { type?: string } & P; onChange: (newParams: any) => void; // todo // onChange: FieldFormatEditorProps['onChange']; - // onError: (error: any) => void; // todo onError: FieldFormatEditorProps['onError']; basePath: string; } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx index 5d1d779a137c58..2e2b1c3ae2357d 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/static_lookup.test.tsx @@ -30,7 +30,7 @@ const format = { }; const formatParams = { lookupEntries: [{}] as StaticLookupFormatEditorFormatParams['lookupEntries'], - unknownKeyValue: null, + unknownKeyValue: '', }; const onChange = jest.fn(); const onError = jest.fn(); diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx index 28da98887bf107..bb723386ff7773 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/truncate/truncate.test.tsx @@ -17,7 +17,7 @@ * under the License. */ -import React from 'react'; +import React, { ChangeEvent } from 'react'; import { shallow } from 'enzyme'; import { EuiFieldNumber } from '@elastic/eui'; import { FieldFormat } from 'src/plugins/data/public'; @@ -81,7 +81,8 @@ describe('TruncateFormatEditor', () => { validationMessage: 'Error!', }, }; - await input.invoke('onChange')(changeEvent); + + await input!.invoke('onChange')!((changeEvent as unknown) as ChangeEvent); expect(onError).toBeCalledWith(changeEvent.target.validationMessage); expect(onChange).not.toBeCalled(); @@ -108,7 +109,7 @@ describe('TruncateFormatEditor', () => { }, }; onError.mockClear(); - await input.invoke('onChange')(changeEvent); + await input!.invoke('onChange')!((changeEvent as unknown) as ChangeEvent); expect(onError).not.toBeCalled(); expect(onChange).toBeCalledWith({ fieldLength: 123 }); }); diff --git a/src/legacy/ui/public/field_editor/field_editor.test.tsx b/src/legacy/ui/public/field_editor/field_editor.test.tsx index 7a08c88552629e..4bfe3b9b204235 100644 --- a/src/legacy/ui/public/field_editor/field_editor.test.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.test.tsx @@ -23,7 +23,14 @@ import React from 'react'; import { npStart } from 'ui/new_platform'; import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers'; -import { Field, IndexPattern } from 'src/plugins/data/public'; +import { + Field, + IndexPattern, + IndexPatternFieldList, + IFieldFormatType, +} from 'src/plugins/data/public'; +import { HttpStart } from '../../../../core/public'; +// import { Field} jest.mock('brace/mode/groovy', () => ({})); jest.mock('ui/new_platform'); @@ -99,8 +106,8 @@ const field = { const helpers = { Field: () => {}, getConfig: () => {}, - $http: () => {}, - fieldFormatEditors: {}, + getHttpStart: () => (({} as unknown) as HttpStart), + fieldFormatEditors: [], redirectAway: () => {}, }; @@ -108,21 +115,29 @@ describe('FieldEditor', () => { let indexPattern: IndexPattern; beforeEach(() => { - indexPattern = { - fields, - }; + indexPattern = ({ + fields: fields as IndexPatternFieldList, + } as unknown) as IndexPattern; - npStart.plugins.data.fieldFormats.getDefaultType = jest.fn(() => Format); + npStart.plugins.data.fieldFormats.getDefaultType = jest.fn( + () => (({} as unknown) as IFieldFormatType) + ); npStart.plugins.data.fieldFormats.getByFieldType = jest.fn(fieldType => { if (fieldType === 'number') { - return [Format]; + return [({} as unknown) as IFieldFormatType]; + } else { + return []; } }); }); it('should render create new scripted field correctly', async () => { const component = shallowWithI18nProvider( - + ); await new Promise(resolve => process.nextTick(resolve)); @@ -141,11 +156,15 @@ describe('FieldEditor', () => { const flds = { [testField.name]: testField, }; - return flds[name]; + return flds[name] as Field; }; const component = shallowWithI18nProvider( - + ); await new Promise(resolve => process.nextTick(resolve)); @@ -160,16 +179,20 @@ describe('FieldEditor', () => { script: 'doc.test.value', lang: 'testlang', }; - indexPattern.fields.push(testField); + indexPattern.fields.push((testField as unknown) as Field); indexPattern.fields.getByName = name => { const flds = { [testField.name]: testField, }; - return flds[name]; + return flds[name] as Field; }; const component = shallowWithI18nProvider( - + ); await new Promise(resolve => process.nextTick(resolve)); @@ -180,7 +203,11 @@ describe('FieldEditor', () => { it('should show conflict field warning', async () => { const testField = { ...field }; const component = shallowWithI18nProvider( - + ); await new Promise(resolve => process.nextTick(resolve)); @@ -199,7 +226,11 @@ describe('FieldEditor', () => { }, }; const component = shallowWithI18nProvider( - + ); await new Promise(resolve => process.nextTick(resolve)); diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 73a836902f1621..7e9b076e75515a 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -206,6 +206,7 @@ export const fieldFormats = { export { IFieldFormat, + IFieldFormatType, IFieldFormatsRegistry, FieldFormatsContentType, FieldFormatsGetConfigFn, diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index df94d9e1ee2dd4..3cad9ecbfb7732 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -555,8 +555,6 @@ export abstract class FieldFormat { // Warning: (ae-forgotten-export) The symbol "FieldFormatConvert" needs to be exported by the entry point index.d.ts convertObject: FieldFormatConvert | undefined; static fieldType: string | string[]; - // Warning: (ae-forgotten-export) The symbol "IFieldFormatType" needs to be exported by the entry point index.d.ts - // // (undocumented) static from(convertFn: FieldFormatConvertFunction): IFieldFormatType; // (undocumented) @@ -804,6 +802,15 @@ export type IFieldFormat = PublicMethodsOf; // @public (undocumented) export type IFieldFormatsRegistry = PublicMethodsOf; +// Warning: (ae-missing-release-tag) "IFieldFormatType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type IFieldFormatType = (new (params?: any, getConfig?: FieldFormatsGetConfigFn) => FieldFormat) & { + id: FieldFormatId; + title: string; + fieldType: string | string[]; +}; + // Warning: (ae-forgotten-export) The symbol "FieldParamType" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "IFieldParamType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1891,28 +1898,28 @@ export type TSearchStrategyProvider = (context: ISearc // src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:237:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:385:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:385:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:385:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:385:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:393:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:416:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:414:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:417:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts // src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts diff --git a/src/plugins/data/server/server.api.md b/src/plugins/data/server/server.api.md index f8a9a7792c4921..203ffcccb692b6 100644 --- a/src/plugins/data/server/server.api.md +++ b/src/plugins/data/server/server.api.md @@ -609,7 +609,7 @@ export class Plugin implements Plugin_2 { // (undocumented) setup(core: CoreSetup, { usageCollection }: DataPluginSetupDependencies): { fieldFormats: { - register: (customFieldFormat: import("../common").IFieldFormatType) => number; + register: (customFieldFormat: import("../public").IFieldFormatType) => number; }; search: ISearchSetup; }; From d4de6b1dd911aaa985501204800f38e51f23b08f Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 23 Apr 2020 12:47:53 -0500 Subject: [PATCH 11/20] update snapshots, fix jest test --- ...est.js.snap => field_editor.test.tsx.snap} | 82 ++++++------------- ...snap => field_format_editor.test.tsx.snap} | 12 ++- .../bytes/__snapshots__/bytes.test.tsx.snap | 2 +- .../color/__snapshots__/color.test.tsx.snap | 6 ++ .../date/__snapshots__/date.test.tsx.snap | 2 +- .../__snapshots__/date_nanos.test.tsx.snap | 2 +- .../__snapshots__/default.test.tsx.snap | 2 +- .../editors/default/default.test.tsx | 8 +- .../__snapshots__/duration.test.tsx.snap | 7 +- .../number/__snapshots__/number.test.tsx.snap | 2 +- .../__snapshots__/percent.test.tsx.snap | 2 +- .../__snapshots__/static_lookup.test.tsx.snap | 4 + .../string/__snapshots__/string.test.tsx.snap | 2 +- .../__snapshots__/truncate.test.tsx.snap | 2 +- .../url/__snapshots__/url.test.tsx.snap | 8 -- .../field_format_editor.test.tsx | 19 ++--- .../__snapshots__/samples.test.tsx.snap | 2 +- .../__snapshots__/help_flyout.test.tsx.snap | 46 ++++++++++- 18 files changed, 119 insertions(+), 91 deletions(-) rename src/legacy/ui/public/field_editor/__snapshots__/{field_editor.test.js.snap => field_editor.test.tsx.snap} (94%) rename src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/{field_format_editor.test.js.snap => field_format_editor.test.tsx.snap} (62%) diff --git a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.js.snap b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap similarity index 94% rename from src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.js.snap rename to src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap index 19d12f4bbbd4c4..b4ccbd1019e191 100644 --- a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.js.snap +++ b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap @@ -112,15 +112,9 @@ exports[`FieldEditor should render create new scripted field correctly 1`] = ` } label={ - Test format - , - } - } + defaultMessage="Format" + id="common.ui.fieldEditor.formatHeader" + values={Object {}} /> } > @@ -134,8 +128,8 @@ exports[`FieldEditor should render create new scripted field correctly 1`] = ` "value": "", }, Object { - "text": "Test format", - "value": "test_format", + "text": undefined, + "value": "", }, ] } @@ -349,15 +343,9 @@ exports[`FieldEditor should render edit scripted field correctly 1`] = ` } label={ - Test format - , - } - } + defaultMessage="Format" + id="common.ui.fieldEditor.formatHeader" + values={Object {}} /> } > @@ -371,8 +359,8 @@ exports[`FieldEditor should render edit scripted field correctly 1`] = ` "value": "", }, Object { - "text": "Test format", - "value": "test_format", + "text": undefined, + "value": "", }, ] } @@ -645,15 +633,9 @@ exports[`FieldEditor should show conflict field warning 1`] = ` } label={ - Test format - , - } - } + defaultMessage="Format" + id="common.ui.fieldEditor.formatHeader" + values={Object {}} /> } > @@ -667,8 +649,8 @@ exports[`FieldEditor should show conflict field warning 1`] = ` "value": "", }, Object { - "text": "Test format", - "value": "test_format", + "text": undefined, + "value": "", }, ] } @@ -854,7 +836,7 @@ exports[`FieldEditor should show deprecated lang warning 1`] = ` testlang , "painlessLink": - Test format - , - } - } + defaultMessage="Format" + id="common.ui.fieldEditor.formatHeader" + values={Object {}} /> } > @@ -994,8 +970,8 @@ exports[`FieldEditor should show deprecated lang warning 1`] = ` "value": "", }, Object { - "text": "Test format", - "value": "test_format", + "text": undefined, + "value": "", }, ] } @@ -1324,15 +1300,9 @@ exports[`FieldEditor should show multiple type field warning with a table contai } label={ - Test format - , - } - } + defaultMessage="Format" + id="common.ui.fieldEditor.formatHeader" + values={Object {}} /> } > @@ -1346,8 +1316,8 @@ exports[`FieldEditor should show multiple type field warning with a table contai "value": "", }, Object { - "text": "Test format", - "value": "test_format", + "text": undefined, + "value": "", }, ] } diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.tsx.snap similarity index 62% rename from src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.js.snap rename to src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.tsx.snap index b83ae8a901ecc4..82d21eb5d30ada 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.js.snap +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/__snapshots__/field_format_editor.test.tsx.snap @@ -12,4 +12,14 @@ exports[`FieldFormatEditor should render normally 1`] = ` `; -exports[`FieldFormatEditor should render nothing if there is no editor for the format 1`] = ``; +exports[`FieldFormatEditor should render nothing if there is no editor for the format 1`] = ` + + + +`; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap index 1f77660c9784cb..bf1682faf9a9d9 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.tsx.snap @@ -5,7 +5,6 @@ exports[`BytesFormatEditor should render normally 1`] = ` `; diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx index 670ad142c5bfd8..846091d8ccb0a1 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx @@ -45,12 +45,12 @@ describe('DefaultFormatEditor', () => { const inputs = [1, 10, 15]; const output = convertSampleInput(converter, inputs); - expect(output.error).toEqual(null); + expect(output.error).toBeUndefined(); expect(JSON.stringify(output.samples)).toEqual( JSON.stringify([ - { input: 1, output: 2 }, - { input: 10, output: 20 }, - { input: 15, output: 30 }, + { input: 1, output: '2' }, + { input: 10, output: '20' }, + { input: 15, output: '30' }, ]) ); }); diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap index ef11d70926ad75..dbebd324b16b69 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.tsx.snap @@ -5,7 +5,6 @@ exports[`DurationFormatEditor should render human readable output normally 1`] = { it('should render normally', async () => { const component = shallow( @@ -40,11 +47,7 @@ describe('FieldFormatEditor', () => { fieldFormat={{} as DefaultFormatEditor} fieldFormatId="number" fieldFormatParams={{}} - fieldFormatEditors={{ - getEditor: () => { - return TestEditor; - }, - }} + fieldFormatEditors={formatEditors} onChange={() => {}} onError={() => {}} /> @@ -60,11 +63,7 @@ describe('FieldFormatEditor', () => { fieldFormat={{} as DefaultFormatEditor} fieldFormatId="ip" fieldFormatParams={{}} - fieldFormatEditors={{ - getEditor: () => { - return null; - }, - }} + fieldFormatEditors={formatEditors} onChange={() => {}} onError={() => {}} /> diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap index 73a7c1141c6014..2883ffb6bc8a13 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.tsx.snap @@ -41,7 +41,7 @@ exports[`FormatEditorSamples should render normally 1`] = ` }, Object { "input": 123, - "output": 456, + "output": "456", }, Object { "input": Array [ diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap b/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap index ca252b6d0147b6..636ef951202c87 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap @@ -46,4 +46,48 @@ exports[`ScriptingHelpFlyout should render normally 1`] = ` `; -exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = `""`; +exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` + + + , + "data-test-subj": "syntaxTab", + "id": "syntax", + "name": "Syntax", + } + } + tabs={ + Array [ + Object { + "content": , + "data-test-subj": "syntaxTab", + "id": "syntax", + "name": "Syntax", + }, + Object { + "content": , + "data-test-subj": "testTab", + "id": "test", + "name": "Preview results", + }, + ] + } + /> + + +`; From 556773846f322fd9e36d4f31dea7b6d67806d96f Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 23 Apr 2020 21:02:37 -0500 Subject: [PATCH 12/20] ts improvements, remove a couple of comments --- .../editors/default/default.test.tsx | 4 ++-- .../editors/default/default.tsx | 14 +++++++------- .../components/scripting_help/test_script.tsx | 6 ++---- .../ui/public/field_editor/field_editor.test.tsx | 1 - src/legacy/ui/public/field_editor/field_editor.tsx | 1 - src/legacy/ui/public/scripting_languages/index.ts | 1 - 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx index 846091d8ccb0a1..3f30af97dc063b 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { FieldFormat } from 'src/plugins/data/public'; -import { DefaultFormatEditor, convertSampleInput, ConvertSampleInputParams } from './default'; +import { DefaultFormatEditor, convertSampleInput, ConverterParams } from './default'; const fieldType = 'number'; const format = { @@ -33,7 +33,7 @@ const onError = jest.fn(); describe('DefaultFormatEditor', () => { describe('convertSampleInput', () => { - const converter = (input: ConvertSampleInputParams) => { + const converter = (input: ConverterParams) => { if (typeof input !== 'number') { throw new Error('Input is not a number'); } else { diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx index bb11097893408f..8a98e579665587 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/default/default.tsx @@ -24,11 +24,11 @@ import { FieldFormat, FieldFormatsContentType } from 'src/plugins/data/public'; import { Sample } from '../../../../types'; import { FieldFormatEditorProps } from '../../field_format_editor'; -export type ConvertSampleInputParams = string | number | Array; +export type ConverterParams = string | number | Array; export const convertSampleInput = ( - converter: (input: ConvertSampleInputParams) => string, - inputs: Array> + converter: (input: ConverterParams) => string, + inputs: ConverterParams[] ) => { let error; let samples: Sample[] = []; @@ -61,8 +61,7 @@ export interface FormatEditorProps

{ fieldType: string; format: FieldFormat; formatParams: { type?: string } & P; - onChange: (newParams: any) => void; // todo - // onChange: FieldFormatEditorProps['onChange']; + onChange: (newParams: Record) => void; onError: FieldFormatEditorProps['onError']; basePath: string; } @@ -70,7 +69,7 @@ export interface FormatEditorProps

{ export interface FormatEditorState { sampleInputs: ReactText[]; sampleConverterType: FieldFormatsContentType; - error: any; + error?: string; samples: Sample[]; sampleInputsByType: SampleInputs; } @@ -78,7 +77,7 @@ export interface FormatEditorState { export const defaultState = { sampleInputs: [] as ReactText[], sampleConverterType: 'text' as FieldFormatsContentType, - error: null, + error: undefined, samples: [] as Sample[], sampleInputsByType: {}, }; @@ -103,6 +102,7 @@ export class DefaultFormatEditor

extends PureComponent< onChange = (newParams = {}) => { const { onChange, formatParams } = this.props; + onChange({ ...formatParams, ...newParams, diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx index 19a3395e4599dc..c5af0f144843fc 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx @@ -57,7 +57,7 @@ interface AdditionalField { interface TestScriptState { isLoading: boolean; additionalFields: AdditionalField[]; - previewData?: any; + previewData?: Record; } export class TestScript extends Component { @@ -77,7 +77,6 @@ export class TestScript extends Component { } } - // todo type this previewScript = async (searchContext?: { query?: Query | undefined }) => { const { indexPattern, lang, name, script, executeScript } = this.props; @@ -133,7 +132,6 @@ export class TestScript extends Component { }); }; - // todo renderPreview(previewData: { error: any } | undefined) { if (!previewData) { return null; @@ -237,7 +235,7 @@ export class TestScript extends Component {

({})); jest.mock('ui/new_platform'); diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 520de13c57bdb2..8f507b8f7ab860 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -21,7 +21,6 @@ import React, { PureComponent, Fragment } from 'react'; import { intersection, union, get } from 'lodash'; import { HttpStart } from 'src/core/public'; -// todo move into ui/field_editor import { GetEnabledScriptingLanguagesProvider, getDeprecatedScriptingLanguages, diff --git a/src/legacy/ui/public/scripting_languages/index.ts b/src/legacy/ui/public/scripting_languages/index.ts index ab6afa411a54e7..c43f024345284b 100644 --- a/src/legacy/ui/public/scripting_languages/index.ts +++ b/src/legacy/ui/public/scripting_languages/index.ts @@ -30,7 +30,6 @@ export function getDeprecatedScriptingLanguages(): string[] { return []; } -// todo move to ui/field_editor export function GetEnabledScriptingLanguagesProvider($http: HttpStart) { return () => { return $http From ef45516784e2a3277c31db1080f041657abadcaa Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Thu, 23 Apr 2020 21:56:04 -0500 Subject: [PATCH 13/20] remove change to data public api, only needed type --- ...ationformat.allowsnumericalaggregations.md | 11 -- ...ns-data-public.durationformat.fieldtype.md | 11 -- ...-public.durationformat.getparamdefaults.md | 23 ---- ...n-plugins-data-public.durationformat.id.md | 11 -- ...data-public.durationformat.inputformats.md | 14 --- ...gins-data-public.durationformat.ishuman.md | 15 --- ...ugin-plugins-data-public.durationformat.md | 31 ----- ...ata-public.durationformat.outputformats.md | 14 --- ...-data-public.durationformat.textconvert.md | 11 -- ...lugins-data-public.durationformat.title.md | 11 -- .../kibana-plugin-plugins-data-public.md | 1 - .../editors/duration/duration.tsx | 2 +- src/plugins/data/public/index.ts | 2 - src/plugins/data/public/public.api.md | 113 ++++++------------ 14 files changed, 40 insertions(+), 230 deletions(-) delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md delete mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md deleted file mode 100644 index 3215ecf9283087..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [allowsNumericalAggregations](./kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md) - -## DurationFormat.allowsNumericalAggregations property - -Signature: - -```typescript -allowsNumericalAggregations: boolean; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md deleted file mode 100644 index 848df3222d0aa7..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.fieldtype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [fieldType](./kibana-plugin-plugins-data-public.durationformat.fieldtype.md) - -## DurationFormat.fieldType property - -Signature: - -```typescript -static fieldType: KBN_FIELD_TYPES; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md deleted file mode 100644 index 8d05f92eecbacf..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [getParamDefaults](./kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md) - -## DurationFormat.getParamDefaults() method - -Signature: - -```typescript -getParamDefaults(): { - inputFormat: string; - outputFormat: string; - outputPrecision: number; - }; -``` -Returns: - -`{ - inputFormat: string; - outputFormat: string; - outputPrecision: number; - }` - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md deleted file mode 100644 index e7459846c86861..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.id.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [id](./kibana-plugin-plugins-data-public.durationformat.id.md) - -## DurationFormat.id property - -Signature: - -```typescript -static id: FIELD_FORMAT_IDS; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md deleted file mode 100644 index 8733ee8e2857d9..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.inputformats.md +++ /dev/null @@ -1,14 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [inputFormats](./kibana-plugin-plugins-data-public.durationformat.inputformats.md) - -## DurationFormat.inputFormats property - -Signature: - -```typescript -static inputFormats: { - text: string; - kind: string; - }[]; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md deleted file mode 100644 index c916168251f396..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.ishuman.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [isHuman](./kibana-plugin-plugins-data-public.durationformat.ishuman.md) - -## DurationFormat.isHuman() method - -Signature: - -```typescript -isHuman(): boolean; -``` -Returns: - -`boolean` - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md deleted file mode 100644 index a6f4a1c903c78a..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.md +++ /dev/null @@ -1,31 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) - -## DurationFormat class - -Signature: - -```typescript -export declare class DurationFormat extends FieldFormat -``` - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [allowsNumericalAggregations](./kibana-plugin-plugins-data-public.durationformat.allowsnumericalaggregations.md) | | boolean | | -| [fieldType](./kibana-plugin-plugins-data-public.durationformat.fieldtype.md) | static | KBN_FIELD_TYPES | | -| [id](./kibana-plugin-plugins-data-public.durationformat.id.md) | static | FIELD_FORMAT_IDS | | -| [inputFormats](./kibana-plugin-plugins-data-public.durationformat.inputformats.md) | static | {
text: string;
kind: string;
}[] | | -| [outputFormats](./kibana-plugin-plugins-data-public.durationformat.outputformats.md) | static | {
text: string;
method: string;
}[] | | -| [textConvert](./kibana-plugin-plugins-data-public.durationformat.textconvert.md) | | TextContextTypeConvert | | -| [title](./kibana-plugin-plugins-data-public.durationformat.title.md) | static | string | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [getParamDefaults()](./kibana-plugin-plugins-data-public.durationformat.getparamdefaults.md) | | | -| [isHuman()](./kibana-plugin-plugins-data-public.durationformat.ishuman.md) | | | - diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md deleted file mode 100644 index 555f6a453a3354..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.outputformats.md +++ /dev/null @@ -1,14 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [outputFormats](./kibana-plugin-plugins-data-public.durationformat.outputformats.md) - -## DurationFormat.outputFormats property - -Signature: - -```typescript -static outputFormats: { - text: string; - method: string; - }[]; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md deleted file mode 100644 index 56da40f2be3eec..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.textconvert.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [textConvert](./kibana-plugin-plugins-data-public.durationformat.textconvert.md) - -## DurationFormat.textConvert property - -Signature: - -```typescript -textConvert: TextContextTypeConvert; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md deleted file mode 100644 index b20aa0c7c0e2f8..00000000000000 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.durationformat.title.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) > [title](./kibana-plugin-plugins-data-public.durationformat.title.md) - -## DurationFormat.title property - -Signature: - -```typescript -static title: string; -``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md index 84bc89fef5bfaf..7c8b40a1473dc2 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.md @@ -11,7 +11,6 @@ | [AggParamType](./kibana-plugin-plugins-data-public.aggparamtype.md) | | | [AggTypeFieldFilters](./kibana-plugin-plugins-data-public.aggtypefieldfilters.md) | A registry to store which are used to filter down available fields for a specific visualization and . | | [AggTypeFilters](./kibana-plugin-plugins-data-public.aggtypefilters.md) | A registry to store which are used to filter down available aggregations for a specific visualization and . | -| [DurationFormat](./kibana-plugin-plugins-data-public.durationformat.md) | | | [Field](./kibana-plugin-plugins-data-public.field.md) | | | [FieldFormat](./kibana-plugin-plugins-data-public.fieldformat.md) | | | [FilterManager](./kibana-plugin-plugins-data-public.filtermanager.md) | | diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx index 96fd845e3caee2..aed3264bad440a 100644 --- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx +++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/duration.tsx @@ -18,7 +18,7 @@ */ import React, { Fragment } from 'react'; -import { DurationFormat } from 'src/plugins/data/public'; +import { DurationFormat } from 'src/plugins/data/common'; import { EuiFieldNumber, EuiFormRow, EuiSelect } from '@elastic/eui'; diff --git a/src/plugins/data/public/index.ts b/src/plugins/data/public/index.ts index 7e9b076e75515a..09823e52a78e32 100644 --- a/src/plugins/data/public/index.ts +++ b/src/plugins/data/public/index.ts @@ -170,8 +170,6 @@ import { serializeFieldFormat, } from '../common/field_formats'; -export { DurationFormat }; - import { DateFormat } from './field_formats'; export { baseFormattersPublic } from './field_formats'; diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 3cad9ecbfb7732..96f169d4f5fa04 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -283,44 +283,6 @@ export interface DateRangeKey { to: number; } -// Warning: (ae-missing-release-tag) "DurationFormat" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export class DurationFormat extends FieldFormat { - // (undocumented) - allowsNumericalAggregations: boolean; - // (undocumented) - static fieldType: KBN_FIELD_TYPES; - // (undocumented) - getParamDefaults(): { - inputFormat: string; - outputFormat: string; - outputPrecision: number; - }; - // Warning: (ae-forgotten-export) The symbol "FIELD_FORMAT_IDS" needs to be exported by the entry point index.d.ts - // - // (undocumented) - static id: FIELD_FORMAT_IDS; - // (undocumented) - static inputFormats: { - text: string; - kind: string; - }[]; - // (undocumented) - isHuman(): boolean; - // (undocumented) - static outputFormats: { - text: string; - method: string; - }[]; - // Warning: (ae-forgotten-export) The symbol "TextContextTypeConvert" needs to be exported by the entry point index.d.ts - // - // (undocumented) - textConvert: TextContextTypeConvert; - // (undocumented) - static title: string; -} - // @public (undocumented) export enum ES_FIELD_TYPES { // (undocumented) @@ -573,6 +535,7 @@ export abstract class FieldFormat { protected readonly _params: any; // (undocumented) setupContentType(): FieldFormatConvert; + // Warning: (ae-forgotten-export) The symbol "TextContextTypeConvert" needs to be exported by the entry point index.d.ts textConvert: TextContextTypeConvert | undefined; static title: string; toJSON(): { @@ -594,6 +557,7 @@ export interface FieldFormatConfig { params: Record; } +// Warning: (ae-forgotten-export) The symbol "FIELD_FORMAT_IDS" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "FieldFormatId" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -1884,42 +1848,43 @@ export type TSearchStrategyProvider = (context: ISearc // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "getEsQueryConfig" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "luceneStringToDsl" needs to be exported by the entry point index.d.ts // src/plugins/data/public/index.ts:135:21 - (ae-forgotten-export) The symbol "decorateQuery" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "DateNanosFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:179:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:238:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:386:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:391:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:394:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:404:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:405:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:409:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:410:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:413:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:414:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts -// src/plugins/data/public/index.ts:417:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "FieldFormatsRegistry" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BoolFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "BytesFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "ColorFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "DateNanosFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "DurationFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "IpFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "NumberFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "PercentFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "RelativeDateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "SourceFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StaticLookupFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "UrlFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:177:26 - (ae-forgotten-export) The symbol "TruncateFormat" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "isFilterable" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "isNestedField" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "validateIndexPattern" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "getFromSavedObject" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "flattenHitWrapper" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "getRoutes" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:236:27 - (ae-forgotten-export) The symbol "formatHitProvider" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getRequestInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "getResponseInspectorStats" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyAggResponse" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:384:20 - (ae-forgotten-export) The symbol "tabifyGetColumns" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:389:1 - (ae-forgotten-export) The symbol "CidrMask" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:390:1 - (ae-forgotten-export) The symbol "convertDateRangeToString" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:392:1 - (ae-forgotten-export) The symbol "dateHistogramInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:401:1 - (ae-forgotten-export) The symbol "InvalidEsCalendarIntervalError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:402:1 - (ae-forgotten-export) The symbol "InvalidEsIntervalFormatError" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:403:1 - (ae-forgotten-export) The symbol "isDateHistogramBucketAggConfig" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:407:1 - (ae-forgotten-export) The symbol "isValidEsInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:408:1 - (ae-forgotten-export) The symbol "isValidInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:411:1 - (ae-forgotten-export) The symbol "parseInterval" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:412:1 - (ae-forgotten-export) The symbol "propFilter" needs to be exported by the entry point index.d.ts +// src/plugins/data/public/index.ts:415:1 - (ae-forgotten-export) The symbol "toAbsoluteDates" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:33:33 - (ae-forgotten-export) The symbol "FilterStateStore" needs to be exported by the entry point index.d.ts // src/plugins/data/public/query/state_sync/connect_to_query_state.ts:37:1 - (ae-forgotten-export) The symbol "QueryStateChange" needs to be exported by the entry point index.d.ts // src/plugins/data/public/types.ts:52:5 - (ae-forgotten-export) The symbol "createFiltersFromValueClickAction" needs to be exported by the entry point index.d.ts From 534bf31fe07e3ccde561705dd0297ceaccfba784 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 24 Apr 2020 08:43:47 -0500 Subject: [PATCH 14/20] rename prop argument --- .../sections/index_patterns/edit_index_pattern/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js index e05aea3678fe20..d35c71ced69f6e 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js @@ -112,7 +112,7 @@ const renderCreateEditField = ($scope, $route, getConfig, $http, fieldFormatEdit fieldFormatEditors={fieldFormatEditors} getConfig={getConfig} services={{ - http: $http, + getHttpStart: () => $http, notifications: npStart.core.notifications, docTitle: npStart.core.chrome.docTitle, }} From 922c50f54ab9220b5bc7416bc59ed4b16f40f5c1 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 24 Apr 2020 12:24:54 -0500 Subject: [PATCH 15/20] no more ui/kfetch --- .../index_patterns/edit_index_pattern/index.js | 4 ++-- .../scripting_help/help_flyout.test.tsx | 3 +++ .../components/scripting_help/help_flyout.tsx | 4 ++++ .../components/scripting_help/test_script.tsx | 5 ++++- .../ui/public/field_editor/field_editor.test.tsx | 2 -- .../ui/public/field_editor/field_editor.tsx | 2 ++ .../public/field_editor/lib/validate_script.ts | 16 +++++++++++++--- src/legacy/ui/public/field_editor/types.ts | 2 ++ 8 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js index d35c71ced69f6e..4a71822eb967ef 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js @@ -95,7 +95,7 @@ uiModules // routes for create edit field. Will be removed after migartion all component to react. const REACT_FIELD_EDITOR_ID = 'reactFieldEditor'; -const renderCreateEditField = ($scope, $route, getConfig, $http, fieldFormatEditors) => { +const renderCreateEditField = ($scope, $route, getConfig, fieldFormatEditors) => { $scope.$$postDigest(() => { const node = document.getElementById(REACT_FIELD_EDITOR_ID); if (!node) { @@ -112,7 +112,7 @@ const renderCreateEditField = ($scope, $route, getConfig, $http, fieldFormatEdit fieldFormatEditors={fieldFormatEditors} getConfig={getConfig} services={{ - getHttpStart: () => $http, + getHttpStart: () => npStart.core.http, notifications: npStart.core.notifications, docTitle: npStart.core.chrome.docTitle, }} diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx index 9937215e2b81b4..48d17f241699ab 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx @@ -19,6 +19,7 @@ import React from 'react'; import { shallow } from 'enzyme'; +import { HttpStart } from 'src/core/public'; import { ScriptingHelpFlyout } from './help_flyout'; @@ -47,6 +48,7 @@ describe('ScriptingHelpFlyout', () => { lang="painless" executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} + getHttpStart={() => (({} as unknown) as HttpStart)} /> ); @@ -61,6 +63,7 @@ describe('ScriptingHelpFlyout', () => { lang="painless" executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} + getHttpStart={() => (({} as unknown) as HttpStart)} /> ); diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx index 2b1ed3895dee9f..2ba95c118b9470 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx @@ -18,6 +18,7 @@ */ import React from 'react'; +import { HttpStart } from 'src/core/public'; import { EuiFlyout, EuiFlyoutBody, EuiTabbedContent } from '@elastic/eui'; @@ -35,6 +36,7 @@ interface ScriptingHelpFlyoutProps { executeScript: ExecuteScript; isVisible: boolean; onClose: () => void; + getHttpStart: () => HttpStart; } export const ScriptingHelpFlyout: React.FC = ({ @@ -45,6 +47,7 @@ export const ScriptingHelpFlyout: React.FC = ({ name, script, executeScript, + getHttpStart, }) => { const tabs = [ { @@ -64,6 +67,7 @@ export const ScriptingHelpFlyout: React.FC = ({ name={name} script={script} executeScript={executeScript} + getHttpStart={getHttpStart} /> ), }, diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx index c5af0f144843fc..8d3a83a155553c 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/test_script.tsx @@ -18,6 +18,7 @@ */ import React, { Component, Fragment } from 'react'; +import { HttpStart } from 'src/core/public'; import { EuiButton, @@ -47,6 +48,7 @@ interface TestScriptProps { name?: string; script?: string; executeScript: ExecuteScript; + getHttpStart: () => HttpStart; } interface AdditionalField { @@ -78,7 +80,7 @@ export class TestScript extends Component { } previewScript = async (searchContext?: { query?: Query | undefined }) => { - const { indexPattern, lang, name, script, executeScript } = this.props; + const { indexPattern, lang, name, script, executeScript, getHttpStart } = this.props; if (!script || script.length === 0) { return; @@ -106,6 +108,7 @@ export class TestScript extends Component { indexPatternTitle: indexPattern.title, query, additionalFields: this.state.additionalFields.map((option: AdditionalField) => option.value), + getHttpStart, }); if (scriptResponse.status !== 200) { diff --git a/src/legacy/ui/public/field_editor/field_editor.test.tsx b/src/legacy/ui/public/field_editor/field_editor.test.tsx index 983b658e08052d..00342e54d7027a 100644 --- a/src/legacy/ui/public/field_editor/field_editor.test.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.test.tsx @@ -17,8 +17,6 @@ * under the License. */ -jest.mock('ui/kfetch', () => ({})); - import React from 'react'; import { npStart } from 'ui/new_platform'; diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 373f0c3fe64a07..83df43ed59bdfb 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -755,6 +755,7 @@ export class FieldEditor extends PureComponent ); @@ -795,6 +796,7 @@ export class FieldEditor extends PureComponent => { // Using _msearch because _search with index name in path dorks everything up const header = { @@ -61,7 +62,8 @@ export const executeScript = async ({ } const body = `${JSON.stringify(header)}\n${JSON.stringify(search)}\n`; - const esResp = await kfetch({ method: 'POST', pathname: '/elasticsearch/_msearch', body }); + const http = await getHttpStart(); + const esResp = await http.fetch('/elasticsearch/_msearch', { method: 'POST', body }); // unwrap _msearch response return esResp.responses[0]; }; @@ -71,13 +73,21 @@ export const isScriptValid = async ({ lang, script, indexPatternTitle, + getHttpStart, }: { name: string; lang: string; script: string; indexPatternTitle: string; + getHttpStart: () => HttpStart; }) => { - const scriptResponse = await executeScript({ name, lang, script, indexPatternTitle }); + const scriptResponse = await executeScript({ + name, + lang, + script, + indexPatternTitle, + getHttpStart, + }); if (scriptResponse.status !== 200) { return false; diff --git a/src/legacy/ui/public/field_editor/types.ts b/src/legacy/ui/public/field_editor/types.ts index 326f2a7ba4b8dd..174cb7da73cebe 100644 --- a/src/legacy/ui/public/field_editor/types.ts +++ b/src/legacy/ui/public/field_editor/types.ts @@ -19,6 +19,7 @@ import { ReactText } from 'react'; import { Query } from 'src/plugins/data/public'; +import { HttpStart } from 'src/core/public'; export interface Sample { input: ReactText | ReactText[]; @@ -32,6 +33,7 @@ export interface ExecuteScriptParams { indexPatternTitle: string; query?: Query['query']; additionalFields?: string[]; + getHttpStart: () => HttpStart; } export interface ExecuteScriptResult { From d2ef5384f8b5cedf3617b2813a2710cb7cab94bf Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 24 Apr 2020 15:25:08 -0500 Subject: [PATCH 16/20] update snapshots, fix field editor args --- .../sections/index_patterns/edit_index_pattern/index.js | 4 ++-- .../field_editor/__snapshots__/field_editor.test.tsx.snap | 5 +++++ .../scripting_help/__snapshots__/help_flyout.test.tsx.snap | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js index 4a71822eb967ef..3b2b0a80f752f0 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js @@ -162,11 +162,11 @@ uiRoutes }, }, controllerAs: 'fieldSettings', - controller: function FieldEditorPageController($scope, $route, $http, Private, config) { + controller: function FieldEditorPageController($scope, $route, Private, config) { const getConfig = (...args) => config.get(...args); const fieldFormatEditors = Private(RegistryFieldFormatEditorsProvider); - renderCreateEditField($scope, $route, getConfig, $http, fieldFormatEditors); + renderCreateEditField($scope, $route, getConfig, fieldFormatEditors); $scope.$on('$destroy', () => { destroyCreateEditField(); diff --git a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap index b4ccbd1019e191..f06e839c6150f1 100644 --- a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap @@ -23,6 +23,7 @@ exports[`FieldEditor should render create new scripted field correctly 1`] = ` /> , @@ -78,6 +79,7 @@ exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` Object { "content": , From 142169aacdd34718ee56aa3d0ea2aa51d4503abc Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Fri, 24 Apr 2020 17:04:33 -0500 Subject: [PATCH 17/20] fix scripted fields --- .../public/field_editor/field_editor.test.tsx | 4 +-- .../ui/public/field_editor/field_editor.tsx | 5 ++-- .../ui/public/scripting_languages/index.ts | 25 +++++++------------ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/legacy/ui/public/field_editor/field_editor.test.tsx b/src/legacy/ui/public/field_editor/field_editor.test.tsx index 00342e54d7027a..849099e65abf3e 100644 --- a/src/legacy/ui/public/field_editor/field_editor.test.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.test.tsx @@ -59,9 +59,7 @@ jest.mock('@elastic/eui', () => ({ })); jest.mock('ui/scripting_languages', () => ({ - GetEnabledScriptingLanguagesProvider: jest - .fn() - .mockImplementation(() => () => ['painless', 'testlang']), + getEnabledScriptingLanguages: () => ['painless', 'testlang'], getSupportedScriptingLanguages: () => ['painless'], getDeprecatedScriptingLanguages: () => ['testlang'], })); diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 83df43ed59bdfb..5c0498d9ce5fd5 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -22,7 +22,7 @@ import { intersection, union, get } from 'lodash'; import { HttpStart } from 'src/core/public'; import { - GetEnabledScriptingLanguagesProvider, + getEnabledScriptingLanguages, getDeprecatedScriptingLanguages, getSupportedScriptingLanguages, } from 'ui/scripting_languages'; @@ -183,8 +183,7 @@ export class FieldEditor extends PureComponent { - return $http - .get(chrome.addBasePath('/api/kibana/scripts/languages')) - .then((res: any) => res.data) - .catch(() => { - toastNotifications.addDanger( - i18n.translate('common.ui.scriptingLanguages.errorFetchingToastDescription', { - defaultMessage: 'Error getting available scripting languages from Elasticsearch', - }) - ); - return []; - }); - }; -} +export const getEnabledScriptingLanguages = (http: HttpStart) => + http.get('/api/kibana/scripts/languages').catch(() => { + toastNotifications.addDanger( + i18n.translate('common.ui.scriptingLanguages.errorFetchingToastDescription', { + defaultMessage: 'Error getting available scripting languages from Elasticsearch', + }) + ); + return []; + }); From a790ac4bdd34cfb875a7ec122b4ce637bbbc3f15 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sat, 25 Apr 2020 15:57:16 -0500 Subject: [PATCH 18/20] ui/dock_links to core.dockLinks --- .../create_edit_field/create_edit_field.tsx | 4 +- .../edit_index_pattern/index.js | 1 + .../__snapshots__/field_editor.test.tsx.snap | 100 ++++++++++++++++++ .../warning_call_out.test.tsx.snap | 4 +- .../warning_call_out.test.tsx | 15 +-- .../scripting_call_outs/warning_call_out.tsx | 16 ++- .../__snapshots__/help_flyout.test.tsx.snap | 52 ++++++++- .../scripting_help/help_flyout.test.tsx | 9 +- .../components/scripting_help/help_flyout.tsx | 6 +- .../scripting_help/scripting_syntax.tsx | 16 +-- .../public/field_editor/field_editor.test.tsx | 3 + .../ui/public/field_editor/field_editor.tsx | 9 +- 12 files changed, 204 insertions(+), 31 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx index da3a6ec12c1dbb..564f115cf2c487 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/create_edit_field/create_edit_field.tsx @@ -23,7 +23,7 @@ import { FieldEditor } from 'ui/field_editor'; import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { HttpStart } from 'src/core/public'; +import { HttpStart, DocLinksStart } from 'src/core/public'; import { IndexHeader } from '../index_header'; import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public'; import { ChromeDocTitle, NotificationsStart } from '../../../../../../../../../core/public'; @@ -39,6 +39,7 @@ interface CreateEditFieldProps extends RouteComponentProps { notifications: NotificationsStart; docTitle: ChromeDocTitle; getHttpStart: () => HttpStart; + docLinksScriptedFields: DocLinksStart['links']['scriptedFields']; }; } @@ -102,6 +103,7 @@ export const CreateEditField = withRouter( getHttpStart: services.getHttpStart, fieldFormatEditors, redirectAway, + docLinksScriptedFields: services.docLinksScriptedFields, }} /> diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js index 3b2b0a80f752f0..e2f387c0291a7a 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/edit_index_pattern/index.js @@ -115,6 +115,7 @@ const renderCreateEditField = ($scope, $route, getConfig, fieldFormatEditors) => getHttpStart: () => npStart.core.http, notifications: npStart.core.notifications, docTitle: npStart.core.chrome.docTitle, + docLinksScriptedFields: npStart.core.docLinks.links.scriptedFields, }} /> diff --git a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap index f06e839c6150f1..dc11bdfefa46bf 100644 --- a/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/__snapshots__/field_editor.test.tsx.snap @@ -19,9 +19,29 @@ exports[`FieldEditor should render create new scripted field correctly 1`] = ` isVisible={false} /> , "scriptsInAggregation": ({ - getDocLink: (doc: string) => `(docLink for ${doc})`, -})); +// eslint-disable-next-line +import { docLinksServiceMock } from '../../../../../../core/public/doc_links/doc_links_service.mock'; describe('ScriptingWarningCallOut', () => { + const docLinksScriptedFields = docLinksServiceMock.createStartContract().links.scriptedFields; it('should render normally', async () => { - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); it('should render nothing if not visible', async () => { - const component = shallow(); + const component = shallow( + + ); expect(component).toMatchSnapshot(); }); diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx index b810541d726977..7dac6681fa1ea8 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_call_outs/warning_call_out.tsx @@ -18,13 +18,21 @@ */ import React, { Fragment } from 'react'; -import { getDocLink } from 'ui/documentation_links'; +import { DocLinksStart } from 'src/core/public'; import { EuiCallOut, EuiIcon, EuiLink, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -export const ScriptingWarningCallOut = ({ isVisible = false }) => { +export interface ScriptingWarningCallOutProps { + isVisible: boolean; + docLinksScriptedFields: DocLinksStart['links']['scriptedFields']; +} + +export const ScriptingWarningCallOut = ({ + isVisible = false, + docLinksScriptedFields, +}: ScriptingWarningCallOutProps) => { return isVisible ? ( { defaultMessage="Please familiarize yourself with {scripFields} and with {scriptsInAggregation} before using scripted fields." values={{ scripFields: ( - + { ), scriptsInAggregation: ( - + , + "content": , "data-test-subj": "syntaxTab", "id": "syntax", "name": "Syntax", @@ -24,7 +35,18 @@ exports[`ScriptingHelpFlyout should render normally 1`] = ` tabs={ Array [ Object { - "content": , + "content": , "data-test-subj": "syntaxTab", "id": "syntax", "name": "Syntax", @@ -62,7 +84,18 @@ exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` autoFocus="initial" initialSelectedTab={ Object { - "content": , + "content": , "data-test-subj": "syntaxTab", "id": "syntax", "name": "Syntax", @@ -71,7 +104,18 @@ exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` tabs={ Array [ Object { - "content": , + "content": , "data-test-subj": "syntaxTab", "id": "syntax", "name": "Syntax", diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx index 48d17f241699ab..71bcbd5afb7199 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx @@ -20,6 +20,8 @@ import React from 'react'; import { shallow } from 'enzyme'; import { HttpStart } from 'src/core/public'; +// eslint-disable-next-line +import { docLinksServiceMock } from '../../../../../../core/public/doc_links/doc_links_service.mock'; import { ScriptingHelpFlyout } from './help_flyout'; @@ -27,10 +29,6 @@ import { IndexPattern } from '../../../../../../plugins/data/public'; import { ExecuteScript } from '../../types'; -jest.mock('ui/documentation_links', () => ({ - getDocLink: (doc: string) => `(docLink for ${doc})`, -})); - jest.mock('./test_script', () => ({ TestScript: () => { return `
mockTestScript
`; @@ -40,6 +38,7 @@ jest.mock('./test_script', () => ({ const indexPatternMock = {} as IndexPattern; describe('ScriptingHelpFlyout', () => { + const docLinksScriptedFields = docLinksServiceMock.createStartContract().links.scriptedFields; it('should render normally', async () => { const component = shallow( { executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} getHttpStart={() => (({} as unknown) as HttpStart)} + docLinksScriptedFields={docLinksScriptedFields} /> ); @@ -64,6 +64,7 @@ describe('ScriptingHelpFlyout', () => { executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} getHttpStart={() => (({} as unknown) as HttpStart)} + docLinksScriptedFields={docLinksScriptedFields} /> ); diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx index 2ba95c118b9470..6f51379c796d49 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.tsx @@ -18,7 +18,7 @@ */ import React from 'react'; -import { HttpStart } from 'src/core/public'; +import { HttpStart, DocLinksStart } from 'src/core/public'; import { EuiFlyout, EuiFlyoutBody, EuiTabbedContent } from '@elastic/eui'; @@ -37,6 +37,7 @@ interface ScriptingHelpFlyoutProps { isVisible: boolean; onClose: () => void; getHttpStart: () => HttpStart; + docLinksScriptedFields: DocLinksStart['links']['scriptedFields']; } export const ScriptingHelpFlyout: React.FC = ({ @@ -48,13 +49,14 @@ export const ScriptingHelpFlyout: React.FC = ({ script, executeScript, getHttpStart, + docLinksScriptedFields, }) => { const tabs = [ { id: 'syntax', name: 'Syntax', ['data-test-subj']: 'syntaxTab', - content: , + content: , }, { id: 'test', diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx index ba47b94aaea0c5..8158c6881acf9e 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/scripting_syntax.tsx @@ -18,13 +18,17 @@ */ import React, { Fragment } from 'react'; -import { getDocLink } from 'ui/documentation_links'; +import { DocLinksStart } from 'src/core/public'; import { EuiCode, EuiIcon, EuiLink, EuiText, EuiSpacer } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; -export const ScriptingSyntax = () => ( +export interface ScriptingSyntaxProps { + docLinksScriptedFields: DocLinksStart['links']['scriptedFields']; +} + +export const ScriptingSyntax = ({ docLinksScriptedFields }: ScriptingSyntaxProps) => ( @@ -38,7 +42,7 @@ export const ScriptingSyntax = () => ( specifically for use with Elasticsearch, to access values in the document use the following format:" values={{ painless: ( - + ( you'll be up to speed in no time!" values={{ javaAPIs: ( - + ( ), syntax: ( - + ( are a lot like JavaScript, but limited to basic arithmetic, bitwise and comparison operations." values={{ lucene: ( - + ({})); jest.mock('ui/new_platform'); @@ -104,6 +106,7 @@ const helpers = { getHttpStart: () => (({} as unknown) as HttpStart), fieldFormatEditors: [], redirectAway: () => {}, + docLinksScriptedFields: docLinksServiceMock.createStartContract().links.scriptedFields, }; describe('FieldEditor', () => { diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 5c0498d9ce5fd5..04f563c1fe53fa 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -19,7 +19,7 @@ import React, { PureComponent, Fragment } from 'react'; import { intersection, union, get } from 'lodash'; -import { HttpStart } from 'src/core/public'; +import { HttpStart, DocLinksStart } from 'src/core/public'; import { getEnabledScriptingLanguages, @@ -145,6 +145,7 @@ export interface FieldEdiorProps { getHttpStart: () => HttpStart; fieldFormatEditors: DefaultFormatEditor[]; redirectAway: () => void; + docLinksScriptedFields: DocLinksStart['links']['scriptedFields']; }; } @@ -745,7 +746,10 @@ export class FieldEditor extends PureComponent - + ); From cfa3fd5e7e74538905ebb9243a3b4a7a947e81d2 Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Sun, 26 Apr 2020 22:10:02 -0500 Subject: [PATCH 19/20] better define conflict descriptions --- ...-plugins-data-public.field.conflictdescriptions.md | 11 +++++++++++ .../public/kibana-plugin-plugins-data-public.field.md | 1 + src/legacy/ui/public/field_editor/field_editor.tsx | 4 +--- .../data/public/index_patterns/fields/field.ts | 1 + src/plugins/data/public/public.api.md | 2 ++ 5 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.conflictdescriptions.md diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.conflictdescriptions.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.conflictdescriptions.md new file mode 100644 index 00000000000000..21b6917c4aad41 --- /dev/null +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.conflictdescriptions.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) > [Field](./kibana-plugin-plugins-data-public.field.md) > [conflictDescriptions](./kibana-plugin-plugins-data-public.field.conflictdescriptions.md) + +## Field.conflictDescriptions property + +Signature: + +```typescript +conflictDescriptions?: Record; +``` diff --git a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md index 84c22c47a5e2fc..86ff2b2c28ae94 100644 --- a/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md +++ b/docs/development/plugins/data/public/kibana-plugin-plugins-data-public.field.md @@ -22,6 +22,7 @@ export declare class Field implements IFieldType | --- | --- | --- | --- | | [$$spec](./kibana-plugin-plugins-data-public.field.__spec.md) | | FieldSpec | | | [aggregatable](./kibana-plugin-plugins-data-public.field.aggregatable.md) | | boolean | | +| [conflictDescriptions](./kibana-plugin-plugins-data-public.field.conflictdescriptions.md) | | Record<string, string[]> | | | [count](./kibana-plugin-plugins-data-public.field.count.md) | | number | | | [displayName](./kibana-plugin-plugins-data-public.field.displayname.md) | | string | | | [esTypes](./kibana-plugin-plugins-data-public.field.estypes.md) | | string[] | | diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 04f563c1fe53fa..1402a10ce8b63d 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -420,8 +420,7 @@ export class FieldEditor extends PureComponent ({ type, indices: Array.isArray(indices) ? indices.join(', ') : 'Index names unavailable', diff --git a/src/plugins/data/public/index_patterns/fields/field.ts b/src/plugins/data/public/index_patterns/fields/field.ts index 0fb92393d56f71..d83c0a7d3445eb 100644 --- a/src/plugins/data/public/index_patterns/fields/field.ts +++ b/src/plugins/data/public/index_patterns/fields/field.ts @@ -47,6 +47,7 @@ export class Field implements IFieldType { indexPattern?: IndexPattern; format: any; $$spec: FieldSpec; + conflictDescriptions?: Record; constructor( indexPattern: IndexPattern, diff --git a/src/plugins/data/public/public.api.md b/src/plugins/data/public/public.api.md index 3dee894747fc81..86560b3ccf7b12 100644 --- a/src/plugins/data/public/public.api.md +++ b/src/plugins/data/public/public.api.md @@ -463,6 +463,8 @@ class Field implements IFieldType { // (undocumented) aggregatable?: boolean; // (undocumented) + conflictDescriptions?: Record; + // (undocumented) count?: number; // (undocumented) displayName?: string; From b8b3abba2617ee636643c0db2d5dfc55640d1f1f Mon Sep 17 00:00:00 2001 From: Matt Kime Date: Mon, 27 Apr 2020 09:53:06 -0500 Subject: [PATCH 20/20] one less typescript any and better snapshots --- .../warning_call_out.test.tsx.snap | 2 - .../warning_call_out.test.tsx | 10 ++++- .../__snapshots__/help_flyout.test.tsx.snap | 44 ++----------------- .../scripting_help/help_flyout.test.tsx | 5 ++- .../ui/public/field_editor/field_editor.tsx | 3 +- 5 files changed, 16 insertions(+), 48 deletions(-) diff --git a/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap b/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap index ceef1e0f5e18c1..b331c1e38eb349 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/scripting_call_outs/__snapshots__/warning_call_out.test.tsx.snap @@ -20,7 +20,6 @@ exports[`ScriptingWarningCallOut should render normally 1`] = ` values={ Object { "scripFields": , "scriptsInAggregation": { const docLinksScriptedFields = docLinksServiceMock.createStartContract().links.scriptedFields; it('should render normally', async () => { const component = shallow( - + ); expect(component).toMatchSnapshot(); @@ -36,7 +39,10 @@ describe('ScriptingWarningCallOut', () => { it('should render nothing if not visible', async () => { const component = shallow( - + ); expect(component).toMatchSnapshot(); diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap b/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap index 25e3b2e12f20ab..282e8e311d984d 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap +++ b/src/legacy/ui/public/field_editor/components/scripting_help/__snapshots__/help_flyout.test.tsx.snap @@ -16,16 +16,7 @@ exports[`ScriptingHelpFlyout should render normally 1`] = ` initialSelectedTab={ Object { "content": , "data-test-subj": "syntaxTab", "id": "syntax", @@ -36,16 +27,7 @@ exports[`ScriptingHelpFlyout should render normally 1`] = ` Array [ Object { "content": , "data-test-subj": "syntaxTab", "id": "syntax", @@ -85,16 +67,7 @@ exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` initialSelectedTab={ Object { "content": , "data-test-subj": "syntaxTab", "id": "syntax", @@ -105,16 +78,7 @@ exports[`ScriptingHelpFlyout should render nothing if not visible 1`] = ` Array [ Object { "content": , "data-test-subj": "syntaxTab", "id": "syntax", diff --git a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx index 71bcbd5afb7199..4106eb7b283eea 100644 --- a/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx +++ b/src/legacy/ui/public/field_editor/components/scripting_help/help_flyout.test.tsx @@ -48,7 +48,8 @@ describe('ScriptingHelpFlyout', () => { executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} getHttpStart={() => (({} as unknown) as HttpStart)} - docLinksScriptedFields={docLinksScriptedFields} + // docLinksScriptedFields={docLinksScriptedFields} + docLinksScriptedFields={{} as typeof docLinksScriptedFields} /> ); @@ -64,7 +65,7 @@ describe('ScriptingHelpFlyout', () => { executeScript={((() => {}) as unknown) as ExecuteScript} onClose={() => {}} getHttpStart={() => (({} as unknown) as HttpStart)} - docLinksScriptedFields={docLinksScriptedFields} + docLinksScriptedFields={{} as typeof docLinksScriptedFields} /> ); diff --git a/src/legacy/ui/public/field_editor/field_editor.tsx b/src/legacy/ui/public/field_editor/field_editor.tsx index 1402a10ce8b63d..aa62a53f2c32a1 100644 --- a/src/legacy/ui/public/field_editor/field_editor.tsx +++ b/src/legacy/ui/public/field_editor/field_editor.tsx @@ -218,8 +218,7 @@ export class FieldEditor extends PureComponent { const { field } = this.state; - // @ts-ignore - field[fieldName] = value; + (field as any)[fieldName] = value; this.forceUpdate(); };