From 0b111dca59421eabea67e6fe7316d8e65e14afaf Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 9 Apr 2021 01:45:30 +0200 Subject: [PATCH] [Ingest Pipelines] Add generated copy for all processors (#95507) (#96660) * - minor refactor of 'description' -> 'typeDescription' for generic processor descriptions - added initial pass of generated descriptions for all processors * fix i18n * added wrapping div and title to description and changed default description to appear as placeholder * reworked the description width and overflow styling * only show the text title on hover when we are not showing the text input * fixed a number of minor issues with using values as though they are strings and doing better serialization * slight optimisation to scss * - implement copy feedback - clean up a lot of uses of "target_field = field". it is better to not show these - made "replacement" a required field on gsub (which it was not) * revert the previouis validation as empty values are acceptbale for the replacement text * - updated the copy per feedback and fixed a missing i18n.translate - slight update to SCSS classes to not have unused class * Added an empty string field validator that accepts spaces so that the KV processor value and field split fields accept " " * replace use of HTML "title" with EuiToolTip * remove unused variable and import * implemented feedback; removed if from default descriptions and other minor updates * update default description of foreach to always display Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../inline_text_input.tsx | 14 +- .../pipeline_processors_editor_item.scss | 20 +- .../pipeline_processors_editor_item.tsx | 30 +- .../common_fields/processor_type_field.tsx | 2 +- .../processor_form/processors/kv.tsx | 9 +- .../processor_form/processors/shared.ts | 18 +- .../shared/map_processor_type_to_form.tsx | 384 +++++++++++++++--- 7 files changed, 404 insertions(+), 73 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/inline_text_input.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/inline_text_input.tsx index 1e10d650bed2a..cd7c91685467a 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/inline_text_input.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/inline_text_input.tsx @@ -7,7 +7,7 @@ import classNames from 'classnames'; import React, { useState, useEffect, useCallback, memo } from 'react'; -import { EuiFieldText, EuiText, keys } from '@elastic/eui'; +import { EuiFieldText, EuiText, keys, EuiToolTip } from '@elastic/eui'; export interface Props { placeholder: string; @@ -90,11 +90,13 @@ function _InlineTextInput({ tabIndex={disabled ? -1 : 0} onFocus={() => setIsShowingTextInput(true)} > - -
- {text || {placeholder}} -
-
+ + +
+ {text || {placeholder}} +
+
+
); } diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.scss b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.scss index 55630fa96d9b0..babecc5e5ea33 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.scss +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.scss @@ -43,7 +43,6 @@ overflow-x: hidden; white-space: nowrap; text-overflow: ellipsis; - max-width: 600px; } &__textInput { @@ -65,4 +64,23 @@ // Prevent content jump when spinner renders min-width: 15px; } + + &__controlsContainer { + // Make sure this element knows how wide it is + width: 100%; + // The last element in these controls is an editable text description that can contain an unknown amount (i.e., width) of text. + overflow: hidden; + } + + // By default, flex sets the element width to "auto", we set this explicitly again to avoid the flex item growing beyond the width given + // by flex. This applies to both of the classes below. + &__controlsFlexItem { + min-width: 0; + } + &__descriptionContainer { + min-width: 0; + &--displayNone { + display: none; + } + } } diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx index 27035a8d269f2..d1f6638eb12d6 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/pipeline_processors_editor_item/pipeline_processors_editor_item.tsx @@ -67,6 +67,8 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( const isMovingOtherProcessor = editor.mode.id === 'movingProcessor' && !isMovingThisProcessor; const isDimmed = isEditingOtherProcessor || isMovingOtherProcessor; + const processorDescriptor = getProcessorDescriptor(processor.type); + const { testPipelineData } = useTestPipelineContext(); const { config: { selectedDocumentIndex }, @@ -85,10 +87,14 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( 'pipelineProcessorsEditor__item--dimmed': isDimmed, }); - const inlineTextInputContainerClasses = classNames({ - // eslint-disable-next-line @typescript-eslint/naming-convention - 'pipelineProcessorsEditor__item--displayNone': isInMoveMode && !processor.options.description, - }); + const inlineTextInputContainerClasses = classNames( + 'pipelineProcessorsEditor__item__descriptionContainer', + { + // eslint-disable-next-line @typescript-eslint/naming-convention + 'pipelineProcessorsEditor__item__descriptionContainer--displayNone': + isInMoveMode && !processor.options.description, + } + ); const onDescriptionChange = useCallback( (nextDescription) => { @@ -167,8 +173,13 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( data-test-subj={selectorToDataTestSubject(selector)} data-processor-id={processor.id} > - - + + {renderMoveButton()} {isExecutingPipeline ? ( @@ -193,7 +204,7 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( }} data-test-subj="manageItemButton" > - {getProcessorDescriptor(processor.type)?.label ?? processor.type} + {processorDescriptor?.label ?? processor.type} @@ -203,7 +214,10 @@ export const PipelineProcessorsEditorItem: FunctionComponent = memo( onChange={onDescriptionChange} ariaLabel={i18nTexts.processorTypeLabel({ type: processor.type })} text={description} - placeholder={i18nTexts.descriptionPlaceholder} + placeholder={ + processorDescriptor?.getDefaultDescription(processor.options) ?? + i18nTexts.descriptionPlaceholder + } /> diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/processor_type_field.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/processor_type_field.tsx index 25d3e53073041..1160038b52af8 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/processor_type_field.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/common_fields/processor_type_field.tsx @@ -81,7 +81,7 @@ export const ProcessorTypeField: FunctionComponent = ({ initialType }) => const type = typeField.value; const processorDescriptor = getProcessorDescriptor(type); if (processorDescriptor) { - description = processorDescriptor.description || ''; + description = processorDescriptor.typeDescription || ''; selectedOptions = [{ label: processorDescriptor.label, value: type }]; } else { // If there is no label for this processor type, just use the type as the label diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/kv.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/kv.tsx index 694ae4e07070d..0c8a6ee9c9e29 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/kv.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/kv.tsx @@ -12,20 +12,17 @@ import { EuiCode } from '@elastic/eui'; import { FIELD_TYPES, - fieldValidators, UseField, Field, ComboBoxField, ToggleField, } from '../../../../../../shared_imports'; -import { FieldsConfig, from, to } from './shared'; +import { FieldsConfig, from, to, isEmptyString } from './shared'; import { FieldNameField } from './common_fields/field_name_field'; import { TargetField } from './common_fields/target_field'; import { IgnoreMissingField } from './common_fields/ignore_missing_field'; -const { emptyField } = fieldValidators; - const fieldsConfig: FieldsConfig = { /* Required fields config */ field_split: { @@ -45,7 +42,7 @@ const fieldsConfig: FieldsConfig = { ), validations: [ { - validator: emptyField( + validator: isEmptyString( i18n.translate('xpack.ingestPipelines.pipelineEditor.kvForm.fieldSplitRequiredError', { defaultMessage: 'A value is required.', }) @@ -70,7 +67,7 @@ const fieldsConfig: FieldsConfig = { ), validations: [ { - validator: emptyField( + validator: isEmptyString( i18n.translate('xpack.ingestPipelines.pipelineEditor.kvForm.valueSplitRequiredError', { defaultMessage: 'A value is required.', }) diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/shared.ts b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/shared.ts index bafba412c767f..9a45f7f0017c6 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/shared.ts +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/processor_form/processors/shared.ts @@ -10,7 +10,9 @@ import * as rt from 'io-ts'; import { i18n } from '@kbn/i18n'; import { isRight } from 'fp-ts/lib/Either'; -import { FieldConfig, ValidationFunc } from '../../../../../../shared_imports'; +import { FieldConfig, ValidationFunc, fieldValidators } from '../../../../../../shared_imports'; + +const { emptyField } = fieldValidators; export const arrayOfStrings = rt.array(rt.string); @@ -118,6 +120,20 @@ export const isJSONStringValidator: ValidationFunc = ({ value }) => { } }; +/** + * Similar to the emptyField validator but we accept whitespace characters. + */ +export const isEmptyString = (message: string): ValidationFunc => (field) => { + const { value } = field; + if (typeof value === 'string') { + const hasLength = Boolean(value.length); + const hasNonWhiteSpaceChars = hasLength && Boolean(value.trim().length); + if (hasNonWhiteSpaceChars) { + return emptyField(message)(field); + } + } +}; + export const EDITOR_PX_HEIGHT = { extraSmall: 75, small: 100, diff --git a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/shared/map_processor_type_to_form.tsx b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/shared/map_processor_type_to_form.tsx index 9095ab1927cb9..5ab2d68aa193f 100644 --- a/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/shared/map_processor_type_to_form.tsx +++ b/x-pack/plugins/ingest_pipelines/public/application/components/pipeline_editor/components/shared/map_processor_type_to_form.tsx @@ -56,7 +56,14 @@ interface FieldDescriptor { * A sentence case label that can be displayed to users */ label: string; - description?: string | ((esDocUrl: string) => ReactNode); + /** + * A general description of the processor type + */ + typeDescription?: string | ((esDocUrl: string) => ReactNode); + /** + * Default + */ + getDefaultDescription: (processorOptions: Record) => string | undefined; } type MapProcessorTypeToDescriptor = Record; @@ -68,10 +75,18 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.append', { defaultMessage: 'Append', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.append', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.append', { defaultMessage: "Appends values to a field's array. If the field contains a single value, the processor first converts it to an array. If the field doesn't exist, the processor creates an array containing the appended values.", }), + getDefaultDescription: ({ field, value }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.append', { + defaultMessage: 'Appends "{value}" to the "{field}" field', + values: { + field, + value, + }, + }), }, bytes: { FieldsComponent: Bytes, @@ -79,10 +94,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.bytes', { defaultMessage: 'Bytes', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.bytes', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.bytes', { defaultMessage: 'Converts digital storage units to bytes. For example, 1KB becomes 1024 bytes.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.bytes', { + defaultMessage: 'Converts "{field}" to its value in bytes', + values: { + field, + }, + }), }, circle: { FieldsComponent: Circle, @@ -90,9 +112,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.circle', { defaultMessage: 'Circle', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.circle', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.circle', { defaultMessage: 'Converts a circle definition into an approximate polygon.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.circle', { + defaultMessage: 'Converts a circle definition of "{field}" into an approximate polygon', + values: { + field, + }, + }), }, convert: { FieldsComponent: Convert, @@ -100,10 +129,18 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.convert', { defaultMessage: 'Convert', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.convert', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.convert', { defaultMessage: 'Converts a field to a different data type. For example, you can convert a string to an long.', }), + getDefaultDescription: ({ field, type }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.convert', { + defaultMessage: 'Converts "{field}" to type "{type}"', + values: { + field, + type, + }, + }), }, csv: { FieldsComponent: CSV, @@ -111,9 +148,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.csv', { defaultMessage: 'CSV', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.csv', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.csv', { defaultMessage: 'Extracts field values from CSV data.', }), + getDefaultDescription: ({ field, target_fields: targetFields }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.csv', { + defaultMessage: 'Extracts CSV values from "{field}" to {target_fields}', + values: { + field, + target_fields: targetFields.map((v: string) => `"${v}"`).join(', '), + }, + }), }, date: { FieldsComponent: DateProcessor, @@ -121,9 +166,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.date', { defaultMessage: 'Date', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.date', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.date', { defaultMessage: 'Converts a date to a document timestamp.', }), + getDefaultDescription: ({ field, target_field: targetField = '@timestamp' }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.date', { + defaultMessage: 'Parses a date from "{field}" to a date type on field "{target_field}"', + values: { + field, + target_field: targetField, + }, + }), }, date_index_name: { FieldsComponent: DateIndexName, @@ -131,13 +184,32 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.dateIndexName', { defaultMessage: 'Date index name', }), - description: () => ( + typeDescription: () => ( {'my-index-yyyy-MM-dd'} }} /> ), + getDefaultDescription: ({ field, index_name_prefix: indexNamePrefix }) => { + const prefix = indexNamePrefix + ? i18n.translate( + 'xpack.ingestPipelines.processors.defaultDescription.dateIndexName.indexNamePrefixDefault.prefixValueLabel', + { defaultMessage: 'with the prefix "{prefix}"', values: { prefix: indexNamePrefix } } + ) + : i18n.translate( + 'xpack.ingestPipelines.processors.defaultDescription.dateIndexName.indexNamePrefixDefault.noPrefixValueLabel', + { defaultMessage: 'with no prefix' } + ); + return i18n.translate('xpack.ingestPipelines.processors.defaultDescription.date_index_name', { + defaultMessage: + 'Adds documents to a time-based index based on the timestamp value in "{field}", {prefix}', + values: { + field, + prefix, + }, + }); + }, }, dissect: { FieldsComponent: Dissect, @@ -145,9 +217,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.dissect', { defaultMessage: 'Dissect', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.dissect', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.dissect', { defaultMessage: 'Uses dissect patterns to extract matches from a field.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.dissect', { + defaultMessage: 'Extracts values from "{field}" that match a dissect pattern', + values: { + field, + }, + }), }, dot_expander: { FieldsComponent: DotExpander, @@ -155,10 +234,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.dotExpander', { defaultMessage: 'Dot expander', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.dotExpander', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.dotExpander', { defaultMessage: 'Expands a field containing dot notation into an object field. The object field is then accessible by other processors in the pipeline.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.dot_expander', { + defaultMessage: 'Expands "{field}" into an object field', + values: { + field, + }, + }), }, drop: { FieldsComponent: Drop, @@ -166,10 +252,13 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.drop', { defaultMessage: 'Drop', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.drop', { - defaultMessage: - 'Drops documents without returning an error. Used to only index documents that meet specified conditions.', + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.drop', { + defaultMessage: 'Drops documents without returning an error.', }), + getDefaultDescription: () => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.drop', { + defaultMessage: 'Drops documents without returning an error', + }), }, enrich: { FieldsComponent: Enrich, @@ -177,7 +266,7 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.enrich', { defaultMessage: 'Enrich', }), - description: (esDocUrl) => { + typeDescription: (esDocUrl) => { return ( ); }, + getDefaultDescription: ({ field, policy_name: policyName, target_field: targetField }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.enrich', { + defaultMessage: + 'Enriches data to "{target_field}" if the "{policy_name}" policy matches "{field}"', + values: { + field, + policy_name: policyName, + target_field: targetField, + }, + }), }, fail: { FieldsComponent: Fail, @@ -199,10 +298,14 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.fail', { defaultMessage: 'Fail', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.fail', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.fail', { defaultMessage: 'Returns a custom error message on failure. Often used to notify requesters of required conditions.', }), + getDefaultDescription: () => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.fail', { + defaultMessage: 'Raises an exception that halts execution', + }), }, foreach: { FieldsComponent: Foreach, @@ -210,9 +313,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.foreach', { defaultMessage: 'Foreach', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.foreach', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.foreach', { defaultMessage: 'Applies an ingest processor to each value in an array.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.foreach', { + defaultMessage: 'Runs a processor for each object in "{field}"', + values: { + field, + }, + }), }, geoip: { FieldsComponent: GeoIP, @@ -220,10 +330,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.geoip', { defaultMessage: 'GeoIP', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.geoip', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.geoip', { defaultMessage: 'Adds geo data based on an IP address. Uses geo data from a Maxmind database file.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.geoip', { + defaultMessage: 'Adds geo data to documents based on the value of "{field}"', + values: { + field, + }, + }), }, grok: { FieldsComponent: Grok, @@ -231,7 +348,7 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.grok', { defaultMessage: 'Grok', }), - description: (esDocUrl) => { + typeDescription: (esDocUrl) => { return ( ); }, + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.grok', { + defaultMessage: 'Extracts values from "{field}" that match a grok pattern', + values: { + field, + }, + }), }, gsub: { FieldsComponent: Gsub, @@ -253,9 +377,18 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.gsub', { defaultMessage: 'Gsub', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.gsub', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.gsub', { defaultMessage: 'Uses a regular expression to replace field substrings.', }), + getDefaultDescription: ({ pattern, field, replacement }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.gsub', { + defaultMessage: 'Replaces values matching "{pattern}" in "{field}" with "{replacement}"', + values: { + pattern, + field, + replacement, + }, + }), }, html_strip: { FieldsComponent: HtmlStrip, @@ -263,9 +396,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.htmlStrip', { defaultMessage: 'HTML strip', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.htmlStrip', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.htmlStrip', { defaultMessage: 'Removes HTML tags from a field.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.html_strip', { + defaultMessage: 'Removes HTML tags from "{field}"', + values: { + field, + }, + }), }, inference: { FieldsComponent: Inference, @@ -273,10 +413,21 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.inference', { defaultMessage: 'Inference', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.inference', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.inference', { defaultMessage: 'Uses a pre-trained data frame analytics model to infer against incoming data.', }), + getDefaultDescription: ({ + model_id: modelId, + target_field: targetField = 'ml.inference.', + }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.inference', { + defaultMessage: 'Runs the model "{modelId}" and stores the result in "{target_field}"', + values: { + modelId, + target_field: targetField, + }, + }), }, join: { FieldsComponent: Join, @@ -284,10 +435,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.join', { defaultMessage: 'Join', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.join', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.join', { defaultMessage: 'Joins array elements into a string. Inserts a separator between each element.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.join', { + defaultMessage: 'Joins each element of the array stored in "{field}"', + values: { + field, + }, + }), }, json: { FieldsComponent: Json, @@ -295,9 +453,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.json', { defaultMessage: 'JSON', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.json', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.json', { defaultMessage: 'Creates a JSON object from a compatible string.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.json', { + defaultMessage: 'Parses "{field}" to create a JSON object from a string', + values: { + field, + }, + }), }, kv: { FieldsComponent: Kv, @@ -305,9 +470,19 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.kv', { defaultMessage: 'Key-value (KV)', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.kv', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.kv', { defaultMessage: 'Extracts fields from a string containing key-value pairs.', }), + getDefaultDescription: ({ field, field_split: fieldSplit, value_split: valueSplit }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.kv', { + defaultMessage: + 'Extracts key-value pairs from "{field}" and splits on "{field_split}" and "{value_split}"', + values: { + field, + field_split: fieldSplit, + value_split: valueSplit, + }, + }), }, lowercase: { FieldsComponent: Lowercase, @@ -315,9 +490,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.lowercase', { defaultMessage: 'Lowercase', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.lowercase', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.lowercase', { defaultMessage: 'Converts a string to lowercase.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.lowercase', { + defaultMessage: 'Converts values in "{field}" to lowercase', + values: { + field, + }, + }), }, pipeline: { FieldsComponent: Pipeline, @@ -325,9 +507,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.pipeline', { defaultMessage: 'Pipeline', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.pipeline', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.pipeline', { defaultMessage: 'Runs another ingest node pipeline.', }), + getDefaultDescription: ({ name }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.pipeline', { + defaultMessage: 'Runs the "{name}" ingest pipeline', + values: { + name, + }, + }), }, remove: { FieldsComponent: Remove, @@ -335,9 +524,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.remove', { defaultMessage: 'Remove', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.remove', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.remove', { defaultMessage: 'Removes one or more fields.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.remove', { + defaultMessage: 'Removes "{field}"', + values: { + field: Array.isArray(field) ? field.map((v) => `"${v}"`).join(', ') : field, + }, + }), }, rename: { FieldsComponent: Rename, @@ -345,9 +541,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.rename', { defaultMessage: 'Rename', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.rename', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.rename', { defaultMessage: 'Renames an existing field.', }), + getDefaultDescription: ({ field, target_field: targetField }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.rename', { + defaultMessage: 'Renames "{field}" to "{target_field}"', + values: { + field, + target_field: targetField, + }, + }), }, script: { FieldsComponent: Script, @@ -355,9 +559,10 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.script', { defaultMessage: 'Script', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.script', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.script', { defaultMessage: 'Runs a script on incoming documents.', }), + getDefaultDescription: () => 'Runs a script on incoming documents', }, set: { FieldsComponent: SetProcessor, @@ -365,9 +570,17 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.set', { defaultMessage: 'Set', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.set', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.set', { defaultMessage: 'Sets the value of a field.', }), + getDefaultDescription: ({ field, value }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.set', { + defaultMessage: 'Sets value of "{field}" to "{value}"', + values: { + field, + value, + }, + }), }, set_security_user: { FieldsComponent: SetSecurityUser, @@ -375,10 +588,18 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.setSecurityUser', { defaultMessage: 'Set security user', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.setSecurityUser', { - defaultMessage: - 'Adds details about the current user, such user name and email address, to incoming documents. Requires an authenticated user for the indexing request.', - }), + typeDescription: i18n.translate( + 'xpack.ingestPipelines.processors.description.setSecurityUser', + { + defaultMessage: + 'Adds details about the current user, such user name and email address, to incoming documents. Requires an authenticated user for the indexing request.', + } + ), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.setSecurityUser', { + defaultMessage: 'Adds details about the current user to "{field}"', + values: { field }, + }), }, sort: { FieldsComponent: Sort, @@ -386,9 +607,26 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.sort', { defaultMessage: 'Sort', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.sort', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.sort', { defaultMessage: "Sorts a field's array elements.", }), + getDefaultDescription: ({ field, order = 'asc' }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.sort', { + defaultMessage: 'Sorts elements in the array "{field}" in {order} order', + values: { + field, + order: + order === 'asc' + ? i18n.translate( + 'xpack.ingestPipelines.processors.defaultDescription.sort.orderAscendingLabel', + { defaultMessage: 'ascending' } + ) + : i18n.translate( + 'xpack.ingestPipelines.processors.defaultDescription.sort.orderDescendingLabel', + { defaultMessage: 'descending' } + ), + }, + }), }, split: { FieldsComponent: Split, @@ -396,9 +634,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.split', { defaultMessage: 'Split', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.split', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.split', { defaultMessage: 'Splits a field value into an array.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.split', { + defaultMessage: 'Splits the string stored in "{field}" to an array', + values: { + field, + }, + }), }, trim: { FieldsComponent: Trim, @@ -406,9 +651,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.trim', { defaultMessage: 'Trim', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.trim', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.trim', { defaultMessage: 'Removes leading and trailing whitespace from a string.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.trim', { + defaultMessage: 'Trims whitespaces from "{field}"', + values: { + field, + }, + }), }, uppercase: { FieldsComponent: Uppercase, @@ -416,9 +668,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.uppercase', { defaultMessage: 'Uppercase', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.uppercase', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.uppercase', { defaultMessage: 'Converts a string to uppercase.', }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.uppercase', { + defaultMessage: 'Converts values in "{field}" to uppercase', + values: { + field, + }, + }), }, urldecode: { FieldsComponent: UrlDecode, @@ -426,19 +685,16 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.urldecode', { defaultMessage: 'URL decode', }), - description: i18n.translate('xpack.ingestPipelines.processors.description.urldecode', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.urldecode', { defaultMessage: 'Decodes a URL-encoded string.', }), - }, - user_agent: { - FieldsComponent: UserAgent, - docLinkPath: '/user-agent-processor.html', - label: i18n.translate('xpack.ingestPipelines.processors.label.userAgent', { - defaultMessage: 'User agent', - }), - description: i18n.translate('xpack.ingestPipelines.processors.description.userAgent', { - defaultMessage: "Extracts values from a browser's user agent string.", - }), + getDefaultDescription: ({ field }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.url_decode', { + defaultMessage: 'Decodes the URL in "{field}"', + values: { + field, + }, + }), }, uri_parts: { FieldsComponent: UriParts, @@ -446,10 +702,38 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = { label: i18n.translate('xpack.ingestPipelines.processors.label.uriPartsLabel', { defaultMessage: 'URI parts', }), - description: i18n.translate('xpack.ingestPipelines.processors.uriPartsDescription', { + typeDescription: i18n.translate('xpack.ingestPipelines.processors.uriPartsDescription', { defaultMessage: 'Parses a Uniform Resource Identifier (URI) string and extracts its components as an object.', }), + getDefaultDescription: ({ field, target_field: targetField = 'url' }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.uri_parts', { + defaultMessage: + 'Parses the URI string in "{field}" and stores the result in "{target_field}"', + values: { + field, + target_field: targetField, + }, + }), + }, + user_agent: { + FieldsComponent: UserAgent, + docLinkPath: '/user-agent-processor.html', + label: i18n.translate('xpack.ingestPipelines.processors.label.userAgent', { + defaultMessage: 'User agent', + }), + typeDescription: i18n.translate('xpack.ingestPipelines.processors.description.userAgent', { + defaultMessage: "Extracts values from a browser's user agent string.", + }), + getDefaultDescription: ({ field, target_field: targetField = 'user_agent' }) => + i18n.translate('xpack.ingestPipelines.processors.defaultDescription.user_agent', { + defaultMessage: + 'Extracts the user agent from "{field}" and stores the results in "{target_field}"', + values: { + field, + target_field: targetField, + }, + }), }, };