-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.tsx
80 lines (73 loc) · 2.35 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import 'react-vis/dist/style.css';
import type { ObservabilityRuleTypeRegistry } from '../../../observability/public';
import { ConfigSchema } from '../';
import {
AppMountParameters,
CoreStart,
APP_WRAPPER_CLASS,
} from '../../../../../src/core/public';
import { ApmPluginSetupDeps, ApmPluginStartDeps } from '../plugin';
import { createCallApmApi } from '../services/rest/createCallApmApi';
import { createStaticIndexPattern } from '../services/rest/index_pattern';
import { setHelpExtension } from '../setHelpExtension';
import { setReadonlyBadge } from '../updateBadge';
import { ApmAppRoot } from '../components/routing/app_root';
/**
* This module is rendered asynchronously in the Kibana platform.
*/
export const renderApp = ({
coreStart,
pluginsSetup,
appMountParameters,
config,
pluginsStart,
observabilityRuleTypeRegistry,
}: {
coreStart: CoreStart;
pluginsSetup: ApmPluginSetupDeps;
appMountParameters: AppMountParameters;
config: ConfigSchema;
pluginsStart: ApmPluginStartDeps;
observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry;
}) => {
const { element } = appMountParameters;
const apmPluginContextValue = {
appMountParameters,
config,
core: coreStart,
plugins: pluginsSetup,
data: pluginsStart.data,
inspector: pluginsStart.inspector,
observability: pluginsStart.observability,
observabilityRuleTypeRegistry,
};
// render APM feedback link in global help menu
setHelpExtension(coreStart);
setReadonlyBadge(coreStart);
createCallApmApi(coreStart);
// Automatically creates static index pattern and stores as saved object
createStaticIndexPattern().catch((e) => {
// eslint-disable-next-line no-console
console.log('Error creating static index pattern', e);
});
// add .kbnAppWrappers class to root element
element.classList.add(APP_WRAPPER_CLASS);
ReactDOM.render(
<ApmAppRoot
apmPluginContextValue={apmPluginContextValue}
pluginsStart={pluginsStart}
/>,
element
);
return () => {
ReactDOM.unmountComponentAtNode(element);
};
};