Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppDependencies>;

const setAppDependencies = (deps: AppDependencies) => {
setDependencyCache({
autocomplete: deps.plugins.data.autocomplete,
docLinks: legacyDocLinks as any,
basePath: legacyBasePath as any,
XSRF: chrome.getXsrfToken(),
});
DependenciesContext = createContext<AppDependencies>(deps);
return DependenciesContext.Provider;
};
Expand Down
7 changes: 4 additions & 3 deletions x-pack/legacy/plugins/transform/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -113,7 +114,7 @@ export class Plugin {
unmountReactApp();
const elem = document.getElementById(REACT_ROOT_ID);
if (elem) {
renderReact(elem, AppDependencies);
renderReact(elem, appDependencies);
}
});
},
Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/plugins/transform/public/shared_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/transform/public/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type AppCore = Pick<
>;

export interface AppPlugins {
data: DataPublicPluginStart;
management: {
sections: typeof management;
};
Expand Down