Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
3c1e877
Initial commit
sebelga Aug 26, 2021
be1c329
Merge branch 'master' into index-pattern-field-editor/composite-runti…
kibanamachine Aug 30, 2021
b4dd1f9
Merge remote-tracking branch 'upstream/master' into index-pattern-fie…
sebelga Aug 31, 2021
1582a6d
Merge remote-tracking branch 'upstream/master' into index-pattern-fie…
sebelga Sep 1, 2021
691627c
Merge remote-tracking branch 'upstream/master' into index-pattern-fie…
sebelga Sep 6, 2021
a6e7eca
Merge remote-tracking branch 'upstream/master' into index-pattern-fie…
sebelga Sep 8, 2021
18ba720
[Runtime field editor] Composite runtime in Kibana Data Views (#110226)
sebelga Sep 9, 2021
c8505d3
Merge remote-tracking branch 'upstream/main' into index-pattern-field…
sebelga Nov 25, 2021
4506949
Apply updates from feature branch
sebelga Nov 25, 2021
e3a97f0
Merge remote-tracking branch 'upstream/main' into index-pattern-field…
sebelga Nov 25, 2021
2ef84e7
Merge remote-tracking branch 'upstream/main' into index-pattern-field…
sebelga Nov 29, 2021
5bac201
Fix TS issues
sebelga Nov 29, 2021
58c091a
Fix TS issue
sebelga Nov 29, 2021
46a4c8f
Fix TS issue
sebelga Nov 29, 2021
5606599
Fix jest tests
sebelga Nov 30, 2021
c34a988
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Feb 3, 2022
39669a7
fix jest tests
mattkime Feb 3, 2022
a83c0e9
fix integration test
mattkime Feb 3, 2022
6c66075
fix delete error test
mattkime Feb 3, 2022
75db8bc
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Feb 9, 2022
cbe6b30
partial progress
mattkime Feb 10, 2022
87272c5
partial progress
mattkime Feb 10, 2022
639418c
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Feb 11, 2022
8383b86
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Feb 24, 2022
f74bb48
remove mistaken change
mattkime Feb 24, 2022
7e18c33
fix import
mattkime Mar 2, 2022
3a1d6d1
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Mar 11, 2022
d03e7c1
remove unused translation
mattkime Mar 11, 2022
c786aeb
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Mar 17, 2022
e0efc25
Merge branch 'main' into index-pattern-field-editor/composite-runtime…
mattkime Mar 18, 2022
485d7ed
Merge branch 'main' into composite-runtime-field-editor
mattkime Mar 25, 2022
d35ac81
partial progress
mattkime May 11, 2022
1cdc916
Merge branch 'main' into composite-runtime-field-editor
mattkime May 11, 2022
01e9de5
merge
mattkime May 11, 2022
f22dcb2
Merge branch 'main' into composite-runtime-field-editor
mattkime Jun 19, 2022
98ab5bd
use preview api
mattkime Jun 20, 2022
3d38c21
cleanup
mattkime Jun 20, 2022
2b19a99
Merge branch 'main' into use_preview_api
mattkime Jun 24, 2022
502901b
Merge branch 'main' of github.com:elastic/kibana into use_preview_api
mattkime Jun 25, 2022
bbfacce
use specific index instead of index pattern
mattkime Jun 25, 2022
7a22d83
Merge branch 'use_preview_api' of github.com:mattkime/kibana into use…
mattkime Jun 25, 2022
3e67ced
fix jest test
mattkime Jun 25, 2022
5a0f7f7
one less any
mattkime Jun 25, 2022
a9a316d
Merge branch 'main' into use_preview_api
mattkime Jun 25, 2022
28b13ef
Merge branch 'use_preview_api' of github.com:mattkime/kibana into com…
mattkime Jun 26, 2022
0b8dc9b
Merge branch 'main' into composite-runtime-field-editor
mattkime Jun 27, 2022
aa13df7
setting type on composite subfields is roughly working
mattkime Jun 29, 2022
66c54a2
Merge branch 'main' into composite-runtime-field-editor
mattkime Jun 29, 2022
278e0d2
Merge branch 'main' into composite-runtime-field-editor
mattkime Jul 12, 2022
9627dbe
Merge branch 'main' into composite-runtime-field-editor
mattkime Jul 15, 2022
31352c4
Merge branch 'main' into composite-runtime-field-editor
mattkime Jul 18, 2022
9219af6
Merge branch 'main' into composite-runtime-field-editor
mattkime Jul 20, 2022
8e8975c
partial progress
mattkime Jul 21, 2022
8f1d842
setState not working
mattkime Jul 22, 2022
63d7153
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 22, 2022
81184e7
partial progress
mattkime Jul 27, 2022
c2db769
working but a bit wonky
mattkime Jul 28, 2022
aad4b77
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Jul 28, 2022
f31a2b0
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Jul 29, 2022
e56c761
merge
mattkime Jul 29, 2022
49e9360
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Jul 29, 2022
cd620c6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 29, 2022
312261a
fix handing of field types, remove some console.log statements
mattkime Jul 29, 2022
0e50831
fix initial type for subfields
mattkime Jul 29, 2022
7f61cd8
fix subfield type updates, rename some vars
mattkime Jul 29, 2022
f5c6c8d
fix breakage from bad merge
mattkime Jul 29, 2022
7edaa58
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Jul 29, 2022
e50a6d9
fix types
mattkime Jul 30, 2022
363004c
type fixes
mattkime Jul 31, 2022
ccb3ef1
cleanup
mattkime Jul 31, 2022
edf7da6
i18n fix
mattkime Jul 31, 2022
075d4df
i18n fix
mattkime Jul 31, 2022
88a540f
i18n fix
mattkime Jul 31, 2022
a18eed0
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Jul 31, 2022
5e84955
comment cleanup
mattkime Aug 1, 2022
5f9bdb9
remove unused var
mattkime Aug 1, 2022
a4d24c9
add code comment
mattkime Aug 1, 2022
2be2229
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 1, 2022
105e404
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 2, 2022
550c43b
remove comments
mattkime Aug 2, 2022
facfc13
fix jest test
mattkime Aug 2, 2022
e6f3036
add start of functional test
mattkime Aug 2, 2022
059106d
functional test:
mattkime Aug 3, 2022
17b1d45
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 3, 2022
78e4ac2
composite subfield preview
mattkime Aug 3, 2022
220383d
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 3, 2022
f21c9bd
add functional test
mattkime Aug 4, 2022
7cbf055
functional tests
mattkime Aug 5, 2022
3d30916
functional tests
mattkime Aug 6, 2022
b5ce58f
rendering improvements
mattkime Aug 6, 2022
ce7d5fc
functional tests
mattkime Aug 6, 2022
2cdc3b1
functional tests
mattkime Aug 6, 2022
be886d7
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 7, 2022
4ad20ae
add jest test
mattkime Aug 8, 2022
4947d9b
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 8, 2022
0a77a2e
add jest test
mattkime Aug 9, 2022
f44ff57
move to observables
mattkime Aug 11, 2022
e2949f9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 11, 2022
0a9ce5c
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 11, 2022
051896b
cleanup
mattkime Aug 12, 2022
b39c692
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Aug 12, 2022
8ae2450
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 12, 2022
9080136
better use of form lib
mattkime Aug 12, 2022
3cbb7b1
type fixes
mattkime Aug 12, 2022
e68950f
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 12, 2022
2c1850d
cleanup
mattkime Aug 13, 2022
10f9472
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 13, 2022
7b59a93
add refresh button
mattkime Aug 13, 2022
81d75df
remove ts ignore
mattkime Aug 13, 2022
a1f352c
improve dev docs
mattkime Aug 14, 2022
921cc4a
internationalize text
mattkime Aug 14, 2022
41b4718
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 14, 2022
a819f1a
type fix
mattkime Aug 14, 2022
95a7992
delete should warn regarding subfields
mattkime Aug 14, 2022
b489de6
typescript fix
mattkime Aug 14, 2022
e07249b
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 14, 2022
aacb884
redraws of FieldEditor would reset diff state. This fixes it.
mattkime Aug 15, 2022
e7297b4
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Aug 15, 2022
062d792
add placeholder text to code editor
mattkime Aug 15, 2022
bf4c3ef
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 16, 2022
fad4dd1
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 16, 2022
a12278d
hook cleanup
mattkime Aug 16, 2022
fde44a4
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Aug 16, 2022
e0173ed
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 19, 2022
3a67a90
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 23, 2022
6723896
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 27, 2022
beffe1d
Merge branch 'composite-runtime-field-editor_v2' of github.com:mattki…
mattkime Aug 30, 2022
20358f6
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Aug 30, 2022
dce9901
add getFieldPreviewChanges jest test
mattkime Aug 30, 2022
d352b1a
add getFieldPreviewChanges jest test
mattkime Aug 30, 2022
8faae79
keep parent name in sync with preview when changed during script update
mattkime Sep 1, 2022
8c7af5c
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Sep 1, 2022
a754e80
fix test
mattkime Sep 1, 2022
4479598
move subfields to observables
mattkime Sep 6, 2022
e32976d
fix jest tests
mattkime Sep 7, 2022
8f4f16a
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Sep 7, 2022
f518638
fix jest tests
mattkime Sep 7, 2022
075098f
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Sep 8, 2022
0cad9fe
fix save after field type change to composite
mattkime Sep 9, 2022
7e1c9d4
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Sep 11, 2022
83b3324
previewFields to behaviorSubject
mattkime Sep 11, 2022
e260d2e
fix test
mattkime Sep 11, 2022
ff82723
Merge branch 'main' into composite-runtime-field-editor_v2
mattkime Sep 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('<FieldEditor />', () => {
expect(lastState.submit).toBeDefined();

const { data: formData } = await submitFormAndGetData(lastState);
expect(formData).toEqual(field);
expect(formData).toEqual({ ...field, format: null });

// Make sure that both isValid and isSubmitted state are now "true"
lastState = getLastStateUpdate();
Expand All @@ -128,7 +128,10 @@ describe('<FieldEditor />', () => {
onChange,
},
{
namesNotAllowed: existingFields,
namesNotAllowed: {
fields: existingFields,
runtimeComposites: [],
},
existingConcreteFields: [],
fieldTypeToProcess: 'runtime',
}
Expand Down Expand Up @@ -165,7 +168,10 @@ describe('<FieldEditor />', () => {
onChange,
},
{
namesNotAllowed: existingRuntimeFieldNames,
namesNotAllowed: {
fields: existingRuntimeFieldNames,
runtimeComposites: [],
},
existingConcreteFields: [],
fieldTypeToProcess: 'runtime',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('<FieldEditorFlyoutContent />', () => {

expect(onSave).toHaveBeenCalled();
const fieldReturned = onSave.mock.calls[onSave.mock.calls.length - 1][0];
expect(fieldReturned).toEqual(field);
expect(fieldReturned).toEqual({ ...field, format: null });
});

test('should accept an onCancel prop', async () => {
Expand Down Expand Up @@ -149,6 +149,7 @@ describe('<FieldEditorFlyoutContent />', () => {
name: 'someName',
type: 'keyword', // default to keyword
script: { source: 'echo("hello")' },
format: null,
});

// Change the type and make sure it is forwarded
Expand All @@ -165,6 +166,7 @@ describe('<FieldEditorFlyoutContent />', () => {
name: 'someName',
type: 'date',
script: { source: 'echo("hello")' },
format: null,
});
});

Expand Down Expand Up @@ -202,6 +204,7 @@ describe('<FieldEditorFlyoutContent />', () => {
name: 'someName',
type: 'keyword',
script: { source: 'echo("hello")' },
format: null,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,48 @@ describe('Field editor Preview panel', () => {
expect(exists('previewNotAvailableCallout')).toBe(true);
});
});

describe('composite runtime field', () => {
test('should display composite editor when composite type is selected', async () => {
testBed = await setup();
const {
exists,
actions: { fields, waitForUpdates },
} = testBed;
fields.updateType('composite', 'Composite');
await waitForUpdates();
expect(exists('compositeEditor')).toBe(true);
});

test('should show composite field types and update appropriately', async () => {
httpRequestsMockHelpers.setFieldPreviewResponse({ values: { 'composite_field.a': [1] } });
testBed = await setup();
const {
exists,
actions: { fields, waitForUpdates },
} = testBed;
await fields.updateType('composite', 'Composite');
await fields.updateScript("emit('a',1)");
await waitForUpdates();
expect(exists('typeField_0')).toBe(true);

// increase the number of fields
httpRequestsMockHelpers.setFieldPreviewResponse({
values: { 'composite_field.a': [1], 'composite_field.b': [1] },
});
await fields.updateScript("emit('a',1); emit('b',1)");
await waitForUpdates();
expect(exists('typeField_0')).toBe(true);
expect(exists('typeField_1')).toBe(true);

// decrease the number of fields
httpRequestsMockHelpers.setFieldPreviewResponse({
values: { 'composite_field.a': [1] },
});
await fields.updateScript("emit('a',1)");
await waitForUpdates();
expect(exists('typeField_0')).toBe(true);
expect(exists('typeField_1')).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import './jest.mocks';
import React, { FunctionComponent } from 'react';
import { merge } from 'lodash';

import { defer } from 'rxjs';
import { defer, BehaviorSubject } from 'rxjs';
import { notificationServiceMock, uiSettingsServiceMock } from '@kbn/core/public/mocks';
import { dataPluginMock } from '@kbn/data-plugin/public/mocks';
import { fieldFormatsMock as fieldFormats } from '@kbn/field-formats-plugin/common/mocks';
Expand All @@ -21,6 +21,7 @@ import { FieldEditorProvider, Context } from '../../../public/components/field_e
import { FieldPreviewProvider } from '../../../public/components/preview';
import { initApi, ApiService } from '../../../public/lib';
import { init as initHttpRequests } from './http_requests';
import { RuntimeFieldSubFields } from '../../../public/shared_imports';

const dataStart = dataPluginMock.createStartContract();
const { search } = dataStart;
Expand Down Expand Up @@ -124,7 +125,7 @@ export const WithFieldEditorDependencies =
uiSettings: uiSettingsServiceMock.createStartContract(),
fieldTypeToProcess: 'runtime',
existingConcreteFields: [],
namesNotAllowed: [],
namesNotAllowed: { fields: [], runtimeComposites: [] },
links: {
runtimePainless: 'https://elastic.co',
},
Expand All @@ -138,6 +139,8 @@ export const WithFieldEditorDependencies =
getById: () => undefined,
},
fieldFormats,
fieldName$: new BehaviorSubject(''),
subfields$: new BehaviorSubject<RuntimeFieldSubFields | undefined>(undefined),
};

const mergedDependencies = merge({}, dependencies, overridingDependencies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ import { CloseEditor } from '../types';
type DeleteFieldFunc = (fieldName: string | string[]) => void;
export interface Props {
children: (deleteFieldHandler: DeleteFieldFunc) => React.ReactNode;
/**
* Data view of fields to be deleted
*/
dataView: DataView;
/**
* Callback fired when fields are deleted
* @param fieldNames - the names of the deleted fields
*/
onDelete?: (fieldNames: string[]) => void;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import React from 'react';
import {
EuiNotificationBadge,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiText,
EuiFieldText,
EuiComboBox,
EuiFormRow,
EuiButtonEmpty,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import useObservable from 'react-use/lib/useObservable';
import { FormattedMessage } from '@kbn/i18n-react';
import { ScriptField } from './form_fields';
import { useFieldEditorContext } from '../field_editor_context';
import { RUNTIME_FIELD_OPTIONS_PRIMITIVE } from './constants';
import { valueToComboBoxOption } from './lib';
import { RuntimePrimitiveTypes } from '../../shared_imports';

export interface CompositeEditorProps {
onReset: () => void;
}

export const CompositeEditor = ({ onReset }: CompositeEditorProps) => {
const { links, existingConcreteFields, subfields$ } = useFieldEditorContext();
const subfields = useObservable(subfields$) || {};

return (
<div data-test-subj="compositeEditor">
<ScriptField
existingConcreteFields={existingConcreteFields}
links={links}
placeholder={"emit('field_name', 'hello world');"}
/>
<EuiSpacer size="xl" />
<>
<EuiFlexGroup gutterSize="s" alignItems="center" justifyContent="spaceBetween">
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiText size="s">
<FormattedMessage
id="indexPatternFieldEditor.editor.compositeFieldsCount"
defaultMessage="Generated fields"
/>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiNotificationBadge color="subdued">
{Object.entries(subfields).length}
</EuiNotificationBadge>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiButtonEmpty flush="right" iconType="refresh" onClick={onReset}>
<FormattedMessage
id="indexPatternFieldEditor.editor.compositeRefreshTypes"
defaultMessage="Reset"
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
{Object.entries(subfields).map(([key, itemValue], idx) => {
return (
<div>
<EuiFlexGroup gutterSize="s">
<EuiFlexItem>
<EuiFieldText value={key} disabled={true} />
</EuiFlexItem>
<EuiFlexItem>
<EuiFormRow fullWidth>
<EuiComboBox
placeholder={i18n.translate(
'indexPatternFieldEditor.editor.form.runtimeType.placeholderLabel',
{
defaultMessage: 'Select a type',
}
)}
singleSelection={{ asPlainText: true }}
options={RUNTIME_FIELD_OPTIONS_PRIMITIVE}
selectedOptions={[valueToComboBoxOption(itemValue.type)!]}
onChange={(newValue) => {
if (newValue.length === 0) {
// Don't allow clearing the type. One must always be selected
return;
}
// update the type for the given field
subfields[key] = { type: newValue[0].value! as RuntimePrimitiveTypes };

subfields$.next({ ...subfields });
}}
isClearable={false}
data-test-subj={`typeField_${idx}`}
aria-label={i18n.translate(
'indexPatternFieldEditor.editor.form.typeSelectAriaLabel',
{
defaultMessage: 'Type select',
}
)}
fullWidth
/>
</EuiFormRow>
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
})}
</>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import type { EuiComboBoxOptionOption } from '@elastic/eui';
import { RuntimeType } from '../../shared_imports';

export const RUNTIME_FIELD_OPTIONS: Array<EuiComboBoxOptionOption<RuntimeType>> = [
export const RUNTIME_FIELD_OPTIONS_PRIMITIVE: Array<EuiComboBoxOptionOption<RuntimeType>> = [
{
label: 'Keyword',
value: 'keyword',
Expand Down Expand Up @@ -39,3 +39,11 @@ export const RUNTIME_FIELD_OPTIONS: Array<EuiComboBoxOptionOption<RuntimeType>>
value: 'geo_point',
},
];

export const RUNTIME_FIELD_OPTIONS = [
...RUNTIME_FIELD_OPTIONS_PRIMITIVE,
{
label: 'Composite',
value: 'composite',
} as EuiComboBoxOptionOption<RuntimeType>,
];
Loading