diff --git a/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx b/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx index 28a54e67bf838..282d1380b396b 100644 --- a/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx +++ b/x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx @@ -7,13 +7,35 @@ import React, { createContext, useContext, ReactNode } from 'react'; import { HashRouter } from 'react-router-dom'; +import chrome from 'ui/chrome'; +import { metadata } from 'ui/metadata'; + import { API_BASE_PATH } from '../../common/constants'; -import { AuthorizationProvider } from './lib/authorization'; + +import { setDependencyCache } from '../shared_imports'; import { AppDependencies } from '../shim'; +import { AuthorizationProvider } from './lib/authorization'; + +const legacyBasePath = { + prepend: chrome.addBasePath, + get: chrome.getBasePath, + remove: () => {}, +}; +const legacyDocLinks = { + ELASTIC_WEBSITE_URL: 'https://www.elastic.co/', + DOC_LINK_VERSION: metadata.branch, +}; + let DependenciesContext: React.Context; const setAppDependencies = (deps: AppDependencies) => { + setDependencyCache({ + autocomplete: deps.plugins.data.autocomplete, + docLinks: legacyDocLinks as any, + basePath: legacyBasePath as any, + XSRF: chrome.getXsrfToken(), + }); DependenciesContext = createContext(deps); return DependenciesContext.Provider; }; diff --git a/x-pack/legacy/plugins/transform/public/plugin.ts b/x-pack/legacy/plugins/transform/public/plugin.ts index 3b02d07b8c150..2e29ecfc19510 100644 --- a/x-pack/legacy/plugins/transform/public/plugin.ts +++ b/x-pack/legacy/plugins/transform/public/plugin.ts @@ -35,12 +35,13 @@ export class Plugin { savedObjects, overlays, } = core; - const { management, savedSearches: coreSavedSearches, uiMetric } = plugins; + const { data, management, savedSearches: coreSavedSearches, uiMetric } = plugins; // AppCore/AppPlugins to be passed on as React context - const AppDependencies = { + const appDependencies = { core: { chrome, http, i18n: core.i18n, uiSettings, savedObjects, overlays }, plugins: { + data, management: { sections: management.sections }, savedSearches: coreSavedSearches, }, @@ -113,7 +114,7 @@ export class Plugin { unmountReactApp(); const elem = document.getElementById(REACT_ROOT_ID); if (elem) { - renderReact(elem, AppDependencies); + renderReact(elem, appDependencies); } }); }, diff --git a/x-pack/legacy/plugins/transform/public/shared_imports.ts b/x-pack/legacy/plugins/transform/public/shared_imports.ts index fe9fe8b8e695b..74e0c9a3878db 100644 --- a/x-pack/legacy/plugins/transform/public/shared_imports.ts +++ b/x-pack/legacy/plugins/transform/public/shared_imports.ts @@ -32,5 +32,8 @@ export { SORT_DIRECTION, } from '../../ml/public/application/components/ml_in_memory_table'; +// Needs to be imported because we're reusing KqlFilterBar which depends on it. +export { setDependencyCache } from '../../ml/public/application/util/dependency_cache'; + // @ts-ignore: could not find declaration file for module export { KqlFilterBar } from '../../ml/public/application/components/kql_filter_bar'; diff --git a/x-pack/legacy/plugins/transform/public/shim.ts b/x-pack/legacy/plugins/transform/public/shim.ts index 758cc90210579..38bb072ff9eb7 100644 --- a/x-pack/legacy/plugins/transform/public/shim.ts +++ b/x-pack/legacy/plugins/transform/public/shim.ts @@ -26,6 +26,7 @@ export type AppCore = Pick< >; export interface AppPlugins { + data: DataPublicPluginStart; management: { sections: typeof management; };