Skip to content

Commit ba80b40

Browse files
committed
[transform] Fix types, tests.
1 parent e1320e6 commit ba80b40

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

x-pack/legacy/plugins/transform/public/app/app.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { SectionError } from './components';
1414
import { CLIENT_BASE_PATH, SECTION_SLUG } from './constants';
1515
import { getAppProviders } from './app_dependencies';
1616
import { AuthorizationContext } from './lib/authorization';
17-
import { AppCore, AppPlugins } from './types';
17+
import { AppDependencies } from '../shim';
1818

1919
import { CreateTransformSection } from './sections/create_transform';
2020
import { TransformManagementSection } from './sections/transform_management';
@@ -54,8 +54,8 @@ export const App: FC = () => {
5454
);
5555
};
5656

57-
export const renderReact = (elem: Element, core: AppCore, plugins: AppPlugins) => {
58-
const Providers = getAppProviders({ core, plugins });
57+
export const renderReact = (elem: Element, appDependencies: AppDependencies) => {
58+
const Providers = getAppProviders(appDependencies);
5959

6060
render(
6161
<Providers>

x-pack/legacy/plugins/transform/public/app/app_dependencies.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { HashRouter } from 'react-router-dom';
99

1010
import { API_BASE_PATH } from '../../common/constants';
1111
import { AuthorizationProvider } from './lib/authorization';
12-
import { AppDependencies } from './types';
12+
import { AppDependencies } from '../shim';
1313

1414
let DependenciesContext: React.Context<AppDependencies>;
1515

x-pack/legacy/plugins/transform/public/app/lib/kibana/kibana_provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface Props {
3030

3131
export const KibanaProvider: FC<Props> = ({ savedObjectId, children }) => {
3232
const appDeps = useAppDependencies();
33-
const savedSearches = appDeps.core.savedSearches.getClient();
33+
const savedSearches = appDeps.plugins.savedSearches.getClient();
3434

3535
const [contextValue, setContextValue] = useState<KibanaContextValue>({ initialized: false });
3636

x-pack/legacy/plugins/transform/public/app/types/app.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

x-pack/legacy/plugins/transform/public/app/types/index.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

x-pack/legacy/plugins/transform/public/plugin.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { SavedSearchLoader } from '../../../../../src/legacy/core_plugins/kibana
1212
import { PLUGIN } from '../common/constants';
1313
import { CLIENT_BASE_PATH } from './app/constants';
1414
import { renderReact } from './app/app';
15-
import { AppCore, AppPlugins } from './app/types';
1615
import { Core, Plugins } from './shim';
1716

1817
import { breadcrumbService, docTitleService } from './app/services/navigation';
@@ -30,6 +29,15 @@ export class Plugin {
3029
const { http, routing, legacyHttp, chrome, documentation, docTitle } = core;
3130
const { management, savedSearches: coreSavedSearches, uiMetric } = plugins;
3231

32+
// AppCore/AppPlugins to be passed on as React context
33+
const AppDependencies = {
34+
core: { chrome, http, i18n: core.i18n },
35+
plugins: {
36+
management: { sections: management.sections },
37+
savedSearches: coreSavedSearches,
38+
},
39+
};
40+
3341
// Register management section
3442
const esSection = management.sections.getSection('elasticsearch');
3543
esSection.register(PLUGIN.ID, {
@@ -101,11 +109,7 @@ export class Plugin {
101109
unmountReactApp();
102110
const elem = document.getElementById(REACT_ROOT_ID);
103111
if (elem) {
104-
renderReact(
105-
elem,
106-
{ chrome, http, savedSearches: coreSavedSearches } as AppCore,
107-
{ management: { sections: management.sections } } as AppPlugins
108-
);
112+
renderReact(elem, AppDependencies);
109113
}
110114
});
111115
},

x-pack/legacy/plugins/transform/public/shim.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,25 @@ import { docTitle } from 'ui/doc_title/doc_title';
1414
import { createUiStatsReporter } from '../../../../../src/legacy/core_plugins/ui_metric/public';
1515
import { SavedSearchLoader } from '../../../../../src/legacy/core_plugins/kibana/public/discover/types';
1616

17-
type npCore = typeof npStart.core;
17+
export type npCore = typeof npStart.core;
18+
19+
// AppCore/AppPlugins is the set of core features/plugins
20+
// we pass on via context/hooks to the app and its components.
21+
export type AppCore = Pick<npCore, 'chrome' | 'http' | 'i18n'>;
1822

1923
export interface AppPlugins {
2024
management: {
2125
sections: typeof management;
2226
};
27+
savedSearches: {
28+
getClient(): any;
29+
setClient(client: any): void;
30+
};
31+
}
32+
33+
export interface AppDependencies {
34+
core: AppCore;
35+
plugins: AppPlugins;
2336
}
2437

2538
export interface Core extends npCore {
@@ -47,10 +60,6 @@ export interface Plugins extends AppPlugins {
4760
BREADCRUMB: typeof MANAGEMENT_BREADCRUMB;
4861
};
4962
};
50-
savedSearches: {
51-
getClient(): any;
52-
setClient(client: any): void;
53-
};
5463
uiMetric: {
5564
createUiStatsReporter: typeof createUiStatsReporter;
5665
};

x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ export default function({ getService }: FtrProviderContext) {
280280
after(async () => {
281281
await esArchiver.unload('ml/farequote');
282282
await ml.api.cleanMlIndices();
283-
await ml.api.cleanDataframeIndices();
284283
});
285284

286285
for (const testData of testDataList) {

0 commit comments

Comments
 (0)