-
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
[Enterprise Search] Upgrade Kea to 2.3, update LogicMounter helper w/ props support #94232
Conversation
@@ -110,8 +111,10 @@ export class LogicMounter { | |||
}; | |||
|
|||
// Automatically reset context & mount the logic file | |||
public mount = (values?: object) => { | |||
public mount = (values?: object, props?: object) => { |
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 want to quickly note - I'm not a super huge fan of how logic files that don't want defaults and only want props (e.g., AppLogic) now have to either pass undefined
or {}
as a first param. If I could go back in time I'd probably change this to
public mount = ({ defaults, props }) => {
and have test files pass in their API like mount({ defaults: { foo: 'bar' } })
or mount({ props: { bar: 'baz' } })
. IDK if we feel strongly to make that change in a ton of files at this point so I'm fine leaving it as-is, mostly just thinking out loud
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.
Also for more context, here's the first conversation where I mentioned LogicMounter needing to support props: #92560 (comment)
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.
I supposed you could do a mountWithProps
, which would not require the empty object, but I am not a huge fan of that.
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.
Ya for sure, to clarify I don't hate this either and I'm fine with shipping it for now - we can definitely come back to this API later if we start using a ton more logic files w/ props!
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 LGTM. Thanks for the detailed description!
this.resetContext(values); | ||
if (props) this.logicFile.build(props); |
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.
TIL
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.
I got that from Kea's docs here for context: https://kea.js.org/docs/guide/advanced#mounting-and-unmounting
// build the logic with props (`logic(props)` is short for `logic.build(props)`)
@@ -110,8 +111,10 @@ export class LogicMounter { | |||
}; | |||
|
|||
// Automatically reset context & mount the logic file | |||
public mount = (values?: object) => { | |||
public mount = (values?: object, props?: object) => { |
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.
I supposed you could do a mountWithProps
, which would not require the empty object, but I am not a huge fan of that.
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.
Looks good to me!
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / X-Pack Alerting API Integration Tests.x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/rbac_legacy·ts.alerting api integration security and spaces enabled Alerts legacy alerts alerts space_1_all_alerts_none_actions at space1 should schedule actions on legacy alertsStandard Out
Stack Trace
Metrics [docs]Async chunks
To update your PR or re-run it, just comment with: |
Thanks for the reviews all! 🎉 I'm merging now to unblock myself from opening more PRs, but don't hesitate to leave more comments / make change requests @JasonStoltz - I'm happy to open up a follow up PR |
… props support (elastic#94232) * Enhance our LogicMounter helper to accept and build props * Update logic tests in AS that require props to now use LogicMounter * Upgrade Kea to 2.3.0 for future BindLogic use
Summary
The general theme of this PR is setting up Kea to work even better with
props
. I'll shortly be using this for my upcoming CurationLogic work/PR, as I'll be passing acurationId
prop into CurationLogic.Kea upgrade (a71f142)
The Kea 2.3 upgrade will allow us to use a new BindLogic API: https://kea.js.org/blog/kea-2.3/
Which means I can avoid doing
useActions(CurationLogic({ curationId: 'cur-123456789' }))
within<Curation />
and just douseActions(CurationLogic)
.LogicMounter changes (82ae123 & 8a566ec)
This updates our
mount
test helper to allow passing in props as well as defaults. API looks the same as before, just with an extra param:Checklist
2.3 should not have introduced any breaking changes, but I did a basic QA smoke test of our App Search pages and confirmed they work as before.
Unit or functional tests were updated or added to match the most common scenarios