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

[Enterprise Search] Move header actions menu to be rendered after the main app + share its store #78691

Merged
merged 6 commits into from
Sep 29, 2020

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Sep 28, 2020

Summary

This is (hopefully) the final PR related to our Kea/store refactors, and solves the app race condition discussed in #78368 (comment). 🎉

What changed:

  • Enterprise Search apps should no longer register their header action menu component from plugin.ts. They should instead do so from their respective app indexes: 6925b13
  • This solves the issue of header menu apps rendering before the main app, and as such being unable to access its loaded Kea/redux stores. All header menu components should now be able to access HttpLogic, KibanaLogic, and any logic file instantiated by the main app.
  • Misc:
    • Removed temporary externalUrl workaround (9a855bd)
    • Test refactors (b87e8c2 & 791d537)

As always, I recommend following along by commit.

QA/Regression testing

  • Navigate to the Workplace Search plugin. Confirm their header action menu link still renders and goes to http://localhost:3002/ws/search

Checklist

- This is anticipation of upcoming renderHeaderActions changes which will require these helpers (particularly the unmount portion, for some reason renderHeaderAction tests fail if apps are not unmounted properly)

- Add mount/unmount helper (but leave first test the same so that devs can see the normal/expected usage)
- Add missing EnterpriseSearch app test
- Add mockContainer var for brevity, pull out MockApp in anticipation of future usage
- a light wrapper/helper around params.setHeaderActionMenu

+ update renderHeaderActions - move to main renderApp block to reflect that its relationship with renderApp ('child'/should be called within renderApp/shares dependencies).
- We need to update WS tests to setMockValues so that it doesn't override the renderHeaderActions mock
+ bonus - add setMockActions as well because since we're already here
+ bonus - update App Search index tests as well to match
+ ?? - for some reason tests were failing beceause react router wasn't mocked properly - requireActual seems to fix that
- set in elastic@9d993d8

- WorkplaceSearchHeaderActions should now still have the correct URL - and also now be able to access all Kea logic set up by the main app :)
@cee-chen cee-chen added Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.10.0 labels Sep 28, 2020
@cee-chen cee-chen requested review from scottybollinger and a team September 28, 2020 21:19
@cee-chen
Copy link
Member Author

Haha fffff. I forgot updating the App Search test would trigger CODEOWNERS. Oh well, worth CCing @JasonStoltz in on this one in any case since we discussed the race condition together in-depth!

@cee-chen
Copy link
Member Author

For a working example of header apps being able to access Kea stores, you can check out my header-actions-store-example branch. 🎉

Copy link
Contributor

@scottybollinger scottybollinger left a 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 doing this!

import { ApplicationStart, ChromeBreadcrumb } from 'src/core/public';

export interface IKibanaValues {
config: { host?: string };
navigateToUrl: ApplicationStart['navigateToUrl'];
setBreadcrumbs(crumbs: ChromeBreadcrumb[]): void;
setDocTitle(title: string): void;
renderHeaderActions(HeaderActions: FC): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL typing this way 💯

Copy link
Member Author

Choose a reason for hiding this comment

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

It felt weird importing all of React just for React.FC so I destructured it out. Totally agreed it looks weirdly naked though haha

@cee-chen
Copy link
Member Author

Thanks Byron!! 🙇‍♀️

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

async chunks size

id value diff baseline
enterpriseSearch 430.0KB -47.1KB 477.1KB

distributable file count

id value diff baseline
default 45832 -3 45835

page load bundle size

id value diff baseline
enterpriseSearch 20.0KB -1.7KB 21.7KB

History

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

@cee-chen cee-chen merged commit bc9bd13 into elastic:master Sep 29, 2020
@cee-chen cee-chen deleted the header-actions-store branch September 29, 2020 20:28
cee-chen pushed a commit that referenced this pull request Sep 29, 2020
… main app + share its store (#78691) (#78866)

* [Setup] Refactor renderApp tests

- This is anticipation of upcoming renderHeaderActions changes which will require these helpers (particularly the unmount portion, for some reason renderHeaderAction tests fail if apps are not unmounted properly)

- Add mount/unmount helper (but leave first test the same so that devs can see the normal/expected usage)
- Add missing EnterpriseSearch app test
- Add mockContainer var for brevity, pull out MockApp in anticipation of future usage

* Store renderHeaderActions in KibanaLogic

- a light wrapper/helper around params.setHeaderActionMenu

+ update renderHeaderActions - move to main renderApp block to reflect that its relationship with renderApp ('child'/should be called within renderApp/shares dependencies).

* Update WorkplaceSearch to render its header actions from app, not plugin.ts

* Update WorkplaceSearch tests (+ bonus refactor)

- We need to update WS tests to setMockValues so that it doesn't override the renderHeaderActions mock
+ bonus - add setMockActions as well because since we're already here
+ bonus - update App Search index tests as well to match
+ ?? - for some reason tests were failing beceause react router wasn't mocked properly - requireActual seems to fix that

* 🔥 Remove temporary externalUrl workaround

- set in 9d993d8

- WorkplaceSearchHeaderActions should now still have the correct URL - and also now be able to access all Kea logic set up by the main app :)
yctercero pushed a commit to yctercero/kibana that referenced this pull request Sep 30, 2020
… main app + share its store (elastic#78691)

* [Setup] Refactor renderApp tests

- This is anticipation of upcoming renderHeaderActions changes which will require these helpers (particularly the unmount portion, for some reason renderHeaderAction tests fail if apps are not unmounted properly)

- Add mount/unmount helper (but leave first test the same so that devs can see the normal/expected usage)
- Add missing EnterpriseSearch app test
- Add mockContainer var for brevity, pull out MockApp in anticipation of future usage

* Store renderHeaderActions in KibanaLogic

- a light wrapper/helper around params.setHeaderActionMenu

+ update renderHeaderActions - move to main renderApp block to reflect that its relationship with renderApp ('child'/should be called within renderApp/shares dependencies).

* Update WorkplaceSearch to render its header actions from app, not plugin.ts

* Update WorkplaceSearch tests (+ bonus refactor)

- We need to update WS tests to setMockValues so that it doesn't override the renderHeaderActions mock
+ bonus - add setMockActions as well because since we're already here
+ bonus - update App Search index tests as well to match
+ ?? - for some reason tests were failing beceause react router wasn't mocked properly - requireActual seems to fix that

* 🔥 Remove temporary externalUrl workaround

- set in elastic@9d993d8

- WorkplaceSearchHeaderActions should now still have the correct URL - and also now be able to access all Kea logic set up by the main app :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants