Skip to content

Commit 5ff03ea

Browse files
committed
fix types and i18n
1 parent 106701f commit 5ff03ea

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/bytes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const Bytes: FunctionComponent = () => {
3030
<>
3131
<FieldNameField
3232
helpText={i18n.translate(
33-
'xpack.ingestPipelines.pipelineEditor.bytesForm.targetFieldHelpText',
33+
'xpack.ingestPipelines.pipelineEditor.bytesForm.fieldNameHelpText',
3434
{ defaultMessage: 'The field to convert.' }
3535
)}
3636
/>

x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/processor_type_field.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,12 @@ interface Props {
4646

4747
const { emptyField } = fieldValidators;
4848

49-
const typeConfig: FieldConfig = {
49+
const typeConfig: FieldConfig<any, string> = {
5050
type: FIELD_TYPES.COMBO_BOX,
5151
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.typeField.typeFieldLabel', {
5252
defaultMessage: 'Processor',
5353
}),
54-
deserializer: (value: string | undefined) => {
55-
if (value) {
56-
return [value];
57-
}
58-
return [];
59-
},
60-
serializer: (value: string[]) => {
61-
return value[0];
62-
},
54+
deserializer: String,
6355
validations: [
6456
{
6557
validator: emptyField(
@@ -73,11 +65,11 @@ const typeConfig: FieldConfig = {
7365

7466
export const ProcessorTypeField: FunctionComponent<Props> = ({ initialType }) => {
7567
return (
76-
<UseField<string[]> config={typeConfig} defaultValue={initialType} path="type">
68+
<UseField<string> config={typeConfig} defaultValue={initialType} path="type">
7769
{(typeField) => {
7870
let selectedOptions: ProcessorTypeAndLabel[];
7971
if (typeField.value?.length) {
80-
const [type] = typeField.value;
72+
const type = typeField.value;
8173
const descriptor = getProcessorDescriptor(type);
8274
selectedOptions = descriptor
8375
? [{ label: descriptor.label, value: type }]
@@ -103,9 +95,7 @@ export const ProcessorTypeField: FunctionComponent<Props> = ({ initialType }) =>
10395
return false;
10496
}
10597

106-
const newValue = [...(typeField.value as string[]), value];
107-
108-
typeField.setValue(newValue);
98+
typeField.setValue(value);
10999
};
110100

111101
return (
@@ -131,8 +121,9 @@ export const ProcessorTypeField: FunctionComponent<Props> = ({ initialType }) =>
131121
options={processorTypesAndLabels}
132122
selectedOptions={selectedOptions}
133123
onCreateOption={onCreateComboOption}
134-
onChange={(options: EuiComboBoxOptionOption[]) => {
135-
typeField.setValue(options.map(({ value }) => value));
124+
onChange={(options: Array<EuiComboBoxOptionOption<string>>) => {
125+
const [selection] = options;
126+
typeField.setValue(selection?.value! ?? '');
136127
}}
137128
noSuggestions={false}
138129
singleSelection={{

x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/convert.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ const fieldsConfig: FieldsConfig = {
4848
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldLabel', {
4949
defaultMessage: 'Target field (optional)',
5050
}),
51-
helpText: i18n.translate('xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldLabel', {
52-
defaultMessage: 'The field to assign the converted value to.',
53-
}),
51+
helpText: i18n.translate(
52+
'xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldHelpText',
53+
{
54+
defaultMessage: 'The field to assign the converted value to.',
55+
}
56+
),
5457
},
5558
};
5659

@@ -59,7 +62,7 @@ export const Convert: FunctionComponent = () => {
5962
<>
6063
<FieldNameField
6164
helpText={i18n.translate(
62-
'xpack.ingestPipelines.pipelineEditor.convertForm.targetFieldHelpText',
65+
'xpack.ingestPipelines.pipelineEditor.convertForm.fieldNameHelpText',
6366
{ defaultMessage: 'The field whose value is to be converted.' }
6467
)}
6568
/>

x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/csv.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ export const CSV: FunctionComponent = () => {
139139
return (
140140
<>
141141
<FieldNameField
142-
helpText={i18n.translate(
143-
'xpack.ingestPipelines.pipelineEditor.convertForm.fieldNameHelpText',
144-
{ defaultMessage: 'The field to extract data from.' }
145-
)}
142+
helpText={i18n.translate('xpack.ingestPipelines.pipelineEditor.csvForm.fieldNameHelpText', {
143+
defaultMessage: 'The field to extract data from.',
144+
})}
146145
/>
147146

148147
<UseField

x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date_index_name.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const fieldsConfig: FieldsConfig = {
117117
),
118118
helpText: (
119119
<FormattedMessage
120-
id="xpack.ingestPipelines.pipelineEditor.dateForm.timezoneHelpText"
120+
id="xpack.ingestPipelines.pipelineEditor.dateIndexNameForm.timezoneHelpText"
121121
defaultMessage="The timezone to use when parsing the date and when date math index supports resolves expressions into concrete index names. Default value is {timezone}."
122122
values={{ timezone: <EuiCode inline>{'UTC'}</EuiCode> }}
123123
/>
@@ -134,7 +134,7 @@ const fieldsConfig: FieldsConfig = {
134134
),
135135
helpText: (
136136
<FormattedMessage
137-
id="xpack.ingestPipelines.pipelineEditor.dateForm.localeHelpText"
137+
id="xpack.ingestPipelines.pipelineEditor.dateIndexForm.localeHelpText"
138138
defaultMessage="The locale to use when parsing the date from the document being preprocessed, relevant when parsing month names or week days. Default value is {locale}"
139139
values={{ locale: <EuiCode inline>{'ENGLISH'}</EuiCode> }}
140140
/>

0 commit comments

Comments
 (0)