From ce496b3cc9d1bbbbceccd7cb251c7cc38ccf3143 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Fri, 13 Dec 2019 10:33:28 +0000 Subject: [PATCH] [ML] Removing context API (#52953) --- .../plugins/ml/public/application/app.tsx | 19 +++++++++++-------- x-pack/legacy/plugins/ml/public/plugin.ts | 10 ++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/application/app.tsx b/x-pack/legacy/plugins/ml/public/application/app.tsx index c790f10725716..085e395f2ebf7 100644 --- a/x-pack/legacy/plugins/ml/public/application/app.tsx +++ b/x-pack/legacy/plugins/ml/public/application/app.tsx @@ -13,8 +13,7 @@ import 'ui/autoload/all'; // needed to make syntax highlighting work in ace editors import 'ace'; - -import { AppMountContext, AppMountParameters } from 'kibana/public'; +import { AppMountParameters, CoreStart } from 'kibana/public'; import { IndexPatternsContract, Plugin as DataPlugin, @@ -30,24 +29,28 @@ export interface MlDependencies extends AppMountParameters { } interface AppProps { - context: AppMountContext; + coreStart: CoreStart; indexPatterns: IndexPatternsContract; } -const App: FC = ({ context, indexPatterns }) => { - const config = (context.core.uiSettings as never) as KibanaConfigTypeFix; // TODO - make this UiSettingsClientContract, get rid of KibanaConfigTypeFix +const App: FC = ({ coreStart, indexPatterns }) => { + const config = (coreStart.uiSettings as never) as KibanaConfigTypeFix; // TODO - make this UiSettingsClientContract, get rid of KibanaConfigTypeFix return ( ); }; -export const renderApp = (context: AppMountContext, { element, indexPatterns }: MlDependencies) => { - ReactDOM.render(, element); +export const renderApp = ( + coreStart: CoreStart, + depsStart: object, + { element, indexPatterns }: MlDependencies +) => { + ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); }; diff --git a/x-pack/legacy/plugins/ml/public/plugin.ts b/x-pack/legacy/plugins/ml/public/plugin.ts index 2a80b18446046..f68d1ffe88216 100644 --- a/x-pack/legacy/plugins/ml/public/plugin.ts +++ b/x-pack/legacy/plugins/ml/public/plugin.ts @@ -11,21 +11,15 @@ export interface MlSetupDependencies { npData: ReturnType; } -export interface MlStartDependencies { - __LEGACY: { - Storage: any; - xpackInfo: any; - }; -} - export class MlPlugin implements Plugin { setup(core: CoreSetup, { npData }: MlSetupDependencies) { core.application.register({ id: 'ml', title: 'Machine learning', async mount(context, params) { + const [coreStart, depsStart] = await core.getStartServices(); const { renderApp } = await import('./application/app'); - return renderApp(context, { + return renderApp(coreStart, depsStart, { ...params, indexPatterns: npData.indexPatterns, npData,