-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
@@ -5,4 +5,4 @@ | |||
* 2.0. | |||
*/ | |||
|
|||
export { CurationQueries } from './curation_queries'; | |||
export { MultiInputRows } from './multi_input_rows'; |
There was a problem hiding this comment.
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
- What's changed is that it allows passing in overrides for all the various text/input/aria labels, and also a
- 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
...prise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.tsx
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
..._search/public/applications/app_search/components/multi_input_rows/multi_input_rows.test.tsx
Outdated
Show resolved
Hide resolved
...prise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.tsx
Outdated
Show resolved
Hide resolved
..._search/public/applications/app_search/components/multi_input_rows/multi_input_rows_logic.ts
Outdated
Show resolved
Hide resolved
I need to drop off for now, will continue reviewing tomorrow! |
7ed0d78
to
8436c81
Compare
- 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
8436c81
to
a758b1f
Compare
- 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
a758b1f
to
e628d4d
Compare
There was a problem hiding this 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.
...prise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.tsx
Outdated
Show resolved
Hide resolved
...prise_search/public/applications/app_search/components/multi_input_rows/multi_input_rows.tsx
Outdated
Show resolved
Hide resolved
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
@elasticmachine merge upstream |
:dead_inside: don't mind me, just over here overloading Kibana's CI instances because I'm a ding dong |
…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
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…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>
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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:
BTW, I strongly recommend following along by commit, and reading the commit messages!
Screencaps
Curations
Relevance Tuning
QA
Checklist