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 Node Pipeline] Pipeline Processors Editor #63694

Closed

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Apr 16, 2020

Summary

Variant on #63617 where the editor focusses on processors.

Branch from original PR #63617.

This involved moving JSX around and creating a way for the pipeline form component to read out data from the pipeline editor.

Note; does not handle on failure processors yet. We can render a second editor for handling the on failure processors.

Notes on architecture and structure

  • The pipeline_processors_editor folder contains the component and it's child components
  • The top-level component contains all business logic for dispatching to the state reducer and all other state related updates
  • We use a form component which dynamically renders settings fields for a specific processor as a child component of the editor.
  • The editor takes in an array of processors and a callback that fires for every state change which gives the consumer the ability to get the current state out of the processors editor as well as the overall validity of the processors array.
  • All missing processors should be added to the processor_settings_form child component with all validation and configuration in the same file.

Notes to reviewer

  • Main focus has been establishing patterns for us to flesh out all the other processor forms.

  • All styling optimisations have been deferred until after this review and once final designs have been agreed upon.

  • Translations have been done or marked as TODO throughout (please flag any ones that I may have missed).

  • The data has not been flattened to a byId map which keeps the reordering and rendering logic a bit simpler for now. Optimisation other than flattening to a byId map is still possible, which I would like to explore a bit later on but for now, worst case O(n) on an array that should never grow past 50-60 (guessing?) items is acceptable IMO.

  • Have not built rendering of on failure pipelines yet. There are some things that are still in flux here, however I can definitely work on just rending the nested list next.

Screenshot

TODO

alisonelizabeth and others added 21 commits April 3, 2020 14:59
* First iteration of ingest table

* Add action placeholders

* Refactor list and address PR feedback

Refactored the list into smaller pieces and assemble in main.tsx

Also addressed feedback on copy, removed unused notifications dep

* WiP on flyout

Showing name in title

* Add reload button

* Finish first version of flyout

* Slight update to copy

* `delete` -> `edit`

* Address PR feedback

Copy and a11y updates

* Add on failure JSON to flyout if it is available

* Add details json block file and remove ununsed import

Co-authored-by: Elastic Machine <[email protected]>
…bana into pipeline-editor-part-mvp-1

* 'feature/ingest-node-pipelines' of github.com:elastic/kibana:
  [Ingest pipelines] Edit pipeline page (elastic#63522)

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/sections/pipelines_create/pipelines_create.tsx
#	x-pack/plugins/ingest_pipelines/public/shared_imports.ts
@jloleysens jloleysens added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Ingest Node Pipelines Ingest node pipelines management labels Apr 16, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @jloleysens! It’s awesome to start seeing this come together.

Overall, I was able to easily follow along the code. I do think it would be helpful though to update the PR description with some notes around the general architecture decisions you made, so it’s documented and also so others can come along and easily review.

I left a few comments in the code. Some other general thoughts I had:

  • I like having the field configs live within each processor type
  • I like the “dumb” file names given for data manipulation (data_in and data_out)
  • DnD 👌
  • I don’t know that I agree with the pipeline_processors_editor directory living directly under application (not sure if this was an intentional decision or not)
  • I noticed a few places where i18n is missing and there is not a todo. I can make a note of them if you’d like, but not sure if it was necessary for the initial review.
  • [bug] I noticed the processors data for the ES request flyout isn’t updated

@jloleysens
Copy link
Contributor Author

jloleysens commented Apr 20, 2020

Thanks for the review @alisonelizabeth !

I don’t know that I agree with the pipeline_processors_editor directory living directly under application (not sure if this was an intentional decision or not)

At the time this was an intentional decision, I was trying to think of ingest pipeline editor as a separate app (not a component inside of ingest pipelines). Even though it is consumed as a component inside of ingest pipelines.

What do you think about moving it to x-pack/plugins/ingest_pipelines/public so that it lives next door to application? (If this deviates too much I am happy to place it in public/application/components for now.)

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @jloleysens! This is looking great. I went through the code again and left some more comments.

A couple other things I noticed while testing:

  • I noticed a React warning in the console when adding an on_failure processor
  • The 'Delete' functionality was buggy for me. I didn't look into it in too much detail, but sometimes the UI did not remove the processor. If I continued to click "Delete" for all of them, it eventually broke the UI.
  • Dragging a processor into another one took me a little bit to get the hang of. Possibly just me though 😄 . I haven't really played around with the EUI component much, so not sure how much flexibility we have here.

const subscription = form.subscribe(onFormUpdate);
return subscription.unsubscribe;

// TODO: Address this issue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bug in the form lib.

Create a separate component to connect to the form and subscribe to its changes. It is currently required to have a separate component (instead of putting the subscribing logic inside the current ) because the form object is not memoized in the lib and it creates an infinite re-render loop. This is something I will change in a future update (Probably exposing a hook useFormData() and that's it for the consumer).

See: #63522 (comment)

@@ -0,0 +1,7 @@

.pipelineProcessorsEditor__dragAndDropTreeFixes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something we should open up an issue against EUI for?

return (
<EuiDraggable spacing="l" draggableId={id} key={id} index={index} customDragHandle>
{provided => (
<EuiPanel style={{ marginLeft: 30 * level + 'px' }} paddingSize="s">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is likely subject to change, but might make a note that this is to handle the nesting.

const { emptyField } = fieldValidators;

const typeConfig: FieldConfig = {
type: FIELD_TYPES.TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC there is a FIELD_TYPES.COMBOBOX that you can use.

Copy link
Contributor Author

@jloleysens jloleysens May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alisonelizabeth Thanks for pointing that out! Do you know what effect setting it to FIELD_TYPES.COMBO_BOX has?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It maps to this: https://github.com/elastic/kibana/blob/master/src/plugins/es_ui_shared/static/forms/components/fields/combobox_field.tsx

(Not tested) I think you can do something like this:

const typeConfig: FieldConfig = {
  type: FIELD_TYPES.COMBO_BOX,
  label: i18n.translate('xpack.ingestPipelines.pipelineEditor.typeField.typeFieldLabel', {
    defaultMessage: 'Type',
  }),
  defaultValue: [],
  validations: [
    {
      validator: emptyField(
        i18n.translate('xpack.ingestPipelines.pipelineEditor.typeField.fieldRequiredError', {
          defaultMessage: 'A type is required.',
        })
      ),
    },
  ],
};
<UseField config={typeConfig} path="type" />

Copy link
Contributor

@alisonelizabeth alisonelizabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @jloleysens! This is looking great. I went through the code again and left some more comments.

A couple other things I noticed while testing:

  • I noticed a React warning in the console when adding an on_failure processor
  • The 'Delete' functionality was buggy for me. I didn't look into it in too much detail, but sometimes the UI did not remove the processor. If I continued to click "Delete" for all of them, it eventually broke the UI.
  • Dragging a processor into another one took me a little bit to get the hang of. Possibly just me though 😄 . I haven't really played around with the EUI component much, so not sure how much flexibility we have here.

@jloleysens
Copy link
Contributor Author

jloleysens commented May 7, 2020

@alisonelizabeth Thanks for the review!

I noticed a React warning in the console when adding an on_failure processor

Yeah, happens only the first time when opening a flyout to add or edit a processor. Subsequent opening of the flyout does not cause this warning. I was wondering if @sebelga could weigh in here as it seems this may be related to the form lib?

The 'Delete' functionality was buggy for me

Yeah I see I had not pushed my latest code which contains the fix for this!

Dragging a processor into another one took me a little bit to get the hang of

Do you mean getting one processor to "hover" over another then turning transparent? Or just generally moving a processor up and down in an indented list?

jloleysens added 8 commits May 7, 2020 11:29
- added some padding around the new processors editor field
- Updated use of flex box in the pipeline form fields
The test button is also now inside of the pipeline processor
editor. Eventually all of this functionality should be moved
into the pipeline processor editor.
@alisonelizabeth
Copy link
Contributor

@jloleysens

Yeah, happens only the first time when opening a flyout to add or edit a processor. Subsequent opening of the flyout does not cause this warning. I was wondering if @sebelga could weigh in here as it seems this may be related to the form lib?

👍

Yeah I see I had not pushed my latest code which contains the fix for this!

👍

Do you mean getting one processor to "hover" over another then turning transparent? Or just generally moving a processor up and down in an indented list?

Yeah, the hover part took me a little bit to get used to.

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

merge conflict between base and head

jloleysens added 5 commits May 8, 2020 10:39
…or-part-mvp-2

* 'master' of github.com:elastic/kibana: (259 commits)
  SavedObjects bulkCreate API should return migrationVersion and strip the type & namespace from the id (elastic#65150)
  Drilldown count tooltip (elastic#65105)
  plugins logs start with "plugins." prefix (elastic#65710)
  [ML] Fix pagination reset on search query update. (elastic#65668)
  [SIEM] Add types to the mappings objects so extra keys cannot be introduced
  [apm] Update machine learning flyout and service maps docs (elastic#65517)
  change api endpoint and throw error (elastic#65790)
  [Maps] remove SLA percentage metric (elastic#65718)
  [Reporting] APM integration for baseline performance measurements (elastic#59967)
  fix(NA): noParse regex for windows on kbn optimizer (elastic#65755)
  [ML] DFA: ensure at least one field is included in analysis before job can be created (elastic#65320)
  [Data plugin] cleanup - remove unused getRoutes / routes from indexPattern object (elastic#65683)
  Removed skip to enable test. (elastic#65575)
  [Lens] Type safe migrations (elastic#65576)
  [Canvas] Fix nav link behavior in Canvas  (elastic#65590)
  [Event log] Fix flaky test (elastic#65658)
  [Alerting] changes preconfigured actions config from array to object (elastic#65397)
  remove immediate functions from esqueue worker cycles (elastic#65375)
  [Metrics UI] Fix isAbove to only display when threshold set (elastic#65540)
  draft search profiler accessibility tests (elastic#62357)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form_fields.tsx
@kibanamachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps


Test Failures

Kibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/plugins/ingest_pipelines/__jest__/client_integration. on component mount should toggle the on-failure processors editor

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: "onFailureToggle" was not found.
    at Object.toggleEuiSwitch (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/test_utils/testbed/testbed.ts:228:17)
    at Object.toggleOnFailureSwitch (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts:29:10)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/ingest_pipelines_create.test.tsx:78:17
    at batchedUpdates$1 (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/react-dom/cjs/react-dom.development.js:24386:12)
    at act (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
    at Object.test (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/ingest_pipelines_create.test.tsx:77:13)
    at Object.asyncJestTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:102:37)
    at resolve (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:43:12)
    at new Promise (<anonymous>)
    at mapper (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:26:19)
    at promise.then (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:73:41)

Kibana Pipeline / x-pack-intake-agent / X-Pack Jest Tests.x-pack/plugins/ingest_pipelines/__jest__/client_integration. on component mount test pipeline should open the test pipeline flyout

Link to Jenkins

Standard Out

Failed Tests Reporter:
  - Test has not failed recently on tracked branches


Stack Trace

Error: Method “simulate” is meant to be run on 1 node. 0 found instead.
    at ReactWrapper.single (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/enzyme/src/ReactWrapper.js:1168:13)
    at ReactWrapper.simulate (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/enzyme/src/ReactWrapper.js:665:17)
    at Object.clickTestPipelineButton (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/helpers/pipeline_form.helpers.ts:17:32)
    at /var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/ingest_pipelines_create.test.tsx:198:19
    at batchedUpdates$1 (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/react-dom/cjs/react-dom.development.js:24386:12)
    at act (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
    at Object.test (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/x-pack/plugins/ingest_pipelines/__jest__/client_integration/ingest_pipelines_create.test.tsx:197:15)
    at Object.asyncJestTest (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:102:37)
    at resolve (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:43:12)
    at new Promise (<anonymous>)
    at mapper (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:26:19)
    at promise.then (/var/lib/jenkins/workspace/elastic+kibana+pipeline-pull-request/kibana/node_modules/jest-jasmine2/build/queueRunner.js:73:41)

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@sebelga
Copy link
Contributor

sebelga commented May 12, 2020

Yeah, happens only the first time when opening a flyout to add or edit a processor. Subsequent opening of the flyout does not cause this warning. I was wondering if @sebelga could weigh in here as it seems this may be related to the form lib?

It depended of what React warning 😊 #64647 Fixes a data flow issue in the form lib, once it will be merged and you rebase this branch we'll know for sure. 👍

@jloleysens
Copy link
Contributor Author

Closing in favour of new feature branch PR #66021

@jloleysens jloleysens closed this May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Ingest Node Pipelines Ingest node pipelines management release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants