-
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] Convert our public_url
route to config_data
and collect initialAppData
#75616
Conversation
export interface IAccount { | ||
id: string; | ||
groups: string[]; | ||
isAdmin: boolean; | ||
isCurated: boolean; | ||
canCreatePersonalSources: boolean; | ||
viewedOnboardingPage: boolean; | ||
} | ||
|
||
export interface IOrganization { | ||
name: string; | ||
defaultOrgName: string; | ||
} |
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.
@scottybollinger FYI that I moved Workplace Search's IAccount/IOrganization types here (since both public/ and server/ files use it).
Also note that I deleted IUser
, since we're no longer showing current user data (Kibana does that for us)
@@ -24,7 +24,6 @@ const account = { | |||
isAdmin: true, | |||
canCreatePersonalSources: true, | |||
groups: [], | |||
supportEligible: true, |
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.
@scottybollinger Another heads up that I also deleted this, it doesn't seem to be in the initial AppLogic API spec and I don't see it used anywhere in ent-search either
import { Provider } from 'react-redux'; | ||
import { Store } from 'redux'; | ||
import { getContext, resetContext } from 'kea'; | ||
|
||
resetContext({ createStore: true }); | ||
|
||
const store = getContext().store as Store; |
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.
Another heads up to WS that this was moved to the top-level public/applications/index.tsx
- DRYs out repeated code - This will be used by an upcoming server/ endpoint change, hence why it's in common
- In preparation for upcoming server logic that will need to reuse these types + DRY out and clean up workplace_search types - remove unused supportEligible - remove currentUser - unneeded in Kibana
… API from public/plugin + set returned initialData in this.data
- resetContext at the top level only gets called once total on first plugin load and never after, causing navigating between WS and AS to crash when both have Kea - this fixes the issue - moves redux Provider to top level app as well
9e96af7
to
f4d815e
Compare
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
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 all seems reasonable to me. I have no concerns.
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
jest.mock('kea', () => ({ |
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.
Good call making this a common mock
@@ -14,6 +14,7 @@ import { mockLicenseContext } from './license_context.mock'; | |||
jest.mock('react', () => ({ | |||
...(jest.requireActual('react') as object), | |||
useContext: jest.fn(() => ({ ...mockKibanaContext, ...mockLicenseContext })), | |||
useEffect: jest.fn((fn) => fn()), // Calls on mount/every update - use mount for more complex behavior |
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.
Could you explain why you are mocking useEffect
for shallow rendering?
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.
So that these lines in app_search/index.tsx
run in the test:
kibana/x-pack/plugins/enterprise_search/public/applications/app_search/index.tsx
Lines 52 to 54 in f4d815e
useEffect(() => { | |
if (!hasInitialized) initializeAppData(props); | |
}, [hasInitialized]); |
Unfortunately Enzyme doesn't yet call useEffect() in shallow() so we have to kind of stub it ourselves. It's not perfect however since it ignores the [changeOnThisVar]
array that you can pass into useEffect - if you want to really granularly test that, you'll have to use mount()
.
It's OK however in this case because I just want to check that initializeAppData
was called on mount.
@scottybollinger - I know you're out today so apologies if I'm merging anything too quickly with changes that WS didn't want - feel free to let me know next week and I can revert or make changes as needed! |
…nd collect initialAppData (#75616) (#75667) * [Setup] DRY out stripTrailingSlash helper - DRYs out repeated code - This will be used by an upcoming server/ endpoint change, hence why it's in common * [Setup] DRY out initial app data types to common/types - In preparation for upcoming server logic that will need to reuse these types + DRY out and clean up workplace_search types - remove unused supportEligible - remove currentUser - unneeded in Kibana * Update callEnterpriseSearchConfigAPI to parse and fetch new expected data * Remove /public_url API for /config_data * Remove getPublicUrl in favor of directly calling the new /config_data API from public/plugin + set returned initialData in this.data * Set up product apps to be passed initial data as props * Fix for Kea/redux state not resetting between AS<->WS nav - resetContext at the top level only gets called once total on first plugin load and never after, causing navigating between WS and AS to crash when both have Kea - this fixes the issue - moves redux Provider to top level app as well * Add very basic Kea logic file to App Search * Finish AppSearchConfigured tests & set up kea+useEffect mocks * [Cleanup] DRY out repeated mock initialAppData to a reusable defaults constant
* master: (71 commits) [Lens] Show 'No data for this field' for empty field in accordion (elastic#73772) Skip failing lens test Configure ScopedHistory consistenty regardless of URL used to mount app (elastic#75074) Fix returned payload by "search" usage collector (elastic#75340) [Security Solution] Fix missing key error (elastic#75576) Upgrade EUI to v27.4.1 (elastic#75240) Update datasets UI copy to data streams (elastic#75618) [Lens] Register saved object references (elastic#74523) [DOCS] Update links to Beats documentation (elastic#70380) [Enterprise Search] Convert our `public_url` route to `config_data` and collect initialAppData (elastic#75616) [Usage Collection Schemas] Remove Legacy entries (elastic#75652) [Dashboard First] Lens Originating App Breadcrumb (elastic#75470) Improve login UI error message. (elastic#75642) [Security Solution] modify circular deps checker to output images of circular deps graphs (elastic#75579) [Data Telemetry] Add index pattern to identify "meow" attacks (elastic#75163) Migrate CSP usage collector to `kibana_usage_collection` plugin (elastic#75536) [Console] Get ES Config from core (elastic#75406) [Uptime] Add delay in telemetry test (elastic#75162) [Lens] Use index pattern service instead saved object client (elastic#74654) Embeddable input (elastic#73033) ...
export interface IInitialAppData { | ||
readOnlyMode?: boolean; | ||
ilmEnabled?: boolean; | ||
configuredLimits?: IConfiguredLimits; |
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.
Why is this top-level and not nested under appSearch
?
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 believe Oleksiy mentioned that Workplace Search either uses configurable limits as well (possibly in the back-end) or may, in the future, add more configurable limits to the front-end.
Summary
TL;DR of changes (or, follow along by commit):
public_url
API route in favor of newconfig_data
routecallEnterpriseSearchConfigAPI
to account for new (expected) data<Provider>
to a top-level wrapper and correctly resets state between AS<->WS navigationQA
console.log('hasInitialized', hasInitialized);
topublic/applications/app_search/index.tsx
(line 55 or so) and confirm that it updates totrue
and staystrue
when navigating within App Search pagesChecklist