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] Add descriptions for ingest processors E-J #76113

Merged
merged 9 commits into from
Sep 8, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
import { EuiComboBox, EuiComboBoxOptionOption, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { FunctionComponent } from 'react';
import React, { FunctionComponent, ReactNode } from 'react';
import { flow } from 'fp-ts/lib/function';
import { map } from 'fp-ts/lib/Array';

Expand Down Expand Up @@ -68,13 +68,18 @@ export const ProcessorTypeField: FunctionComponent<Props> = ({ initialType }) =>
<UseField<string> config={typeConfig} defaultValue={initialType} path="type">
{(typeField) => {
let selectedOptions: ProcessorTypeAndLabel[];
let description: string | ReactNode = '';

if (typeField.value?.length) {
const type = typeField.value;
const descriptor = getProcessorDescriptor(type);
selectedOptions = descriptor
? [{ label: descriptor.label, value: type }]
: // If there is no label for this processor type, just use the type as the label
[{ label: type, value: type }];
const processorDescriptor = getProcessorDescriptor(type);
if (processorDescriptor) {
description = processorDescriptor.description || '';
selectedOptions = [{ label: processorDescriptor.label, value: type }];
} else {
// If there is no label for this processor type, just use the type as the label
selectedOptions = [{ label: type, value: type }];
}
} else {
selectedOptions = [];
}
Expand Down Expand Up @@ -102,9 +107,7 @@ export const ProcessorTypeField: FunctionComponent<Props> = ({ initialType }) =>
<EuiFormRow
label={typeField.label}
labelAppend={typeField.labelAppend}
helpText={
typeof typeField.helpText === 'function' ? typeField.helpText() : typeField.helpText
}
helpText={typeof description === 'function' ? description() : description}
error={error}
isInvalid={isInvalid}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const fieldsConfig: FieldsConfig = {
helpText: i18n.translate(
'xpack.ingestPipelines.pipelineEditor.commonFields.targetFieldHelpText',
{
defaultMessage: 'Field to assign the value to. If empty, the field is updated in-place.',
defaultMessage: 'Output field. If empty, the input field is updated in place.',
}
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCode } from '@elastic/eui';

import { FIELD_TYPES, fieldValidators, UseField, Field } from '../../../../../../shared_imports';

Expand Down Expand Up @@ -87,17 +85,7 @@ export const Gsub: FunctionComponent = () => {

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

<TargetField
helpText={
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.gsubForm.targetFieldHelpText"
defaultMessage="Field used to contain updated text. Defaults to {field}."
values={{
field: <EuiCode>{'field'}</EuiCode>,
}}
/>
}
/>
<TargetField />

<IgnoreMissingField />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCode } from '@elastic/eui';

import { FieldNameField } from './common_fields/field_name_field';
import { IgnoreMissingField } from './common_fields/ignore_missing_field';
Expand All @@ -23,15 +21,7 @@ export const HtmlStrip: FunctionComponent = () => {
)}
/>

<TargetField
helpText={
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.htmlStripForm.targetFieldHelpText"
defaultMessage="Field used to contain stripped text. Defaults to {field}."
values={{ field: <EuiCode>{'field'}</EuiCode> }}
/>
}
/>
<TargetField />

<IgnoreMissingField />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import React, { FunctionComponent } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiCode } from '@elastic/eui';

import { FIELD_TYPES, fieldValidators, UseField, Field } from '../../../../../../shared_imports';

Expand Down Expand Up @@ -55,17 +53,7 @@ export const Join: FunctionComponent = () => {

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

<TargetField
helpText={
<FormattedMessage
id="xpack.ingestPipelines.pipelineEditor.joinForm.targetFieldHelpText"
defaultMessage="Field used to contain the joined value. Defaults to {field}."
values={{
field: <EuiCode>{'field'}</EuiCode>,
}}
/>
}
/>
<TargetField />
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ export const Json: FunctionComponent = () => {
)}
/>

<TargetField
helpText={i18n.translate(
'xpack.ingestPipelines.pipelineEditor.jsonForm.targetFieldHelpText',
{ defaultMessage: 'Field used to contain the JSON object.' }
)}
/>
<TargetField />

<UseField
config={fieldsConfig.add_to_root}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*/

import { i18n } from '@kbn/i18n';
import React, { ReactNode } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiLink } from '@elastic/eui';
import { useKibana } from '../../../../../shared_imports';

import {
Append,
Expand Down Expand Up @@ -47,6 +51,7 @@ interface FieldDescriptor {
* A sentence case label that can be displayed to users
*/
label: string;
description?: string | ReactNode;
}

type MapProcessorTypeToDescriptor = Record<string, FieldDescriptor>;
Expand Down Expand Up @@ -128,69 +133,135 @@ export const mapProcessorTypeToDescriptor: MapProcessorTypeToDescriptor = {
label: i18n.translate('xpack.ingestPipelines.processors.label.enrich', {
defaultMessage: 'Enrich',
}),
description: function Description() {
const {
services: { documentation },
} = useKibana();
const esDocUrl = documentation.getEsDocsBasePath();
return (
<FormattedMessage
id="xpack.ingestPipelines.processors.description.enrich"
defaultMessage="Adds enrich data to incoming documents based on an {enrichPolicyLink}."
values={{
enrichPolicyLink: (
<EuiLink external target="_blank" href={esDocUrl + '/ingest-enriching-data.html'}>
{'enrich policy'}
</EuiLink>
),
}}
/>
);
},
},
fail: {
FieldsComponent: Fail,
docLinkPath: '/fail-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.fail', {
defaultMessage: 'Fail',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.fail', {
defaultMessage:
'Returns a custom error message on failure. Often used to notify requesters of required conditions.',
}),
},
foreach: {
FieldsComponent: Foreach,
docLinkPath: '/foreach-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.foreach', {
defaultMessage: 'Foreach',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.foreach', {
defaultMessage: 'Applies an ingest processor to each value in an array.',
}),
},
geoip: {
FieldsComponent: GeoIP,
docLinkPath: '/geoip-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.geoip', {
defaultMessage: 'GeoIP',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.geoip', {
defaultMessage:
'Adds geo data based on an IP address. Uses geo data from a Maxmind database file.',
}),
},
grok: {
FieldsComponent: Grok,
docLinkPath: '/grok-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.grok', {
defaultMessage: 'Grok',
}),
description: function Description() {
const {
services: { documentation },
} = useKibana();
const esDocUrl = documentation.getEsDocsBasePath();
return (
<FormattedMessage
id="xpack.ingestPipelines.processors.description.grok"
defaultMessage="Uses {grokLink} expressions to extract matches from a field."
values={{
grokLink: (
<EuiLink external target="_blank" href={esDocUrl + '/grok-processor.html'}>
{'grok'}
</EuiLink>
),
}}
/>
);
},
},
gsub: {
FieldsComponent: Gsub,
docLinkPath: '/gsub-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.gsub', {
defaultMessage: 'Gsub',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.gsub', {
defaultMessage: 'Uses a regular expression to replace field substrings.',
}),
},
html_strip: {
FieldsComponent: HtmlStrip,
docLinkPath: '/htmlstrip-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.htmlStrip', {
defaultMessage: 'HTML strip',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.htmlStrip', {
defaultMessage: 'Removes HTML tags from a field.',
}),
},
inference: {
FieldsComponent: Inference,
docLinkPath: '/inference-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.inference', {
defaultMessage: 'Inference',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.inference', {
defaultMessage:
'Uses a pre-trained data frame analytics model to infer against incoming data.',
}),
},
join: {
FieldsComponent: Join,
docLinkPath: '/join-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.join', {
defaultMessage: 'Join',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.join', {
defaultMessage:
'Joins array elements into a string. Inserts a separator between each element.',
}),
},
json: {
FieldsComponent: Json,
docLinkPath: '/json-processor.html',
label: i18n.translate('xpack.ingestPipelines.processors.label.json', {
defaultMessage: 'JSON',
}),
description: i18n.translate('xpack.ingestPipelines.processors.description.json', {
defaultMessage: 'Creates a JSON object from a compatible string.',
}),
},
kv: {
FieldsComponent: Kv,
Expand Down