Skip to content

Commit 96e9ce6

Browse files
committed
Render Watcher title in tab and clear it on unmount.
- Refactor boot file to follow index-oriented pattern of other plugins.
1 parent ae8ab3b commit 96e9ce6

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

x-pack/plugins/watcher/public/application/boot.tsx renamed to x-pack/plugins/watcher/public/application/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface BootDeps extends AppDeps {
1717
I18nContext: any;
1818
}
1919

20-
export const boot = (bootDeps: BootDeps) => {
20+
export const renderApp = (bootDeps: BootDeps) => {
2121
const { I18nContext, element, savedObjects, ...appDeps } = bootDeps;
2222

2323
setHttpClient(appDeps.http);
@@ -29,6 +29,7 @@ export const boot = (bootDeps: BootDeps) => {
2929
</I18nContext>,
3030
element
3131
);
32+
3233
return () => {
3334
unmountComponentAtNode(element);
3435
};

x-pack/plugins/watcher/public/plugin.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,31 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
3030
) {
3131
const esSection = management.sections.section.insightsAndAlerting;
3232

33+
const pluginName = i18n.translate(
34+
'xpack.watcher.sections.watchList.managementSection.watcherDisplayName',
35+
{ defaultMessage: 'Watcher' }
36+
);
37+
3338
const watcherESApp = esSection.registerApp({
3439
id: 'watcher',
35-
title: i18n.translate(
36-
'xpack.watcher.sections.watchList.managementSection.watcherDisplayName',
37-
{ defaultMessage: 'Watcher' }
38-
),
40+
title: pluginName,
3941
order: 3,
4042
mount: async ({ element, setBreadcrumbs, history }) => {
41-
const [core] = await getStartServices();
42-
const { i18n: i18nDep, docLinks, savedObjects, application } = core;
43-
const { boot } = await import('./application/boot');
43+
const [coreStart] = await getStartServices();
44+
const {
45+
chrome: { docTitle },
46+
i18n: i18nDep,
47+
docLinks,
48+
savedObjects,
49+
application,
50+
} = coreStart;
51+
52+
docTitle.change(pluginName);
53+
54+
const { renderApp } = await import('./application');
4455
const { TimeBuckets } = await import('./legacy');
4556

46-
return boot({
57+
const unmountAppCallback = renderApp({
4758
// Skip the first license status, because that's already been used to determine
4859
// whether to include Watcher.
4960
licenseStatus$: licensing.license$.pipe(skip(1), map(licenseToLicenseStatus)),
@@ -60,6 +71,11 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
6071
history,
6172
getUrlForApp: application.getUrlForApp,
6273
});
74+
75+
return () => {
76+
docTitle.reset();
77+
unmountAppCallback();
78+
};
6379
},
6480
});
6581

0 commit comments

Comments
 (0)