Skip to content

Commit 35ea287

Browse files
committed
Remove use of copied MANAGEMENT_BREADCRUMBS and use setBreadcrumbs from management section's mount
1 parent 1ffb171 commit 35ea287

8 files changed

Lines changed: 18 additions & 47 deletions

File tree

x-pack/plugins/watcher/__jest__/client_integration/helpers/app_context.mock.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import React from 'react';
88
import { of } from 'rxjs';
99
import { ComponentType } from 'enzyme';
1010
import {
11-
chromeServiceMock,
1211
docLinksServiceMock,
1312
uiSettingsServiceMock,
1413
notificationServiceMock,
@@ -31,8 +30,7 @@ class MockTimeBuckets {
3130
export const mockContextValue = {
3231
licenseStatus$: of<LicenseStatus>({ valid: true }),
3332
docLinks: docLinksServiceMock.createStartContract(),
34-
chrome: chromeServiceMock.createStartContract(),
35-
MANAGEMENT_BREADCRUMB: { text: 'test' },
33+
setBreadcrumbs: jest.fn(),
3634
createTimeBuckets: () => new MockTimeBuckets(),
3735
uiSettings: uiSettingsServiceMock.createSetupContract(),
3836
toasts: notificationServiceMock.createSetupContract().toasts,

x-pack/plugins/watcher/public/application/app.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,7 @@
66

77
import React, { useEffect, useState } from 'react';
88
import { Observable } from 'rxjs';
9-
import {
10-
ChromeStart,
11-
DocLinksStart,
12-
HttpSetup,
13-
ToastsSetup,
14-
IUiSettingsClient,
15-
} from 'kibana/public';
9+
import { DocLinksStart, HttpSetup, ToastsSetup, IUiSettingsClient } from 'kibana/public';
1610

1711
import {
1812
HashRouter,
@@ -27,6 +21,8 @@ import { EuiCallOut, EuiLink } from '@elastic/eui';
2721

2822
import { FormattedMessage } from '@kbn/i18n/react';
2923

24+
import { RegisterManagementAppArgs } from '../../../../../src/plugins/management/public';
25+
3026
import { LicenseStatus } from '../../common/types/license_status';
3127
import { WatchStatus } from './sections/watch_status/components/watch_status';
3228
import { WatchEdit } from './sections/watch_edit/components/watch_edit';
@@ -42,15 +38,14 @@ const ShareRouter = withRouter(({ children, history }: RouteComponentProps & { c
4238
});
4339

4440
export interface AppDeps {
45-
chrome: ChromeStart;
4641
docLinks: DocLinksStart;
4742
toasts: ToastsSetup;
4843
http: HttpSetup;
4944
uiSettings: IUiSettingsClient;
5045
theme: ChartsPluginSetup['theme'];
5146
createTimeBuckets: () => any;
5247
licenseStatus$: Observable<LicenseStatus>;
53-
MANAGEMENT_BREADCRUMB: any;
48+
setBreadcrumbs: Parameters<RegisterManagementAppArgs['mount']>[0]['setBreadcrumbs'];
5449
}
5550

5651
export const App = (deps: AppDeps) => {

x-pack/plugins/watcher/public/application/sections/watch_edit/components/watch_edit.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const WatchEdit = ({
9696
};
9797
}) => {
9898
// hooks
99-
const { MANAGEMENT_BREADCRUMB, chrome } = useAppContext();
99+
const { setBreadcrumbs } = useAppContext();
100100
const [{ watch, loadError }, dispatch] = useReducer(watchReducer, { watch: null });
101101

102102
const setWatchProperty = (property: string, value: any) => {
@@ -128,12 +128,8 @@ export const WatchEdit = ({
128128
}, [id, type]);
129129

130130
useEffect(() => {
131-
chrome.setBreadcrumbs([
132-
MANAGEMENT_BREADCRUMB,
133-
listBreadcrumb,
134-
id ? editBreadcrumb : createBreadcrumb,
135-
]);
136-
}, [id, chrome, MANAGEMENT_BREADCRUMB]);
131+
setBreadcrumbs([listBreadcrumb, id ? editBreadcrumb : createBreadcrumb]);
132+
}, [id, setBreadcrumbs]);
137133

138134
const errorCode = getPageErrorCode(loadError);
139135
if (errorCode) {

x-pack/plugins/watcher/public/application/sections/watch_list/components/watch_list.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ import { useAppContext } from '../../../app_context';
4646
export const WatchList = () => {
4747
// hooks
4848
const {
49-
chrome,
50-
MANAGEMENT_BREADCRUMB,
49+
setBreadcrumbs,
5150
links: { watcherGettingStartedUrl },
5251
} = useAppContext();
5352
const [selection, setSelection] = useState([]);
@@ -57,8 +56,8 @@ export const WatchList = () => {
5756
const [deletedWatches, setDeletedWatches] = useState<string[]>([]);
5857

5958
useEffect(() => {
60-
chrome.setBreadcrumbs([MANAGEMENT_BREADCRUMB, listBreadcrumb]);
61-
}, [chrome, MANAGEMENT_BREADCRUMB]);
59+
setBreadcrumbs([listBreadcrumb]);
60+
}, [setBreadcrumbs]);
6261

6362
const { isLoading: isWatchesLoading, data: watches, error } = useLoadWatches(
6463
REFRESH_INTERVALS.WATCH_LIST

x-pack/plugins/watcher/public/application/sections/watch_status/components/watch_status.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const WatchStatus = ({
6767
};
6868
};
6969
}) => {
70-
const { chrome, MANAGEMENT_BREADCRUMB, toasts } = useAppContext();
70+
const { setBreadcrumbs, toasts } = useAppContext();
7171
const {
7272
error: watchDetailError,
7373
data: watchDetail,
@@ -80,8 +80,8 @@ export const WatchStatus = ({
8080
const [isTogglingActivation, setIsTogglingActivation] = useState<boolean>(false);
8181

8282
useEffect(() => {
83-
chrome.setBreadcrumbs([MANAGEMENT_BREADCRUMB, listBreadcrumb, statusBreadcrumb]);
84-
}, [id, chrome, MANAGEMENT_BREADCRUMB]);
83+
setBreadcrumbs([listBreadcrumb, statusBreadcrumb]);
84+
}, [id, setBreadcrumbs]);
8585

8686
const errorCode = getPageErrorCode(watchDetailError);
8787

x-pack/plugins/watcher/public/legacy/index.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

x-pack/plugins/watcher/public/legacy/index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,4 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import { i18n } from '@kbn/i18n';
7-
86
export { TimeBuckets } from './time_buckets';
9-
10-
export const MANAGEMENT_BREADCRUMB = Object.freeze({
11-
text: i18n.translate('xpack.watcher.management.breadcrumb', {
12-
defaultMessage: 'Management',
13-
}),
14-
href: '#/management',
15-
});

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public';
1212
import { LicenseStatus } from '../common/types/license_status';
1313

1414
import { ILicense, LICENSE_CHECK_STATE } from '../../licensing/public';
15-
import { TimeBuckets, MANAGEMENT_BREADCRUMB } from './legacy';
15+
import { TimeBuckets } from './legacy';
1616
import { PLUGIN } from '../common/constants';
1717
import { Dependencies } from './types';
1818

@@ -37,9 +37,9 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
3737
'xpack.watcher.sections.watchList.managementSection.watcherDisplayName',
3838
{ defaultMessage: 'Watcher' }
3939
),
40-
mount: async ({ element }) => {
40+
mount: async ({ element, setBreadcrumbs }) => {
4141
const [core] = await getStartServices();
42-
const { chrome, i18n: i18nDep, docLinks, savedObjects } = core;
42+
const { i18n: i18nDep, docLinks, savedObjects } = core;
4343
const { boot } = await import('./application/boot');
4444

4545
return boot({
@@ -51,12 +51,11 @@ export class WatcherUIPlugin implements Plugin<void, void, Dependencies, any> {
5151
http,
5252
uiSettings,
5353
docLinks,
54-
chrome,
54+
setBreadcrumbs,
5555
theme: charts.theme,
5656
savedObjects: savedObjects.client,
5757
I18nContext: i18nDep.Context,
5858
createTimeBuckets: () => new TimeBuckets(uiSettings, data),
59-
MANAGEMENT_BREADCRUMB,
6059
});
6160
},
6261
});

0 commit comments

Comments
 (0)