-
Notifications
You must be signed in to change notification settings - Fork 8.1k
/
plugin.ts
102 lines (88 loc) · 3.45 KB
/
plugin.ts
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
91
92
93
94
95
96
97
98
99
100
101
102
/*
* 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 { i18n } from '@kbn/i18n';
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kbn/core/public';
import type { HomePublicPluginSetup } from '@kbn/home-plugin/public';
import { ManagementSetup } from '@kbn/management-plugin/public';
import { IndexManagementPluginSetup } from '@kbn/index-management-plugin/public';
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { DataViewsPublicPluginSetup } from '@kbn/data-views-plugin/public/types';
import { rollupBadgeExtension, rollupToggleExtension } from './extend_index_management';
import { UIM_APP_NAME } from '../common';
import { setHttp, init as initDocumentation } from './crud_app/services';
import { setNotifications, setFatalErrors, setUiStatsReporter } from './kibana_services';
import { ClientConfigType } from './types';
export interface RollupPluginSetupDependencies {
home?: HomePublicPluginSetup;
management: ManagementSetup;
indexManagement?: IndexManagementPluginSetup;
usageCollection?: UsageCollectionSetup;
dataViews: DataViewsPublicPluginSetup;
}
export class RollupPlugin implements Plugin {
constructor(private ctx: PluginInitializerContext) {}
setup(
core: CoreSetup,
{ home, management, indexManagement, usageCollection, dataViews }: RollupPluginSetupDependencies
) {
const {
ui: { enabled: isRollupUiEnabled },
} = this.ctx.config.get<ClientConfigType>();
setFatalErrors(core.fatalErrors);
if (usageCollection) {
setUiStatsReporter(usageCollection.reportUiCounter.bind(usageCollection, UIM_APP_NAME));
}
if (isRollupUiEnabled) {
if (indexManagement) {
indexManagement.extensionsService.addBadge(rollupBadgeExtension);
indexManagement.extensionsService.addToggle(rollupToggleExtension);
}
if (home) {
home.featureCatalogue.register({
id: 'rollup_jobs',
title: 'Rollups',
description: i18n.translate('xpack.rollupJobs.featureCatalogueDescription', {
defaultMessage:
'Summarize and store historical data in a smaller index for future analysis.',
}),
icon: 'indexRollupApp',
path: `/app/management/data/rollup_jobs/job_list`,
showOnHomePage: false,
category: 'admin',
});
}
dataViews.enableRollups();
const pluginName = i18n.translate('xpack.rollupJobs.appTitle', {
defaultMessage: 'Rollup Jobs',
});
management.sections.section.data.registerApp({
id: 'rollup_jobs',
title: pluginName,
order: 4,
async mount(params) {
const [coreStart] = await core.getStartServices();
const {
chrome: { docTitle },
} = coreStart;
docTitle.change(pluginName);
params.setBreadcrumbs([{ text: pluginName }]);
const { renderApp } = await import('./application');
const unmountAppCallback = await renderApp(core, params);
return () => {
docTitle.reset();
unmountAppCallback();
};
},
});
}
}
start(core: CoreStart) {
setHttp(core.http);
setNotifications(core.notifications);
initDocumentation(core.docLinks);
}
}