-
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] Remove all instances of KibanaContext to Kea store #78513
Conversation
…seeffect - The file is now no longer used to mock useContext, only unseEffect, hence the rename
- Remove mountWithKibanaContext completely - Change mountWithContext to mountWithIntl, since that's the only context remaining, and move it to its own file - Change mountWithAsyncContext to just mountAsync and move it to its own file + add an option to pair it w/ mountWithIntl for formatted date/number support
+ minor newline linting/grouping tweaks
export const KibanaLogic = kea<MakeLogicType<IKibanaValues>>({ | ||
path: ['enterprise_search', 'kibana_logic'], | ||
reducers: ({ props }) => ({ | ||
config: [props.config || {}, {}], | ||
navigateToUrl: [props.navigateToUrl, {}], | ||
setBreadcrumbs: [props.setBreadcrumbs, {}], | ||
setDocTitle: [props.setDocTitle, {}], | ||
}), | ||
}); |
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.
Similar to the previous externalUrl PR, I also felt kinda weird that this store essentially just holds some variables that never update or require state, but in the end I decided to stay with a Kea logic file here because:
- It's familiar
- It's way easier to mock in tests since we already have the mocks/architecture set up
Admittedly those aren't like, super strong reasons heh, so if I'm definitely open to better paradigms if we think of them or if they come up down the road.
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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 is so great! Thanks for doing it!
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
|
||
export const KibanaLogic = kea<MakeLogicType<IKibanaValues>>({ | ||
path: ['enterprise_search', 'kibana_logic'], | ||
reducers: ({ 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.
Nice. I didn't realize you could initialize logic with props like this.
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.
Yeah! https://kea.js.org/docs/guide/additional/#props
Although as a warning (I think I mentioned this a few PRs back, but repeating it just as an fyi) if you set a value default to a passed prop without any fallbacks (e.g. someVar: [props.someVar, {}],
), if you ever mount without passing a someVar
prop the entire Kea/redux instance will error/crash. It's a good way of making sure you always have the data you need I guess? 😄
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.
LGTM.
elastic#78513) * Add KibanaLogic store/mount * Update usage of setBreadcrumbs/setDocTitle to KibanaLogic * Update usage of Kibana config context to KibanaLogic * Update usage of navigateToUrl context to KibanaLogic * 🔥 Remove unused shallow_usecontext mocks, repurpose file to shallow_useeffect - The file is now no longer used to mock useContext, only unseEffect, hence the rename * 🔥 Delete/repurpose mount with context helpers - Remove mountWithKibanaContext completely - Change mountWithContext to mountWithIntl, since that's the only context remaining, and move it to its own file - Change mountWithAsyncContext to just mountAsync and move it to its own file + add an option to pair it w/ mountWithIntl for formatted date/number support * 🔥 Delete KibanaContext and mockKibanaContext + minor newline linting/grouping tweaks Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
#78513) (#78692) * Add KibanaLogic store/mount * Update usage of setBreadcrumbs/setDocTitle to KibanaLogic * Update usage of Kibana config context to KibanaLogic * Update usage of navigateToUrl context to KibanaLogic * 🔥 Remove unused shallow_usecontext mocks, repurpose file to shallow_useeffect - The file is now no longer used to mock useContext, only unseEffect, hence the rename * 🔥 Delete/repurpose mount with context helpers - Remove mountWithKibanaContext completely - Change mountWithContext to mountWithIntl, since that's the only context remaining, and move it to its own file - Change mountWithAsyncContext to just mountAsync and move it to its own file + add an option to pair it w/ mountWithIntl for formatted date/number support * 🔥 Delete KibanaContext and mockKibanaContext + minor newline linting/grouping tweaks Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…a into add-anomalies-to-timeline * 'add-anomalies-to-timeline' of github.com:phillipb/kibana: (89 commits) Aligns several module versions across the repository (elastic#78327) Empty prompt and loading spinner for service map (elastic#78382) Change progress bar to spinner (elastic#78460) [QA][Code Coverage] Coverage teams lookup w/o Additional Config (elastic#77111) Slim down core bundle (elastic#75912) [Alerting] retry internal OCC calls within alertsClient (elastic#77838) [kbn/optimizer] only build xpack examples when building xpack plugins (elastic#78656) [Ingest Manager] Ingest setup upgrade (elastic#78081) [Ingest Manager] Surface saved object client 10,000 limitation to bulk actions UI (elastic#78520) fix name without a category or if field end with .text (elastic#78655) [Security Solution] [Detections] Log message enhancements (elastic#78429) [ML]DF Analytics exploration: default filter of results page by `defaultIsTraining` value in url (elastic#78303) [Enterprise Search] Remove all instances of KibanaContext to Kea store (elastic#78513) [ML] DF Analytics creation: ensure job did not fail to start before showing results link (elastic#78200) fix createAppNavigationHandler to use `navigateToUrl` (elastic#78583) Fixing a11y test failure on discover app (elastic#59975) (elastic#77614) [Security Solution] Initiate endpoint package upgrade from security app (elastic#77498) [kbn/es] use a basic build process (elastic#78090) [kbn/optimizer] fix .json extension handling (elastic#78524) Fix APM lodash imports (elastic#78438) ...
Summary
This is it, y'all!!! We've reached the endgame (well, there's still one more PR after this that handles sharing our store between our main app and our header app, but that won't require two teams to approve :)
Wow, such kea. much slim
Changelog
config
(not an API and doesn't update dynamically, but it seemed to fall under the general "comes from Kibana" bucket)navigateToUrl
setBreadcrumbs
setDocTitle
setHeaderActionMenu
- this will be in the next PR 🎉)As always, I recommend following along by commit! There's a lot of files touched + test refactors in there.
QA/Regression testing
Checklist