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 16 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 @@ -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,50 @@
/*
* 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.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={Field} path="fields.value" />
</>
);
};
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, 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',
}),
},
};

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

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

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