Skip to content

[Mappings editor] Refactor field "path" format#54146

Merged
sebelga merged 8 commits intoelastic:feature/mappings-editorfrom
sebelga:mappings-editor/field-path-array
Jan 9, 2020
Merged

[Mappings editor] Refactor field "path" format#54146
sebelga merged 8 commits intoelastic:feature/mappings-editorfrom
sebelga:mappings-editor/field-path-array

Conversation

@sebelga
Copy link
Copy Markdown
Contributor

@sebelga sebelga commented Jan 7, 2020

This PR refactors the state format for a field path from a string myObject.prop to an array of string ['myObject', 'prop'].

This allows us to render the path as we wish.

Screen Shot 2020-01-08 at 12 50 01

Screen Shot 2020-01-08 at 12 50 20

For the dropdown where we render the label of the alias path to point to, I decided to keep the > delimiter as having that char in the naming is probably an edge case.

Screen Shot 2020-01-07 at 22 14 32

Fixes #53894

@sebelga sebelga changed the base branch from master to feature/mappings-editor January 7, 2020 16:48
@sebelga sebelga added Feature:Mappings Editor Index mappings editor UI Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t// labels Jan 7, 2020
@elasticmachine
Copy link
Copy Markdown
Contributor

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

@sebelga sebelga added the release_note:skip Skip the PR/issue when compiling release notes label Jan 7, 2020
@sebelga sebelga requested a review from cjcenizal January 7, 2020 16:49
Copy link
Copy Markdown
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

General

Code and UI look great! No blockers found.

  • I don't think this is an issue with the code in this PR, but I was able to trigger a react warning while updating a Text type to an Object type. Could not reproduce consistently so this is a flaky one 🎉 :

Screenshot 2020-01-08 at 13 45 46

This happened after clicking "Update". Looks like an issue on the EUI side while EuiComboBox was doing something in the background. I can open an issue there if you agree with this @sebelga

UX Feedback

  • I can see that the icon renders nicely in this space, I'm just wondering if it's worth using this over the > we use everywhere else. To me it also feels a bit like a map is happening, i.e., we are converting test1 to test2 by way of a mapping function #algebraic.

Screenshot 2020-01-08 at 13 40 56

* The <EuiCode /> component expect the children provided to be a string (html).
* This component allows both string and JSX element
*
* TODO: Open PR on eui repo to allow both string and React.Node to be passed as children of <EuiCode />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have an issue open somewhere for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it is still a TODO. Going through the TODOs might be a good thing to do during the extra week at the end of the cycle.

@@ -103,7 +103,7 @@ const replaceAliasPathByAliasId = (
Object.entries(byId).forEach(([id, field]) => {
if (field.source.type === 'alias') {
const aliasTargetField = Object.values(byId).find(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: just saw this now, but Object.values(byId) can be calculated once outside of the .forEach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is actually not a nit, it would be a NNNIIITTT if that word existed 😄 It caused a big performance issue that I saw and fixed in #54224

Great catch though! 👍

@cjcenizal cjcenizal mentioned this pull request Jan 8, 2020
5 tasks
Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal 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, Seb! I didn't test locally, but the code and screenshots LGTM. I agree with JL that it makes more sense to be consistent with the use of greater-than as a delimiter, rather than introduce the EuiIcon in the flyout header.

@sebelga
Copy link
Copy Markdown
Contributor Author

sebelga commented Jan 9, 2020

Thanks for the review @jloleysens and @cjcenizal

I was able to trigger a react warning while updating a Text type to an Object type.

I also saw randomly this error coming up in the console and it did seem like a Eui bug (updating a state after the component is unmounted). Before opening an issue on their side I'd like to be able to reproduce it first so we are 100% sure it is not coming from us.

I agree with JL that it makes more sense to be consistent with the use of greater-than as a delimiter, rather than introduce the EuiIcon in the flyout header.

OK, I will revert to > delimiter and remove the EuiIcon.

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

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

@sebelga sebelga merged commit 0e2f181 into elastic:feature/mappings-editor Jan 9, 2020
@sebelga sebelga deleted the mappings-editor/field-path-array branch January 9, 2020 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Mappings Editor Index mappings editor UI 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 t//

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants