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

[App Search] Refactor out a shared MultiInputRows component #96881

Merged
merged 11 commits into from
Apr 14, 2021

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Apr 12, 2021

Summary

👋 Jason noted a while back that my CurationQueries component is super similar to a piece of UI in Relevance Tuning. As it turns out, the upcoming Synonyms view will ALSO use an identical component:

As the saying goes, once is chance, twice is coincidence, and three times is a pattern... so let's DRY it out! 🎉 Doing so also has added UI/UX benefit, as the shared component does some cool stuff like:

  • Disabling the delete row button when it's down to just 1 row
  • Disabling the add row button if there's already a blank row
  • Disabling the submit button if there's only 1 row and it's blank

BTW, I strongly recommend following along by commit, and reading the commit messages!

Screencaps

Curations

curations

Relevance Tuning

relevance_tuning

QA

  • Go to the Create Curations page and confirm adding/removing queries still works as expected
  • Go to Curations > select any curation > open the Manage Queries modal and confirm adding/removing queries still works as expected
  • Go to Revelance Tuning and confirm adding/removing value boosts still works as expected

Checklist

@cee-chen cee-chen added Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.13.0 auto-backport Deprecated - use backport:version if exact versions are needed labels Apr 12, 2021
@cee-chen cee-chen requested review from a team and JasonStoltz April 12, 2021 19:45
@@ -5,4 +5,4 @@
* 2.0.
*/

export { CurationQueries } from './curation_queries';
export { MultiInputRows } from './multi_input_rows';
Copy link
Contributor Author

@cee-chen cee-chen Apr 12, 2021

Choose a reason for hiding this comment

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

Just to clarify:

  • This is indeed essentially just the the CurationQueries component but relabelled, I basically moved the entire folder out to its own top-level component and did a bunch of find&replacing to more generic names.
    • What's changed is that it allows passing in overrides for all the various text/input/aria labels, and also a onChange functionality was added for the Relevance Tuning use-case
  • I'm not super in love with the MultiInputRows name lol, it's just what came to mind. Definitely open to ideas if y'all have them

@cee-chen
Copy link
Contributor Author

@elasticmachine merge upstream

@JasonStoltz
Copy link
Member

I need to drop off for now, will continue reviewing tomorrow!

- basically the CurationQuery component, but with a generic values var & allows passing in custom text for every string
- for upcoming Relevance Tuning usage
- relevance_tuning_form.test.tsx fix: was getting test errors with mount(), so I switched to shallow()
- more flexible - allows for either an onSubmit or onChange, or even potentially both
- so that we can have multiple instances on the same page - primarily the value boosts use case
@cee-chen cee-chen requested a review from a team April 14, 2021 17:47
- Use Kea's types instead of trying to rewrite my own LogicFile
- Add an early return for tests that pass `{}` to values as well for performance
Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

This looks so good. I'm going to approve. 2 suggestions to consider before continuing and that's it.

@JasonStoltz
Copy link
Member

I really like that this change pulls a lot of the complexity out of the Relevance Tuning logic file and encapsulates it in this component. This is really great.

+ bonus - add a fallback for initially empty components
+ add a test to check that the logic was mounted correctly
- We don't currently need the extra catch for any live components, and it's confusing
@cee-chen cee-chen enabled auto-merge (squash) April 14, 2021 18:54
@cee-chen
Copy link
Contributor Author

@elasticmachine merge upstream

@cee-chen
Copy link
Contributor Author

:dead_inside: don't mind me, just over here overloading Kibana's CI instances because I'm a ding dong

@cee-chen cee-chen merged commit 2a281c9 into elastic:master Apr 14, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 14, 2021
…96881)

* Add new reusable MultiInputRows component

- basically the CurationQuery component, but with a generic values var & allows passing in custom text for every string

* Update CurationQueries with MultiInputRows

* Update MultiInputRows to support on change behavior

- for upcoming Relevance Tuning usage

* Update Relevance Tuning value boost form to use new component

- relevance_tuning_form.test.tsx fix: was getting test errors with mount(), so I switched to shallow()

* Change submitOnChange to onChange fn

- more flexible - allows for either an onSubmit or onChange, or even potentially both

* Convert MultiInputRowsLogic to keyed Kea logic

- so that we can have multiple instances on the same page - primarily the value boosts use case

* Update LogicMounter helper & tests to handle keyed logic w/ props

* [Misc] LogicMounter helper - fix typing, perf

- Use Kea's types instead of trying to rewrite my own LogicFile
- Add an early return for tests that pass `{}` to values as well for performance

* PR feedback: Change values prop to initialValues

+ bonus - add a fallback for initially empty components
+ add a test to check that the logic was mounted correctly

* PR feedback: Remove useRef/on mount onChange catch for now

- We don't currently need the extra catch for any live components, and it's confusing
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Apr 15, 2021
…97193)

* Add new reusable MultiInputRows component

- basically the CurationQuery component, but with a generic values var & allows passing in custom text for every string

* Update CurationQueries with MultiInputRows

* Update MultiInputRows to support on change behavior

- for upcoming Relevance Tuning usage

* Update Relevance Tuning value boost form to use new component

- relevance_tuning_form.test.tsx fix: was getting test errors with mount(), so I switched to shallow()

* Change submitOnChange to onChange fn

- more flexible - allows for either an onSubmit or onChange, or even potentially both

* Convert MultiInputRowsLogic to keyed Kea logic

- so that we can have multiple instances on the same page - primarily the value boosts use case

* Update LogicMounter helper & tests to handle keyed logic w/ props

* [Misc] LogicMounter helper - fix typing, perf

- Use Kea's types instead of trying to rewrite my own LogicFile
- Add an early return for tests that pass `{}` to values as well for performance

* PR feedback: Change values prop to initialValues

+ bonus - add a fallback for initially empty components
+ add a test to check that the logic was mounted correctly

* PR feedback: Remove useRef/on mount onChange catch for now

- We don't currently need the extra catch for any live components, and it's confusing

Co-authored-by: Constance <constancecchen@users.noreply.github.com>
@cee-chen cee-chen deleted the multi-input-rows branch April 19, 2021 15:32
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
enterpriseSearch 2.0MB 2.0MB -1.4KB

History

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants