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.12] [Ingest Pipelines] Add generated copy for all processors (#95507) #96660

Merged
merged 1 commit into from
Apr 8, 2021
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 @@ -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;
Expand Down Expand Up @@ -90,11 +90,13 @@ function _InlineTextInput({
tabIndex={disabled ? -1 : 0}
onFocus={() => setIsShowingTextInput(true)}
>
<EuiText size="s" color="subdued">
<div className="pipelineProcessorsEditor__item__description">
{text || <em>{placeholder}</em>}
</div>
</EuiText>
<EuiToolTip content={text ?? placeholder}>
<EuiText size="s" color="subdued">
<div className="pipelineProcessorsEditor__item__description">
{text || <em>{placeholder}</em>}
</div>
</EuiText>
</EuiToolTip>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
overflow-x: hidden;
white-space: nowrap;
text-overflow: ellipsis;
max-width: 600px;
}

&__textInput {
Expand All @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
const isMovingOtherProcessor = editor.mode.id === 'movingProcessor' && !isMovingThisProcessor;
const isDimmed = isEditingOtherProcessor || isMovingOtherProcessor;

const processorDescriptor = getProcessorDescriptor(processor.type);

const { testPipelineData } = useTestPipelineContext();
const {
config: { selectedDocumentIndex },
Expand All @@ -85,10 +87,14 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = 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) => {
Expand Down Expand Up @@ -167,8 +173,13 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
data-test-subj={selectorToDataTestSubject(selector)}
data-processor-id={processor.id}
>
<EuiFlexItem>
<EuiFlexGroup gutterSize="m" alignItems="center" responsive={false}>
<EuiFlexItem className="pipelineProcessorsEditor__item__controlsFlexItem">
<EuiFlexGroup
className="pipelineProcessorsEditor__item__controlsContainer"
gutterSize="m"
alignItems="center"
responsive={false}
>
<EuiFlexItem grow={false}>{renderMoveButton()}</EuiFlexItem>
<EuiFlexItem grow={false} className="pipelineProcessorsEditor__item__statusContainer">
{isExecutingPipeline ? (
Expand All @@ -193,7 +204,7 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
}}
data-test-subj="manageItemButton"
>
<b>{getProcessorDescriptor(processor.type)?.label ?? processor.type}</b>
<b>{processorDescriptor?.label ?? processor.type}</b>
</EuiLink>
</EuiText>
</EuiFlexItem>
Expand All @@ -203,7 +214,10 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
onChange={onDescriptionChange}
ariaLabel={i18nTexts.processorTypeLabel({ type: processor.type })}
text={description}
placeholder={i18nTexts.descriptionPlaceholder}
placeholder={
processorDescriptor?.getDefaultDescription(processor.options) ??
i18nTexts.descriptionPlaceholder
}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const ProcessorTypeField: FunctionComponent<Props> = ({ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -45,7 +42,7 @@ const fieldsConfig: FieldsConfig = {
),
validations: [
{
validator: emptyField(
validator: isEmptyString(
i18n.translate('xpack.ingestPipelines.pipelineEditor.kvForm.fieldSplitRequiredError', {
defaultMessage: 'A value is required.',
})
Expand All @@ -70,7 +67,7 @@ const fieldsConfig: FieldsConfig = {
),
validations: [
{
validator: emptyField(
validator: isEmptyString(
i18n.translate('xpack.ingestPipelines.pipelineEditor.kvForm.valueSplitRequiredError', {
defaultMessage: 'A value is required.',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
Loading