-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b70fa7
commit 402459f
Showing
11 changed files
with
149 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
*/ | ||
|
||
export { FormFlyout } from './form_flyout'; | ||
export { ProcessorForm } from './processor_form'; |
49 changes: 49 additions & 0 deletions
49
.../public/application/pipeline_editor/components/processor_form/common_processor_fields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import { | ||
FormRow, | ||
FormSchema, | ||
UseField, | ||
FIELD_TYPES, | ||
Field, | ||
ToggleField, | ||
} from '../../../../shared_imports'; | ||
|
||
export const formSchema: FormSchema = { | ||
ignore_failure: { | ||
defaultValue: false, | ||
label: 'Ignore Failure', | ||
type: FIELD_TYPES.TOGGLE, | ||
}, | ||
if: { | ||
defaultValue: undefined, | ||
label: 'If', | ||
type: FIELD_TYPES.TEXT, | ||
}, | ||
tag: { | ||
defaultValue: undefined, | ||
label: 'Tag', | ||
type: FIELD_TYPES.TEXT, | ||
}, | ||
}; | ||
|
||
export const CommonProcessorFields: FunctionComponent = () => { | ||
return ( | ||
<> | ||
<FormRow title="Ignore Failure"> | ||
<UseField component={ToggleField} path={'ignore_failure'} /> | ||
</FormRow> | ||
<FormRow title="If"> | ||
<UseField component={Field} path={'if'} /> | ||
</FormRow> | ||
<FormRow title="Tag"> | ||
<UseField component={Field} path={'tag'} /> | ||
</FormRow> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...blic/application/pipeline_editor/components/processor_form/map_processor_type_to_form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { ProcessorFormDescriptor } from './types'; | ||
|
||
import * as setForm from './processors/set'; | ||
|
||
const mapProcessorTypeToForm = { | ||
set: setForm, | ||
}; | ||
|
||
type ProcessorType = keyof typeof mapProcessorTypeToForm; | ||
|
||
export const getProcessorFormDescriptor = (type: string): ProcessorFormDescriptor => { | ||
return mapProcessorTypeToForm[type as ProcessorType]; | ||
}; |
40 changes: 40 additions & 0 deletions
40
...pipelines/public/application/pipeline_editor/components/processor_form/processor_form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import { PipelineEditorProcessor } from '../../types'; | ||
import { Form, useForm } from '../../../../shared_imports'; | ||
import { getProcessorFormDescriptor } from './map_processor_type_to_form'; | ||
import { CommonProcessorFields, formSchema as commonFormSchema } from './common_processor_fields'; | ||
|
||
export interface Props { | ||
processor: PipelineEditorProcessor; | ||
onSubmit: (processor: PipelineEditorProcessor) => void; | ||
} | ||
|
||
export const ProcessorForm: FunctionComponent<Props> = ({ processor }) => { | ||
const formDescriptor = getProcessorFormDescriptor(processor.type); | ||
|
||
// TODO: Handle this error in a different way | ||
if (!formDescriptor) { | ||
throw new Error(`Could not find form for type ${processor.type}`); | ||
} | ||
|
||
const { form } = useForm({ | ||
defaultValue: { ...processor.options }, | ||
schema: { | ||
...commonFormSchema, | ||
...formDescriptor.formSchema, | ||
}, | ||
}); | ||
|
||
return ( | ||
<Form form={form}> | ||
<formDescriptor.Component processor={processor} /> | ||
<CommonProcessorFields /> | ||
</Form> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ns/ingest_pipelines/public/application/pipeline_editor/components/processor_form/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { FunctionComponent } from 'react'; | ||
import { PipelineEditorProcessor } from '../../types'; | ||
import { FormSchema } from '../../../../shared_imports'; | ||
|
||
export type ProcessorFormComponent<Props = {}> = FunctionComponent<{ | ||
processor: PipelineEditorProcessor<Props>; | ||
}>; | ||
|
||
export interface ProcessorFormDescriptor { | ||
Component: ProcessorFormComponent<any>; | ||
formSchema: FormSchema; | ||
} |
13 changes: 0 additions & 13 deletions
13
x-pack/plugins/ingest_pipelines/public/application/pipeline_editor/processor_forms/types.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters