Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ingest Pipelines] Processor forms for processors E-J #75054

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fa0e795
Added the enrich processor form (big one)
jloleysens Aug 13, 2020
3c9ad7a
added fail processor form
jloleysens Aug 13, 2020
9ce24ce
Added foreach processor form
jloleysens Aug 13, 2020
02fbb2b
Added geoip processor form and refactored some deserialization
jloleysens Aug 13, 2020
b748cd8
added grok processor form and updated comments and some i18n ids
jloleysens Aug 14, 2020
970939c
updated existing gsub processor form to be in line with other forms
jloleysens Aug 14, 2020
1e12a63
added html_strip processor form
jloleysens Aug 14, 2020
c4d39a0
refactored some serialize and deserialize functions and added inferen…
jloleysens Aug 14, 2020
32b1d46
fix copy-pasta mistake in inference form and add join processor form
jloleysens Aug 14, 2020
13f37b4
Added JSON processor field
jloleysens Aug 14, 2020
cedbd88
remove unused variable
jloleysens Aug 14, 2020
ac6483e
Refactor to use new shared target_field component, and fix JSON seria…
jloleysens Aug 14, 2020
0bbfab1
fix i18n
jloleysens Aug 17, 2020
469d804
Merge branch 'master' into ingest-pipelines/processors-forms-ej
elasticmachine Aug 17, 2020
4592909
Merge branch 'master' into ingest-pipelines/processors-forms-ej
elasticmachine Aug 18, 2020
3e83391
Merge branch 'master' into ingest-pipelines/processors-forms-ej
elasticmachine Aug 19, 2020
6ecf830
address pr feedback
jloleysens Aug 19, 2020
5718f77
Fix enrich max fields help text copy
jloleysens Aug 20, 2020
e633d92
Merge branch 'master' into ingest-pipelines/processors-forms-ej
elasticmachine Aug 20, 2020
40be085
add link to enrich policy docs in help text
jloleysens Aug 20, 2020
70cc6f7
fix error validation message in enrich policy form and replace space …
jloleysens Aug 20, 2020
1ad0f2e
address copy feedback
jloleysens Aug 20, 2020
4030a99
fix i18n id typo
jloleysens Aug 20, 2020
721119d
fix i18n
jloleysens Aug 20, 2020
aea2c0b
Merge branch 'master' into ingest-pipelines/processors-forms-ej
elasticmachine Aug 20, 2020
56642c2
address additional round of feedback and fix json form help text
jloleysens Aug 20, 2020
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 @@ -5,7 +5,7 @@
*/

import React, { FunctionComponent } from 'react';
import { EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
import { EuiHorizontalRule } from '@elastic/eui';

import { FormDataProvider } from '../../../../../shared_imports';
import { ProcessorInternal } from '../../types';
Expand Down Expand Up @@ -36,7 +36,7 @@ export const ProcessorSettingsFields: FunctionComponent<Props> = ({ processor })
return (
<>
<formDescriptor.FieldsComponent />
<EuiSpacer size="m" />
<EuiHorizontalRule />
<CommonProcessorFields />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import {
ComboBoxField,
} from '../../../../../../shared_imports';

import { FieldsConfig } from './shared';
import { FieldsConfig, to } from './shared';
import { FieldNameField } from './common_fields/field_name_field';

const { emptyField } = fieldValidators;

const fieldsConfig: FieldsConfig = {
value: {
type: FIELD_TYPES.COMBO_BOX,
deserializer: (v) => (Array.isArray(v) ? v : [String(v)]),
deserializer: to.arrayOfStrings,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.appendForm.valueFieldLabel', {
defaultMessage: 'Value',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@
import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';

import { FIELD_TYPES, UseField, Field } from '../../../../../../shared_imports';

import { FieldsConfig } from './shared';
import { IgnoreMissingField } from './common_fields/ignore_missing_field';
import { FieldNameField } from './common_fields/field_name_field';

const fieldsConfig: FieldsConfig = {
target_field: {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.bytesForm.targetFieldLabel', {
defaultMessage: 'Target field (optional)',
}),
helpText: i18n.translate('xpack.ingestPipelines.pipelineEditor.bytesForm.targetFieldHelpText', {
defaultMessage: 'The field to assign the converted value to',
}),
},
};
import { TargetField } from './common_fields/target_field';

export const Bytes: FunctionComponent = () => {
return (
Expand All @@ -35,7 +21,7 @@ export const Bytes: FunctionComponent = () => {
)}
/>

<UseField config={fieldsConfig.target_field} component={Field} path="fields.target_field" />
<TargetField />

<IgnoreMissingField />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,19 @@ import {
FIELD_TYPES,
fieldValidators,
UseField,
Field,
SelectField,
NumericField,
} from '../../../../../../shared_imports';

import { FieldsConfig } from './shared';
import { IgnoreMissingField } from './common_fields/ignore_missing_field';
import { FieldNameField } from './common_fields/field_name_field';
import { TargetField } from './common_fields/target_field';

const { emptyField } = fieldValidators;

const fieldsConfig: FieldsConfig = {
target_field: {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.targetFieldLabel', {
defaultMessage: 'Target field (optional)',
}),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.targetFieldHelpText',
{
defaultMessage: 'By default field is updated in-place.',
}
),
},
/* Required fields config */
error_distance: {
type: FIELD_TYPES.NUMBER,
deserializer: (v) => (typeof v === 'number' && !isNaN(v) ? v : 1.0),
Expand Down Expand Up @@ -71,6 +60,7 @@ const fieldsConfig: FieldsConfig = {
},
shape_type: {
type: FIELD_TYPES.SELECT,
serializer: String,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeFieldLabel', {
defaultMessage: 'Shape type',
}),
Expand Down Expand Up @@ -132,7 +122,7 @@ export const Circle: FunctionComponent = () => {
path="fields.shape_type"
/>

<UseField config={fieldsConfig.target_field} component={Field} path="fields.target_field" />
<TargetField />

<IgnoreMissingField />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ import {
} from '../../../../../../../shared_imports';

import { TextEditor } from '../../field_components';
import { to, from } from '../shared';

const ignoreFailureConfig: FieldConfig = {
defaultValue: false,
serializer: (v) => (v === false ? undefined : v),
deserializer: (v) => (typeof v === 'boolean' ? v : undefined),
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.ignoreFailureFieldLabel',
{
Expand Down Expand Up @@ -62,7 +63,7 @@ export const CommonProcessorFields: FunctionComponent = () => {
component={TextEditor}
componentProps={{
editorProps: {
language: 'painless',
languageId: 'painless',
height: 75,
options: { minimap: { enabled: false } },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,47 @@
*/
import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FIELD_TYPES, UseField, ToggleField } from '../../../../../../../shared_imports';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCode } from '@elastic/eui';

import { FieldsConfig } from '../shared';
import {
FIELD_TYPES,
UseField,
ToggleField,
FieldConfig,
} from '../../../../../../../shared_imports';

import { FieldsConfig, to, from } from '../shared';

export const fieldsConfig: FieldsConfig = {
ignore_missing: {
type: FIELD_TYPES.TOGGLE,
defaultValue: false,
serializer: (v) => (v === false ? undefined : v),
deserializer: (v) => (typeof v === 'boolean' ? v : undefined),
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.ignoreMissingFieldLabel',
{
defaultMessage: 'Ignore missing',
}
),
helpText: (
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.commonFields.ignoreMissingFieldHelpText"
defaultMessage="Ignore documents with a missing {field}"
values={{
field: <EuiCode>{'field'}</EuiCode>,
}}
/>
),
},
};

interface Props {
helpText?: string;
}
type Props = Partial<FieldConfig>;

export const IgnoreMissingField: FunctionComponent<Props> = ({ helpText }) => (
export const IgnoreMissingField: FunctionComponent<Props> = (props) => (
<UseField
config={{ ...fieldsConfig.ignore_missing, helpText }}
config={{ ...fieldsConfig.ignore_missing, ...props }}
component={ToggleField}
path="fields.ignore_missing"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';

import { Field, FIELD_TYPES, UseField, FieldConfig } from '../../../../../../../shared_imports';

import { FieldsConfig } from '../shared';

const fieldsConfig: FieldsConfig = {
target_field: {
type: FIELD_TYPES.TEXT,
deserializer: String,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.commonFields.targetFieldLabel', {
defaultMessage: 'Target field (optional)',
}),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.targetFieldHelpText',
{
defaultMessage:
'The field to assign the joined value to. If empty, the field is updated in-place.',
}
),
},
};

type Props = Partial<FieldConfig>;

export const TARGET_FIELD_PATH = 'fields.target_field';

export const TargetField: FunctionComponent<Props> = (props) => {
return (
<UseField
config={{
...fieldsConfig.target_field,
...props,
}}
component={Field}
path={TARGET_FIELD_PATH}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
FIELD_TYPES,
fieldValidators,
UseField,
Field,
SelectField,
} from '../../../../../../shared_imports';

import { FieldsConfig } from './shared';
import { FieldNameField } from './common_fields/field_name_field';
import { IgnoreMissingField } from './common_fields/ignore_missing_field';
import { TargetField } from './common_fields/target_field';

const { emptyField } = fieldValidators;

Expand All @@ -42,19 +42,6 @@ const fieldsConfig: FieldsConfig = {
},
],
},
/* Optional fields config */
target_field: {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldLabel', {
defaultMessage: 'Target field (optional)',
}),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldHelpText',
{
defaultMessage: 'The field to assign the converted value to.',
}
),
},
};

export const Convert: FunctionComponent = () => {
Expand Down Expand Up @@ -128,7 +115,14 @@ export const Convert: FunctionComponent = () => {
path="fields.type"
/>

<UseField config={fieldsConfig.target_field} component={Field} path="fields.target_field" />
<TargetField
helpText={i18n.translate(
'xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldHelpText',
{
defaultMessage: 'The field to assign the converted value to.',
}
)}
/>

<IgnoreMissingField />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FieldsConfig } from './shared';
import { IgnoreMissingField } from './common_fields/ignore_missing_field';
import { FieldNameField } from './common_fields/field_name_field';

import { isArrayOfStrings } from './shared';
import { to } from './shared';

const { minLengthField } = fieldValidators;

Expand All @@ -47,9 +47,7 @@ const fieldsConfig: FieldsConfig = {
/* Required fields config */
target_fields: {
type: FIELD_TYPES.COMBO_BOX,
deserializer: (v) => {
return isArrayOfStrings(v) ? v : [];
},
deserializer: to.arrayOfStrings,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.csvForm.targetFieldsFieldLabel', {
defaultMessage: 'Target fields',
}),
Expand Down Expand Up @@ -112,7 +110,7 @@ const fieldsConfig: FieldsConfig = {
trim: {
type: FIELD_TYPES.TOGGLE,
defaultValue: false,
deserializer: (v) => (typeof v === 'boolean' ? v : undefined),
deserializer: to.booleanOrUndef,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.csvForm.trimFieldLabel', {
defaultMessage: 'Trim',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ import {
ComboBoxField,
} from '../../../../../../shared_imports';

import { FieldsConfig, isArrayOfStrings } from './shared';
import { FieldsConfig, to } from './shared';
import { FieldNameField } from './common_fields/field_name_field';
import { TargetField } from './common_fields/target_field';

const { minLengthField } = fieldValidators;

const fieldsConfig: FieldsConfig = {
/* Required fields config */
formats: {
type: FIELD_TYPES.COMBO_BOX,
deserializer: (v) => {
return isArrayOfStrings(v) ? v : [];
},
deserializer: to.arrayOfStrings,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.dateForm.formatsFieldLabel', {
defaultMessage: 'Formats',
}),
Expand All @@ -51,22 +50,6 @@ const fieldsConfig: FieldsConfig = {
],
},
/* Optional fields config */
target_field: {
type: FIELD_TYPES.TEXT,
serializer: (v) => (v ? undefined : v),
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.dateForm.targetFieldFieldLabel', {
defaultMessage: 'Target field (optional)',
}),
helpText: (
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.dateForm.targetFieldHelpText"
defaultMessage="The field that will hold the parsed date. Default field is {defaultField}."
values={{
defaultField: <EuiCode inline>{'@timestamp'}</EuiCode>,
}}
/>
),
},
timezone: {
type: FIELD_TYPES.TEXT,
serializer: (v) => (v ? v : undefined),
Expand Down Expand Up @@ -112,7 +95,17 @@ export const DateProcessor: FunctionComponent = () => {

<UseField config={fieldsConfig.formats} component={ComboBoxField} path="fields.formats" />

<UseField config={fieldsConfig.target_field} component={Field} path="fields.target_field" />
<TargetField
helpText={
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.dateForm.targetFieldHelpText"
defaultMessage="The field that will hold the parsed date. Default field is {defaultField}."
values={{
defaultField: <EuiCode inline>{'@timestamp'}</EuiCode>,
}}
/>
}
/>

<UseField config={fieldsConfig.timezone} component={Field} path="fields.timezone" />

Expand Down
Loading