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

[7.x] [Ingest Pipelines] Processor forms for processors K-S (#75638) #76762

Merged
merged 2 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -14,6 +14,11 @@ interface Props {
editorProps: { [key: string]: any };
}

const defaultEditorOptions = {
minimap: { enabled: false },
lineNumbers: 'off',
};

export const XJsonEditor: FunctionComponent<Props> = ({ field, editorProps }) => {
const { value, setValue } = field;
const { xJson, setXJson, convertToJson } = Monaco.useXJsonMode(value);
Expand All @@ -31,7 +36,7 @@ export const XJsonEditor: FunctionComponent<Props> = ({ field, editorProps }) =>
editorProps={{
value: xJson,
languageId: XJsonLang.ID,
options: { minimap: { enabled: false } },
options: defaultEditorOptions,
onChange,
...editorProps,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,22 @@ export const ProcessorSettingsFields: FunctionComponent<Props> = ({ processor })
const formDescriptor = getProcessorDescriptor(type as any);

if (formDescriptor?.FieldsComponent) {
const renderedFields = (
<formDescriptor.FieldsComponent
key={type}
initialFieldValues={processor?.options}
/>
);
return (
<>
<formDescriptor.FieldsComponent key={type} />
<EuiHorizontalRule />
{renderedFields ? (
<>
{renderedFields}
<EuiHorizontalRule />
</>
) : (
renderedFields
)}
<CommonProcessorFields />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {
} from '../../../../../../../shared_imports';

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

const ignoreFailureConfig: FieldConfig = {
defaultValue: false,
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
serializer: from.undefinedIfValue(false),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.ignoreFailureFieldLabel',
{
Expand Down Expand Up @@ -64,8 +64,11 @@ export const CommonProcessorFields: FunctionComponent = () => {
componentProps={{
editorProps: {
languageId: 'painless',
height: 75,
options: { minimap: { enabled: false } },
height: EDITOR_PX_HEIGHT.extraSmall,
options: {
lineNumbers: 'off',
minimap: { enabled: false },
},
},
}}
path="fields.if"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const fieldsConfig: FieldsConfig = {
type: FIELD_TYPES.TOGGLE,
defaultValue: false,
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
serializer: from.undefinedIfValue(false),
label: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.ignoreMissingFieldLabel',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ const fieldsConfig: FieldsConfig = {
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.',
defaultMessage: 'Field to assign the value to. If empty, the field is updated in-place.',
}
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
const { emptyField, isJsonField } = fieldValidators;

import { XJsonEditor } from '../field_components';
import { EDITOR_PX_HEIGHT } from './shared';

const customConfig: FieldConfig = {
type: FIELD_TYPES.TEXT,
Expand Down Expand Up @@ -78,7 +79,7 @@ export const Custom: FunctionComponent<Props> = ({ defaultOptions }) => {
componentProps={{
editorProps: {
'data-test-subj': 'processorOptionsEditor',
height: 300,
height: EDITOR_PX_HEIGHT.large,
'aria-label': i18n.translate(
'xpack.ingestPipelines.pipelineEditor.customForm.optionsFieldAriaLabel',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {

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

const { emptyField } = fieldValidators;

Expand Down Expand Up @@ -80,7 +81,7 @@ export const Dissect: FunctionComponent = () => {
component={TextEditor}
componentProps={{
editorProps: {
height: 75,
height: EDITOR_PX_HEIGHT.extraSmall,
options: { minimap: { enabled: false } },
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const fieldsConfig: FieldsConfig = {
type: FIELD_TYPES.TOGGLE,
defaultValue: true,
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef,
serializer: from.undefinedIfValue,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.enrichForm.overrideFieldLabel', {
defaultMessage: 'Override',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FIELD_TYPES, fieldValidators, UseField } from '../../../../../../shared
import { XJsonEditor } from '../field_components';

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

const { emptyField, isJsonField } = fieldValidators;

Expand All @@ -31,15 +31,18 @@ const fieldsConfig: FieldsConfig = {
validations: [
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.failForm.processorRequiredError', {
defaultMessage: 'A processor is required.',
})
i18n.translate(
'xpack.ingestPipelines.pipelineEditor.foreachForm.processorRequiredError',
{
defaultMessage: 'A processor is required.',
}
)
),
},
{
validator: isJsonField(
i18n.translate(
'xpack.ingestPipelines.pipelineEditor.failForm.processorInvalidJsonError',
'xpack.ingestPipelines.pipelineEditor.foreachForm.processorInvalidJsonError',
{
defaultMessage: 'Invalid JSON',
}
Expand All @@ -64,9 +67,9 @@ export const Foreach: FunctionComponent = () => {
component={XJsonEditor}
componentProps={{
editorProps: {
height: 200,
height: EDITOR_PX_HEIGHT.medium,
'aria-label': i18n.translate(
'xpack.ingestPipelines.pipelineEditor.customForm.optionsFieldAriaLabel',
'xpack.ingestPipelines.pipelineEditor.foreachForm.optionsFieldAriaLabel',
{
defaultMessage: 'Configuration JSON editor',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const fieldsConfig: FieldsConfig = {
type: FIELD_TYPES.TOGGLE,
defaultValue: true,
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(true),
serializer: from.undefinedIfValue(true),
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.geoIPForm.firstOnlyFieldLabel', {
defaultMessage: 'First only',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { XJsonEditor } from '../field_components';

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

const { emptyField, isJsonField } = fieldValidators;

Expand Down Expand Up @@ -80,7 +80,7 @@ const fieldsConfig: FieldsConfig = {
type: FIELD_TYPES.TOGGLE,
defaultValue: false,
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
serializer: from.undefinedIfValue(false),
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.grokForm.traceMatchFieldLabel', {
defaultMessage: 'Trace match',
}),
Expand Down Expand Up @@ -110,7 +110,7 @@ export const Grok: FunctionComponent = () => {
config={fieldsConfig.pattern_definitions}
componentProps={{
editorProps: {
height: 200,
height: EDITOR_PX_HEIGHT.medium,
'aria-label': i18n.translate(
'xpack.ingestPipelines.pipelineEditor.grokForm.patternDefinitionsAriaLabel',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FIELD_TYPES, fieldValidators, UseField, Field } from '../../../../../..

import { TextEditor } from '../field_components';

import { FieldsConfig } from './shared';
import { EDITOR_PX_HEIGHT, 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';
Expand Down Expand Up @@ -78,7 +78,7 @@ export const Gsub: FunctionComponent = () => {
component={TextEditor}
componentProps={{
editorProps: {
height: 75,
height: EDITOR_PX_HEIGHT.extraSmall,
options: { minimap: { enabled: false } },
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ export { HtmlStrip } from './html_strip';
export { Inference } from './inference';
export { Join } from './join';
export { Json } from './json';
export { Kv } from './kv';
export { Lowercase } from './lowercase';
export { Pipeline } from './pipeline';
export { Remove } from './remove';
export { Rename } from './rename';
export { Script } from './script';
export { SetProcessor } from './set';
export { SetSecurityUser } from './set_security_user';
export { Split } from './split';
export { Sort } from './sort';

export { FormFieldsComponent } from './shared';
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { XJsonEditor } from '../field_components';

import { TargetField } from './common_fields/target_field';

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

const { emptyField, isJsonField } = fieldValidators;

Expand Down Expand Up @@ -177,7 +177,7 @@ export const Inference: FunctionComponent = () => {
component={XJsonEditor}
componentProps={{
editorProps: {
height: 200,
height: EDITOR_PX_HEIGHT.medium,
options: { minimap: { enabled: false } },
},
}}
Expand All @@ -192,7 +192,7 @@ export const Inference: FunctionComponent = () => {
component={XJsonEditor}
componentProps={{
editorProps: {
height: 200,
height: EDITOR_PX_HEIGHT.medium,
options: { minimap: { enabled: false } },
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const fieldsConfig: FieldsConfig = {
{
validator: emptyField(
i18n.translate('xpack.ingestPipelines.pipelineEditor.joinForm.separatorRequiredError', {
defaultMessage: 'A separator value is required.',
defaultMessage: 'A value is required.',
})
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const fieldsConfig: FieldsConfig = {
defaultMessage: 'Add to root',
}),
deserializer: to.booleanOrUndef,
serializer: from.defaultBoolToUndef(false),
serializer: from.undefinedIfValue(false),
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.jsonForm.addToRootFieldHelpText',
{
Expand Down
Loading