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 #75046

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
b1a970e
Added the enrich processor form (big one)
jloleysens Aug 13, 2020
afe633f
added fail processor form
jloleysens Aug 13, 2020
f94c045
Added foreach processor form
jloleysens Aug 13, 2020
9e83a95
Added geoip processor form and refactored some deserialization
jloleysens Aug 13, 2020
960747c
added grok processor form and updated comments and some i18n ids
jloleysens Aug 14, 2020
5c40bf8
updated existing gsub processor form to be in line with other forms
jloleysens Aug 14, 2020
3f3c45f
added html_strip processor form
jloleysens Aug 14, 2020
2fa58df
refactored some serialize and deserialize functions and added inferen…
jloleysens Aug 14, 2020
4e2b33b
fix copy-pasta mistake in inference form and add join processor form
jloleysens Aug 14, 2020
9933916
Added JSON processor field
jloleysens Aug 14, 2020
daed879
remove unused variable
jloleysens Aug 14, 2020
0daae40
Refactor to use new shared target_field component, and fix JSON seria…
jloleysens Aug 14, 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 @@ -4,4 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { OnXJsonEditorUpdateHandler, XJsonEditor } from './xjson_editor';
export { XJsonEditor } from './xjson_editor';
export { TextEditor } from './text_editor';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 { EuiPanel } from '@elastic/eui';
import React, { FunctionComponent } from 'react';
import { EuiFormRow } from '@elastic/eui';
import {
CodeEditor,
FieldHook,
getFieldValidityAndErrorMessage,
} from '../../../../../../shared_imports';

interface Props {
field: FieldHook<string>;
editorProps: { [key: string]: any };
}

export const TextEditor: FunctionComponent<Props> = ({ field, editorProps }) => {
const { value, helpText, setValue, label } = field;
const { errorMessage } = getFieldValidityAndErrorMessage(field);

return (
<EuiFormRow
label={label}
helpText={helpText}
isInvalid={typeof errorMessage === 'string'}
error={errorMessage}
fullWidth
>
<EuiPanel paddingSize="s" hasShadow={false}>
<CodeEditor value={value} onChange={setValue} {...(editorProps as any)} />
</EuiPanel>
</EuiFormRow>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,20 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiPanel } from '@elastic/eui';
import { XJsonLang } from '@kbn/monaco';
import React, { FunctionComponent, useCallback } from 'react';
import { EuiFormRow } from '@elastic/eui';
import {
CodeEditor,
FieldHook,
getFieldValidityAndErrorMessage,
Monaco,
} from '../../../../../../shared_imports';
import { FieldHook, Monaco } from '../../../../../../shared_imports';

export type OnXJsonEditorUpdateHandler<T = { [key: string]: any }> = (arg: {
data: {
raw: string;
format(): T;
};
validate(): boolean;
isValid: boolean | undefined;
}) => void;
import { TextEditor } from './text_editor';

interface Props {
field: FieldHook<string>;
editorProps: { [key: string]: any };
}

export const XJsonEditor: FunctionComponent<Props> = ({ field, editorProps }) => {
const { value, helpText, setValue, label } = field;
const { value, setValue } = field;
const { xJson, setXJson, convertToJson } = Monaco.useXJsonMode(value);
const { errorMessage } = getFieldValidityAndErrorMessage(field);

const onChange = useCallback(
(s) => {
Expand All @@ -42,25 +27,18 @@ export const XJsonEditor: FunctionComponent<Props> = ({ field, editorProps }) =>
[setValue, setXJson, convertToJson]
);
return (
<EuiFormRow
label={label}
helpText={helpText}
isInvalid={typeof errorMessage === 'string'}
error={errorMessage}
fullWidth
>
<EuiPanel paddingSize="s" hasShadow={false}>
<CodeEditor
value={xJson}
languageId={XJsonLang.ID}
editorDidMount={(m) => {
XJsonLang.registerGrammarChecker(m);
}}
options={{ minimap: { enabled: false } }}
onChange={onChange}
{...(editorProps as any)}
/>
</EuiPanel>
</EuiFormRow>
<TextEditor
field={field}
editorProps={{
value: xJson,
languageId: XJsonLang.ID,
options: { minimap: { enabled: false } },
editorDidMount: (m: any) => {
XJsonLang.registerGrammarChecker(m);
},
onChange,
...editorProps,
}}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ export const ManageProcessorForm: 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 maybeProcessorOptions = processor?.options;
const { form } = useForm({
defaultValue: processor?.options,
defaultValue: { fields: maybeProcessorOptions ?? {} },
onSubmit: handleSubmit,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
EuiFlyoutHeader,
EuiFlyoutBody,
EuiFlyoutFooter,
EuiSpacer,
EuiTabs,
EuiTab,
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
} from '@elastic/eui';

import { Form, FormDataProvider, FormHook } from '../../../../../shared_imports';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

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

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

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: to.arrayOfStrings,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.appendForm.valueFieldLabel', {
defaultMessage: 'Value',
}),
helpText: i18n.translate('xpack.ingestPipelines.pipelineEditor.appendForm.valueFieldHelpText', {
defaultMessage: 'The value to be appended by this processor.',
}),
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.appendForm.valueRequiredError', {
defaultMessage: 'A value to set is required.',
})
),
},
],
},
};

export const Append: FunctionComponent = () => {
return (
<>
<FieldNameField
helpText={i18n.translate('xpack.ingestPipelines.pipelineEditor.appendForm.fieldHelpText', {
defaultMessage: 'The field to be appended to.',
})}
/>

<UseField config={fieldsConfig.value} component={ComboBoxField} path="fields.value" />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { IgnoreMissingField } from './common_fields/ignore_missing_field';
import { FieldNameField } from './common_fields/field_name_field';
import { TargetField } from './common_fields/target_field';

export const Bytes: FunctionComponent = () => {
return (
<>
<FieldNameField
helpText={i18n.translate(
'xpack.ingestPipelines.pipelineEditor.bytesForm.fieldNameHelpText',
{ defaultMessage: 'The field to convert.' }
)}
/>

<TargetField />

<IgnoreMissingField />
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* 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,
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 = {
/* Required fields config */
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',
}
),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceHelpText',
{
defaultMessage:
'The difference between the resulting inscribed distance from center to side and the circle’s radius (measured in meters for geo_shape, unit-less for shape).',
}
),
validations: [
{
validator: ({ value }) => {
return isNaN(Number(value))
? {
message: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.errorDistanceError',
{
defaultMessage: 'An error distance value is required.',
}
),
}
: undefined;
},
},
],
},
shape_type: {
type: FIELD_TYPES.SELECT,
serializer: String,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeFieldLabel', {
defaultMessage: 'Shape type',
}),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeFieldHelpText',
{ defaultMessage: 'Which field mapping type is to be used.' }
),
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.circleForm.shapeTypeRequiredError', {
defaultMessage: 'A shape type value is required.',
})
),
},
],
},
};

export const Circle: FunctionComponent = () => {
return (
<>
<FieldNameField
helpText={i18n.translate(
'xpack.ingestPipelines.pipelineEditor.circleForm.fieldNameHelpText',
{ defaultMessage: 'The string-valued field to trim whitespace from.' }
)}
/>

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

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

<TargetField />

<IgnoreMissingField />
</>
);
};
Loading