Skip to content

Commit

Permalink
🔥 Delete KibanaContext and mockKibanaContext
Browse files Browse the repository at this point in the history
+ minor newline linting/grouping tweaks
  • Loading branch information
cee-chen committed Sep 24, 2020
1 parent 90bb26b commit 1f6f4e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

export { mockHistory, mockLocation } from './react_router_history.mock';
export { mockKibanaContext } from './kibana_context.mock';
export { mockKibanaValues } from './kibana_logic.mock';
export { mockLicensingValues } from './licensing_logic.mock';
export { mockHttpValues } from './http_logic.mock';
Expand Down

This file was deleted.

42 changes: 11 additions & 31 deletions x-pack/plugins/enterprise_search/public/applications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,20 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Router } from 'react-router-dom';

import { Provider } from 'react-redux';
import { Store } from 'redux';
import { getContext, resetContext } from 'kea';

import { I18nProvider } from '@kbn/i18n/react';
import { AppMountParameters, CoreStart, ApplicationStart, ChromeBreadcrumb } from 'src/core/public';

import { AppMountParameters, CoreStart } from 'src/core/public';
import { PluginsStart, ClientConfigType, ClientData } from '../plugin';
import { IInitialAppData } from '../../common/types';

import { mountKibanaLogic } from './shared/kibana';
import { mountLicensingLogic } from './shared/licensing';
import { mountHttpLogic } from './shared/http';
import { mountFlashMessagesLogic } from './shared/flash_messages';
import { externalUrl } from './shared/enterprise_search_url';
import { IInitialAppData } from '../../common/types';

export interface IKibanaContext {
config: { host?: string };
navigateToUrl: ApplicationStart['navigateToUrl'];
setBreadcrumbs(crumbs: ChromeBreadcrumb[]): void;
setDocTitle(title: string): void;
}

export const KibanaContext = React.createContext({});

/**
* This file serves as a reusable wrapper to share Kibana-level context and other helpers
Expand All @@ -55,35 +45,25 @@ export const renderApp = (
setBreadcrumbs: core.chrome.setBreadcrumbs,
setDocTitle: core.chrome.docTitle.change,
});

const unmountLicensingLogic = mountLicensingLogic({
license$: plugins.licensing.license$,
});

const unmountHttpLogic = mountHttpLogic({
http: core.http,
errorConnecting,
readOnlyMode: initialData.readOnlyMode,
});

const unmountFlashMessagesLogic = mountFlashMessagesLogic({ history: params.history });
const unmountFlashMessagesLogic = mountFlashMessagesLogic({
history: params.history,
});

ReactDOM.render(
<I18nProvider>
<KibanaContext.Provider
value={{
config,
navigateToUrl: core.application.navigateToUrl,
setBreadcrumbs: core.chrome.setBreadcrumbs,
setDocTitle: core.chrome.docTitle.change,
}}
>
<Provider store={store}>
<Router history={params.history}>
<App {...initialData} />
</Router>
</Provider>
</KibanaContext.Provider>
<Provider store={store}>
<Router history={params.history}>
<App {...initialData} />
</Router>
</Provider>
</I18nProvider>,
params.element
);
Expand Down

0 comments on commit 1f6f4e4

Please sign in to comment.