-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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 LicenseContext to Kea #78231
Changes from all commits
450c6b7
169d8bb
06293f0
d4dd185
6fa43f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ import { getContext, resetContext } from 'kea'; | |
|
||
import { I18nProvider } from '@kbn/i18n/react'; | ||
import { AppMountParameters, CoreStart, ApplicationStart, ChromeBreadcrumb } from 'src/core/public'; | ||
import { ClientConfigType, ClientData, PluginsSetup } from '../plugin'; | ||
import { LicenseProvider } from './shared/licensing'; | ||
import { PluginsStart, ClientConfigType, ClientData } from '../plugin'; | ||
import { mountLicensingLogic } from './shared/licensing'; | ||
import { mountHttpLogic } from './shared/http'; | ||
import { mountFlashMessagesLogic } from './shared/flash_messages'; | ||
import { IExternalUrl } from './shared/enterprise_search_url'; | ||
|
@@ -39,15 +39,18 @@ export const KibanaContext = React.createContext({}); | |
|
||
export const renderApp = ( | ||
App: React.FC<IInitialAppData>, | ||
params: AppMountParameters, | ||
core: CoreStart, | ||
plugins: PluginsSetup, | ||
config: ClientConfigType, | ||
{ externalUrl, errorConnecting, ...initialData }: ClientData | ||
{ params, core, plugins }: { params: AppMountParameters; core: CoreStart; plugins: PluginsStart }, | ||
{ config, data }: { config: ClientConfigType; data: ClientData } | ||
) => { | ||
const { externalUrl, errorConnecting, ...initialData } = data; | ||
|
||
resetContext({ createStore: true }); | ||
const store = getContext().store as Store; | ||
|
||
const unmountLicensingLogic = mountLicensingLogic({ | ||
license$: plugins.licensing.license$, | ||
}); | ||
|
||
const unmountHttpLogic = mountHttpLogic({ | ||
http: core.http, | ||
errorConnecting, | ||
|
@@ -67,19 +70,18 @@ export const renderApp = ( | |
setDocTitle: core.chrome.docTitle.change, | ||
}} | ||
> | ||
<LicenseProvider license$={plugins.licensing.license$}> | ||
<Provider store={store}> | ||
<Router history={params.history}> | ||
<App {...initialData} /> | ||
</Router> | ||
</Provider> | ||
</LicenseProvider> | ||
<Provider store={store}> | ||
<Router history={params.history}> | ||
<App {...initialData} /> | ||
</Router> | ||
</Provider> | ||
</KibanaContext.Provider> | ||
</I18nProvider>, | ||
params.element | ||
); | ||
return () => { | ||
ReactDOM.unmountComponentAtNode(params.element); | ||
unmountLicensingLogic(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this list gets much longer I might try to think of a better solution than losting all of these inputs.
then we'd never forget to unmount! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sure! FWIW, it stops at 4 total (by the end of my series of PRs) but I can definitely see a case for pulling all our mounts out to a separate file/helper and returning an array of unmounts. I think 4 is just on the border to not a completely warrant a separate helper, but let me know if you disagree 🤔 |
||
unmountHttpLogic(); | ||
unmountFlashMessagesLogic(); | ||
}; | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 one more wrapper to go! 🔥