forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
90 lines (83 loc) · 3.42 KB
/
index.ts
File metadata and controls
90 lines (83 loc) · 3.42 KB
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
81
82
83
84
85
86
87
88
89
90
/*
* 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 { ContainerModule } from 'inversify';
import { OnSetup, PluginSetup, PluginStart, Start } from '@kbn/core-di';
import { CoreSetup } from '@kbn/core-di-browser';
import type { ManagementSetup } from '@kbn/management-plugin/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { LensPublicStart } from '@kbn/lens-plugin/public';
import {
ALERTING_V2_SECTION_ID,
ALERTING_V2_RULES_APP_ID,
ALERTING_V2_NOTIFICATION_POLICIES_APP_ID,
} from './constants';
import { NotificationPoliciesApi } from './services/notification_policies_api';
import { RulesApi } from './services/rules_api';
import { WorkflowsApi } from './services/workflows_api';
import { setKibanaServices } from './kibana_services';
import { DynamicRuleFormFlyout } from './create_rule_form_flyout';
import type { AlertingV2PublicStart } from './types';
export type { AlertingV2PublicStart } from './types';
export type { CreateRuleFormFlyoutProps } from './create_rule_form_flyout';
export const module = new ContainerModule(({ bind }) => {
bind(RulesApi).toSelf().inSingletonScope();
bind(NotificationPoliciesApi).toSelf().inSingletonScope();
bind(WorkflowsApi).toSelf().inSingletonScope();
bind(Start).toConstantValue({
DynamicRuleFormFlyout,
} satisfies AlertingV2PublicStart);
bind(OnSetup).toConstantValue((container) => {
const getStartServices = container.get(CoreSetup('getStartServices'));
getStartServices().then(([coreStart]) => {
const diContainer = coreStart.injection.getContainer();
setKibanaServices({
http: coreStart.http,
notifications: coreStart.notifications,
application: coreStart.application,
data: diContainer.get(PluginStart('data')) as DataPublicPluginStart,
dataViews: diContainer.get(PluginStart('dataViews')) as DataViewsPublicPluginStart,
lens: diContainer.get(PluginStart('lens')) as LensPublicStart,
});
});
const management = container.get(PluginSetup('management')) as ManagementSetup;
const alertingV2Section = management.sections.register({
id: ALERTING_V2_SECTION_ID,
title: 'V2 Alerting Preview',
tip: 'Start exploring our latest alerts experience',
order: 1,
});
alertingV2Section.registerApp({
id: ALERTING_V2_RULES_APP_ID,
title: 'Rules',
order: 1,
async mount(params) {
const [coreStart] = await getStartServices();
const { mountAlertingV2App } = await import('./application/mount');
return mountAlertingV2App({
params,
container: coreStart.injection.getContainer(),
coreStart,
});
},
});
alertingV2Section.registerApp({
id: ALERTING_V2_NOTIFICATION_POLICIES_APP_ID,
title: 'Notification Policies',
order: 2,
async mount(params) {
const [coreStart] = await getStartServices();
const { mountNotificationPoliciesApp } = await import('./application/mount');
return mountNotificationPoliciesApp({
params,
container: coreStart.injection.getContainer(),
coreStart,
});
},
});
});
});