-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Expand file tree
/
Copy pathplugin.ts
More file actions
107 lines (97 loc) · 3.51 KB
/
plugin.ts
File metadata and controls
107 lines (97 loc) · 3.51 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { i18n } from '@kbn/i18n';
import { from } from 'rxjs';
import { distinct, map, switchMap } from 'rxjs';
import type { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { DEFAULT_APP_CATEGORIES, AppStatus } from '@kbn/core/public';
import type {
KibanaOverviewPluginSetup,
KibanaOverviewPluginStart,
AppPluginSetupDependencies,
AppPluginStartDependencies,
} from './types';
import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_PATH, PLUGIN_ICON } from '../common';
import { init as initStatsReporter } from './lib/ui_metric';
export class KibanaOverviewPlugin
implements
Plugin<
KibanaOverviewPluginSetup,
KibanaOverviewPluginStart,
AppPluginSetupDependencies,
AppPluginStartDependencies
>
{
public setup(
core: CoreSetup<AppPluginStartDependencies>,
{ home, usageCollection }: AppPluginSetupDependencies
): KibanaOverviewPluginSetup {
if (usageCollection) {
initStatsReporter(usageCollection.reportUiCounter);
}
const appUpdater$ = from(core.getStartServices()).pipe(
switchMap(([coreDeps]) => coreDeps.chrome.navLinks.getNavLinks$()),
map((navLinks) => {
const hasKibanaApp = Boolean(
navLinks.find(
({ id, category, visibleIn }) =>
visibleIn.length > 0 && category?.id === 'kibana' && id !== PLUGIN_ID
)
);
return hasKibanaApp;
}),
distinct(),
map((hasKibanaApp) => {
return () => {
return { status: hasKibanaApp ? AppStatus.accessible : AppStatus.inaccessible };
};
})
);
// Register an application into the side navigation menu
core.application.register({
category: DEFAULT_APP_CATEGORIES.kibana,
id: PLUGIN_ID,
title: PLUGIN_NAME,
euiIconType: PLUGIN_ICON,
order: 1,
updater$: appUpdater$,
appRoute: PLUGIN_PATH,
visibleIn: ['globalSearch', 'home', 'classicSideNav', 'projectSideNav'],
async mount(params: AppMountParameters) {
// Load application bundle
const { renderApp } = await import('./application');
// Get start services as specified in kibana.json
const [coreStart, depsStart] = await core.getStartServices();
// Render the application
return renderApp(coreStart, depsStart as AppPluginStartDependencies, params);
},
});
if (home) {
home.featureCatalogue.registerSolution({
id: 'kibana',
title: i18n.translate('kibanaOverview.kibana.solution.title', {
defaultMessage: 'Analytics',
}),
description: i18n.translate('kibanaOverview.kibana.solution.description', {
defaultMessage:
'Explore, visualize, and analyze your data using a powerful suite of analytical tools and applications.',
}),
icon: 'logoKibana',
path: PLUGIN_PATH,
order: 400,
});
}
// Return methods that should be available to other plugins
return {};
}
public start(core: CoreStart): KibanaOverviewPluginStart {
return {};
}
public stop() {}
}