Skip to content

Commit

Permalink
Fixes for monaco XJSON grammar parser and update form copy
Browse files Browse the repository at this point in the history
- Monaco XJSON worker was not handling trailing whitespace
- Update copy in the processor configuration form
  • Loading branch information
jloleysens committed Jun 26, 2020
1 parent 7c0afb8 commit 8ffad8c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 43 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-monaco/src/xjson/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,13 @@ export const createParser = () => {

try {
value();
white();
} catch (e) {
errored = true;
annos.push({ type: AnnoTypes.error, at: e.at - 1, text: e.message });
}
if (!errored && ch) {
error('Syntax error');
annos.push({ type: AnnoTypes.error, at: at, text: 'Syntax Error' });
}
return { annotations: annos };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,36 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
<b>{processor.type}</b>
</EuiText>
</EuiFlexItem>
<EuiFlexItem className={inlineTextInputContainerClasses} grow={false}>
<InlineTextInput
disabled={isDisabled}
onChange={(nextDescription) => {
let nextOptions: Record<string, any>;
if (!nextDescription) {
const { description: __, ...restOptions } = processor.options;
nextOptions = restOptions;
} else {
nextOptions = {
...processor.options,
description: nextDescription,
};
}
processorsDispatch({
type: 'updateProcessor',
payload: {
processor: {
...processor,
options: nextOptions,
},
selector,
},
});
}}
ariaLabel={editorItemMessages.processorTypeLabel({ type: processor.type })}
text={description}
placeholder={editorItemMessages.descriptionPlaceholder}
/>
</EuiFlexItem>
<EuiFlexItem className={actionElementClasses} grow={false}>
{!isInMoveMode && (
<EuiToolTip content={editorItemMessages.editButtonLabel}>
Expand Down Expand Up @@ -133,36 +163,6 @@ export const PipelineProcessorsEditorItem: FunctionComponent<Props> = memo(
</EuiToolTip>
)}
</EuiFlexItem>
<EuiFlexItem className={inlineTextInputContainerClasses} grow={false}>
<InlineTextInput
disabled={isDisabled}
onChange={(nextDescription) => {
let nextOptions: Record<string, any>;
if (!nextDescription) {
const { description: __, ...restOptions } = processor.options;
nextOptions = restOptions;
} else {
nextOptions = {
...processor.options,
description: nextDescription,
};
}
processorsDispatch({
type: 'updateProcessor',
payload: {
processor: {
...processor,
options: nextOptions,
},
selector,
},
});
}}
ariaLabel={editorItemMessages.processorTypeLabel({ type: processor.type })}
text={description}
placeholder={editorItemMessages.descriptionPlaceholder}
/>
</EuiFlexItem>
<EuiFlexItem grow={false} className={cancelMoveButtonClasses}>
<EuiButton data-test-subj="cancelMoveItemButton" size="s" onClick={onCancelMove}>
{editorItemMessages.cancelMoveButtonLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,32 @@ import {
EuiFlexItem,
} from '@elastic/eui';

import { Form, useForm, FormDataProvider } from '../../../../../shared_imports';
import { Form, FormDataProvider, FormHook } from '../../../../../shared_imports';
import { usePipelineProcessorsContext } from '../../context';
import { ProcessorInternal } from '../../types';

import { DocumentationButton } from './documentation_button';
import { ProcessorSettingsFromOnSubmitArg } from './processor_settings_form.container';
import { getProcessorFormDescriptor } from './map_processor_type_to_form';
import { CommonProcessorFields, ProcessorTypeField } from './processors/common_fields';
import { Custom } from './processors/custom';

export type OnSubmitHandler = (processor: ProcessorSettingsFromOnSubmitArg) => void;

export interface Props {
isOnFailure: boolean;
processor?: ProcessorInternal;
form: ReturnType<typeof useForm>['form'];
form: FormHook;
onClose: () => void;
onOpen: () => void;
}

const updateButtonLabel = i18n.translate(
'xpack.ingestPipelines.settingsFormOnFailureFlyout.updateButtonLabel',
{ defaultMessage: 'Update' }
);
const addButtonLabel = i18n.translate(
'xpack.ingestPipelines.settingsFormOnFailureFlyout.addButtonLabel',
{ defaultMessage: 'Add' }
);

export const ProcessorSettingsForm: FunctionComponent<Props> = memo(
({ processor, form, isOnFailure, onClose, onOpen }) => {
const {
Expand Down Expand Up @@ -123,10 +129,7 @@ export const ProcessorSettingsForm: FunctionComponent<Props> = memo(
<>
{formContent}
<EuiButton data-test-subj="submitButton" onClick={form.submit}>
{i18n.translate(
'xpack.ingestPipelines.pipelineEditor.settingsForm.submitButtonLabel',
{ defaultMessage: 'Submit' }
)}
{processor ? updateButtonLabel : addButtonLabel}
</EuiButton>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { XJsonEditor } from '../field_components';
const customConfig: FieldConfig = {
type: FIELD_TYPES.TEXT,
label: i18n.translate('xpack.ingestPipelines.pipelineEditor.customForm.optionsFieldLabel', {
defaultMessage: 'Configuration options',
defaultMessage: 'Configuration',
}),
serializer: (value: string) => {
try {
Expand All @@ -43,7 +43,7 @@ const customConfig: FieldConfig = {
i18n.translate(
'xpack.ingestPipelines.pipelineEditor.customForm.configurationRequiredError',
{
defaultMessage: 'Configuration options are required.',
defaultMessage: 'Configuration is required.',
}
)
),
Expand Down Expand Up @@ -82,7 +82,7 @@ export const Custom: FunctionComponent<Props> = ({ defaultOptions }) => {
'aria-label': i18n.translate(
'xpack.ingestPipelines.pipelineEditor.customForm.optionsFieldAriaLabel',
{
defaultMessage: 'Configuration options JSON editor',
defaultMessage: 'Configuration JSON editor',
}
),
},
Expand Down

0 comments on commit 8ffad8c

Please sign in to comment.