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 A-D #72849

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e120f03
First few processors of the first batch
jloleysens Jul 20, 2020
71274a3
add type to shared imports
jloleysens Jul 21, 2020
1621eb8
Refactors for repeated fields and added forms
jloleysens Jul 22, 2020
9691f9e
Merge branch 'master' into ingest-pipelines/processor-forms-a-d
elasticmachine Jul 22, 2020
0dad23e
Merge branch 'master' into ingest-pipelines/processor-forms-a-d
elasticmachine Jul 23, 2020
9952f9b
Merge branch 'master' into ingest-pipelines/processor-forms-a-d
elasticmachine Aug 6, 2020
1a52d64
Merge branch 'master' into ingest-pipelines/processor-forms-a-d
elasticmachine Aug 10, 2020
97eea65
Merge branch 'master' of github.com:elastic/kibana into ingest-pipeli…
jloleysens Aug 11, 2020
8160f85
Fix broken imports and some other small refactors
jloleysens Aug 11, 2020
0bcd67a
added text editor field and updated pattern and if fields
jloleysens Aug 11, 2020
1555486
Large copy improvements and updates and other small refactors
jloleysens Aug 12, 2020
7059261
update circle shape type field to select
jloleysens Aug 12, 2020
a529e38
Added "long" option for convert type
jloleysens Aug 12, 2020
bbbe9d2
Merge branch 'master' of github.com:elastic/kibana into ingest-pipeli…
jloleysens Aug 12, 2020
106701f
fix path import
jloleysens Aug 12, 2020
5ff03ea
fix types and i18n
jloleysens Aug 12, 2020
acc54d7
add validation for dot expander fix append value to be a combobox
jloleysens Aug 13, 2020
023543b
Merge branch 'master' into ingest-pipelines/processor-forms-a-d
elasticmachine Aug 13, 2020
a6a0e1b
fix i18n
jloleysens Aug 13, 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 @@ -7,6 +7,17 @@
import { i18n } from '@kbn/i18n';
import { FunctionComponent } from 'react';

import { Append } from './processors/append';
import { Bytes } from './processors/bytes';
import { Circle } from './processors/circle';
import { Convert } from './processors/convert';
import { CSV } from './processors/csv';
import { DateProcessor } from './processors/date';
import { DateIndexName } from './processors/date_index_name';
import { Dissect } from './processors/dissect';
import { DotExpander } from './processors/dot_expander';
import { Drop } from './processors/drop';

// import { SetProcessor } from './processors/set';
// import { Gsub } from './processors/gsub';

Expand All @@ -21,70 +32,70 @@ interface FieldsFormDescriptor {

const mapProcessorTypeToFormDescriptor: Record<string, FieldsFormDescriptor> = {
append: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Append,
docLinkPath: '/append-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.append', {
defaultMessage: 'Append',
}),
},
bytes: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Bytes,
docLinkPath: '/bytes-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.bytes', {
defaultMessage: 'Bytes',
}),
},
circle: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Circle,
docLinkPath: '/ingest-circle-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.circle', {
defaultMessage: 'Circle',
}),
},
convert: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Convert,
docLinkPath: '/convert-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.convert', {
defaultMessage: 'Convert',
}),
},
csv: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: CSV,
docLinkPath: '/csv-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.csv', {
defaultMessage: 'CSV',
}),
},
date: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: DateProcessor,
docLinkPath: '/date-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.date', {
defaultMessage: 'Date',
}),
},
date_index_name: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: DateIndexName,
docLinkPath: '/date-index-name-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.dateIndexName', {
defaultMessage: 'Date Index Name',
}),
},
dissect: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Dissect,
docLinkPath: '/dissect-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.dissect', {
defaultMessage: 'Dissect',
}),
},
dot_expander: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: DotExpander,
docLinkPath: '/dot-expand-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.dotExpander', {
defaultMessage: 'Dot Expander',
}),
},
drop: {
FieldsComponent: undefined, // TODO: Implement
FieldsComponent: Drop,
docLinkPath: '/drop-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.drop', {
defaultMessage: 'Drop',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ export const ProcessorSettingsForm: FunctionComponent<Props> = ({
const handleSubmit = useCallback(
async (data: FormData, isValid: boolean) => {
if (isValid) {
const { type, customOptions, ...options } = data;
const { type, customOptions, fields } = data;
onSubmit({
type,
options: customOptions ? customOptions : options,
options: customOptions ? customOptions : fields,
});
}
},
[onSubmit]
);

const { form } = useForm({
defaultValue: processor?.options,
defaultValue: { fields: processor?.options },
onSubmit: handleSubmit,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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_TYPES, fieldValidators, UseField, Field } from '../../../../../../shared_imports';

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

const { emptyField } = fieldValidators;

const fieldsConfig: FieldsConfig = {
value: {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.setForm.valueFieldLabel', {
defaultMessage: 'Value',
}),
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.setForm.valueRequiredError', {
defaultMessage: 'A value to set is required.',
})
),
},
],
},
};

export const Append: FunctionComponent = () => {
return (
<>
<FieldNameField />

<UseField config={fieldsConfig.value} component={Field} path="fields.value" />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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_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',
}),
},
};

export const Bytes: FunctionComponent = () => {
return (
<>
<FieldNameField />

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

<IgnoreMissingField />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* 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_TYPES,
fieldValidators,
UseField,
Field,
RadioGroupField,
NumericField,
} from '../../../../../../shared_imports';

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

const { emptyField } = fieldValidators;

const fieldsConfig: FieldsConfig = {
target_field: {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.targetFieldLabel', {
defaultMessage: 'Target field',
}),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.targetFieldHelpText',
{
defaultMessage: 'By default field is updated in-place.',
}
),
},
ignore_missing: {
type: FIELD_TYPES.TOGGLE,
defaultValue: false,
deserializer: (v) => (typeof v === 'boolean' ? v : undefined),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.ignoreMissingFieldLabel',
{
defaultMessage: 'Ignore missing',
}
),
},
error_distance: {
type: FIELD_TYPES.NUMBER,
deserializer: (v) => (typeof v === 'number' && !isNaN(v) ? v : 1.0),
serializer: Number,
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceFieldLabel',
{
defaultMessage: 'Error distance',
}
),
validations: [
{
validator: ({ value }) => {
return isNaN(Number(value))
jloleysens marked this conversation as resolved.
Show resolved Hide resolved
? {
message: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceError',
{
defaultMessage: 'An error distance value is required.',
}
),
}
: undefined;
},
},
],
},
shape_type: {
type: FIELD_TYPES.RADIO_GROUP,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeFieldLabel', {
defaultMessage: 'Shape type',
}),
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeRequiredError', {
defaultMessage: 'A shape type value is required.',
})
),
},
],
},
};

export const Circle: FunctionComponent = () => {
return (
<>
<FieldNameField />

<UseField
componentProps={{
euiFieldProps: {
options: [
{
id: 'shape',
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeShape',
{ defaultMessage: 'Shape' }
),
},
{
id: 'geo_shape',
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeGeoShape',
{ defaultMessage: 'Geo-shape' }
),
},
],
},
}}
config={fieldsConfig.shape_type}
component={RadioGroupField}
path="fields.shape_type"
/>

<UseField
config={fieldsConfig.error_distance}
component={NumericField}
path="fields.error_distance"
/>

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

<IgnoreMissingField />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {

const ignoreFailureConfig: FieldConfig = {
defaultValue: false,
serializer: (v) => (v === false ? undefined : v),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.ignoreFailureFieldLabel',
{
Expand All @@ -27,15 +28,13 @@ const ignoreFailureConfig: FieldConfig = {
};

const ifConfig: FieldConfig = {
defaultValue: undefined,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.commonFields.ifFieldLabel', {
defaultMessage: 'Condition (optional)',
}),
type: FIELD_TYPES.TEXT,
};

const tagConfig: FieldConfig = {
defaultValue: undefined,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.commonFields.tagFieldLabel', {
defaultMessage: 'Tag (optional)',
}),
Expand All @@ -45,11 +44,11 @@ const tagConfig: FieldConfig = {
export const CommonProcessorFields: FunctionComponent = () => {
return (
<>
<UseField config={ignoreFailureConfig} component={ToggleField} path={'ignore_failure'} />
<UseField config={ignoreFailureConfig} component={ToggleField} path="fields.ignore_failure" />

<UseField config={ifConfig} component={Field} path={'if'} />
<UseField config={ifConfig} component={Field} path="fields.if" />

<UseField config={tagConfig} component={Field} path={'tag'} />
<UseField config={tagConfig} component={Field} path="fields.tag" />
</>
);
};
Loading