Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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…
Nov 25, 2021
4506949
Apply updates from feature branch
Nov 25, 2021
e3a97f0
Merge remote-tracking branch 'upstream/main' into index-pattern-field…
Nov 25, 2021
2ef84e7
Merge remote-tracking branch 'upstream/main' into index-pattern-field…
Nov 29, 2021
5bac201
Fix TS issues
Nov 29, 2021
58c091a
Fix TS issue
Nov 29, 2021
46a4c8f
Fix TS issue
Nov 29, 2021
5606599
Fix jest tests
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
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
1 change: 1 addition & 0 deletions src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export type {
FieldFormatMap,
RuntimeType,
RuntimeField,
RuntimeFieldSpec,
IIndexPattern,
DataViewAttributes,
IndexPatternAttributes,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export type {
IndexPatternLoadExpressionFunctionDefinition,
GetFieldsOptions,
AggregationRestrictions,
RuntimeType,
DataViewListItem,
} from '../common';
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('<FieldEditor />', () => {
test('should accept a defaultValue and onChange prop to forward the form state', async () => {
const field = {
name: 'foo',
type: 'date',
type: 'date' as const,
script: { source: 'emit("hello")' },
};

Expand All @@ -113,7 +113,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 @@ -129,7 +129,10 @@ describe('<FieldEditor />', () => {
onChange,
},
{
namesNotAllowed: existingFields,
namesNotAllowed: {
fields: existingFields,
runtimeComposites: [],
},
existingConcreteFields: [],
fieldTypeToProcess: 'runtime',
}
Expand Down Expand Up @@ -166,7 +169,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 @@ -40,7 +40,7 @@ describe('<FieldEditorFlyoutContent />', () => {
test('should allow a field to be provided', async () => {
const field = {
name: 'foo',
type: 'ip',
type: 'ip' as const,
script: {
source: 'emit("hello world")',
},
Expand All @@ -57,7 +57,7 @@ describe('<FieldEditorFlyoutContent />', () => {
test('should accept an "onSave" prop', async () => {
const field = {
name: 'foo',
type: 'date',
type: 'date' as const,
script: { source: 'test=123' },
};
const onSave: jest.Mock<Props['onSave']> = jest.fn();
Expand All @@ -72,7 +72,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 @@ -133,6 +133,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 @@ -149,6 +150,7 @@ describe('<FieldEditorFlyoutContent />', () => {
name: 'someName',
type: 'date',
script: { source: 'echo("hello")' },
format: null,
});
});

Expand Down Expand Up @@ -186,6 +188,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 @@ -220,7 +220,7 @@ describe('Field editor Preview panel', () => {
test('should **not** display an empty prompt editing a document with a script', async () => {
const field = {
name: 'foo',
type: 'ip',
type: 'ip' as const,
script: {
source: 'emit("hello world")',
},
Expand All @@ -241,7 +241,7 @@ describe('Field editor Preview panel', () => {
test('should **not** display an empty prompt editing a document with format defined', async () => {
const field = {
name: 'foo',
type: 'ip',
type: 'ip' as const,
format: {
id: 'upper',
params: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const WithFieldEditorDependencies =
uiSettings: uiSettingsServiceMock.createStartContract(),
fieldTypeToProcess: 'runtime',
existingConcreteFields: [],
namesNotAllowed: [],
namesNotAllowed: { fields: [], runtimeComposites: [] },
links: {
runtimePainless: 'https://elastic.co',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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';

export const CompositeEditor = () => <>hi</>;
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ export const RUNTIME_FIELD_OPTIONS: Array<EuiComboBoxOptionOption<RuntimeType>>
label: 'Geo point',
value: 'geo_point',
},
{
label: 'Composite',
value: 'composite',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { EuiCode } from '@elastic/eui';
import { AdvancedParametersSection } from './advanced_parameters_section';
import { FormRow } from './form_row';
import { PopularityField, FormatField, ScriptField, CustomLabelField } from './form_fields';
import { useFieldEditorContext } from '../field_editor_context';

const geti18nTexts = (): {
[key: string]: { title: string; description: JSX.Element | string };
} => ({
customLabel: {
title: i18n.translate('indexPatternFieldEditor.editor.form.customLabelTitle', {
defaultMessage: 'Set custom label',
}),
description: i18n.translate('indexPatternFieldEditor.editor.form.customLabelDescription', {
defaultMessage: `Create a label to display in place of the field name in Discover, Maps, and Visualize. Useful for shortening a long field name. Queries and filters use the original field name.`,
}),
},
value: {
title: i18n.translate('indexPatternFieldEditor.editor.form.valueTitle', {
defaultMessage: 'Set value',
}),
description: (
<FormattedMessage
id="indexPatternFieldEditor.editor.form.valueDescription"
defaultMessage="Set a value for the field instead of retrieving it from the field with the same name in {source}."
values={{
source: <EuiCode>{'_source'}</EuiCode>,
}}
/>
),
},

format: {
title: i18n.translate('indexPatternFieldEditor.editor.form.formatTitle', {
defaultMessage: 'Set format',
}),
description: i18n.translate('indexPatternFieldEditor.editor.form.formatDescription', {
defaultMessage: `Set your preferred format for displaying the value. Changing the format can affect the value and prevent highlighting in Discover.`,
}),
},

popularity: {
title: i18n.translate('indexPatternFieldEditor.editor.form.popularityTitle', {
defaultMessage: 'Set popularity',
}),
description: i18n.translate('indexPatternFieldEditor.editor.form.popularityDescription', {
defaultMessage: `Adjust the popularity to make the field appear higher or lower in the fields list. By default, Discover orders fields from most selected to least selected.`,
}),
},
});

export const FieldDetail = ({}) => {
const { links, existingConcreteFields, fieldTypeToProcess } = useFieldEditorContext();
const i18nTexts = geti18nTexts();
return (
<>
{/* Set custom label */}
<FormRow
title={i18nTexts.customLabel.title}
description={i18nTexts.customLabel.description}
formFieldPath="__meta__.isCustomLabelVisible"
data-test-subj="customLabelRow"
withDividerRule
>
<CustomLabelField />
</FormRow>

{/* Set value */}
{fieldTypeToProcess === 'runtime' && (
<FormRow
title={i18nTexts.value.title}
description={i18nTexts.value.description}
formFieldPath="__meta__.isValueVisible"
data-test-subj="valueRow"
withDividerRule
>
<ScriptField existingConcreteFields={existingConcreteFields} links={links} />
</FormRow>
)}

{/* Set custom format */}
<FormRow
title={i18nTexts.format.title}
description={i18nTexts.format.description}
formFieldPath="__meta__.isFormatVisible"
data-test-subj="formatRow"
withDividerRule
>
<FormatField />
</FormRow>

{/* Advanced settings */}
<AdvancedParametersSection>
<FormRow
title={i18nTexts.popularity.title}
description={i18nTexts.popularity.description}
formFieldPath="__meta__.isPopularityVisible"
data-test-subj="popularityRow"
withDividerRule
>
<PopularityField />
</FormRow>
</AdvancedParametersSection>
</>
);
};
Loading