From c4ac3af19fc9f3f216ebf969961e69ee86c0ef7a Mon Sep 17 00:00:00 2001 From: Josh Dover <1813008+joshdover@users.noreply.github.com> Date: Mon, 19 Apr 2021 20:52:29 +0200 Subject: [PATCH] Add search deep links for APM, Metrics, Logs, and Dev Tools (#96135) * Add searchDeepLinks for APM * Add searchDeepLinks for Metrics and Logs * Add searchDeepLinks for Dev Tools Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- src/plugins/dev_tools/public/dev_tool.ts | 6 +- src/plugins/dev_tools/public/plugin.ts | 16 ++++- .../app/Main/route_config/index.tsx | 3 + x-pack/plugins/apm/public/plugin.ts | 27 +++++++++ .../infra/public/pages/logs/page_content.tsx | 1 + .../infra/public/pages/metrics/index.tsx | 1 + x-pack/plugins/infra/public/plugin.ts | 59 +++++++++++++++++++ 7 files changed, 110 insertions(+), 3 deletions(-) diff --git a/src/plugins/dev_tools/public/dev_tool.ts b/src/plugins/dev_tools/public/dev_tool.ts index 197e93f20a539f..8adfd4c76482d8 100644 --- a/src/plugins/dev_tools/public/dev_tool.ts +++ b/src/plugins/dev_tools/public/dev_tool.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import { ReactNode } from 'react'; import { AppMount } from 'src/core/public'; /** @@ -26,8 +27,9 @@ export class DevToolApp { /** * The human readable name of the dev tool. Should be internationalized. * This will be used as a label in the tab above the actual tool. + * May also be a ReactNode. */ - public readonly title: string; + public readonly title: ReactNode; public readonly mount: AppMount; /** @@ -55,7 +57,7 @@ export class DevToolApp { constructor( id: string, - title: string, + title: ReactNode, mount: AppMount, enableRouting: boolean, order: number, diff --git a/src/plugins/dev_tools/public/plugin.ts b/src/plugins/dev_tools/public/plugin.ts index 6cf3c57d19ac87..e9f5d206de9180 100644 --- a/src/plugins/dev_tools/public/plugin.ts +++ b/src/plugins/dev_tools/public/plugin.ts @@ -7,7 +7,7 @@ */ import { BehaviorSubject } from 'rxjs'; -import { Plugin, CoreSetup, AppMountParameters } from 'src/core/public'; +import { Plugin, CoreSetup, AppMountParameters, AppSearchDeepLink } from 'src/core/public'; import { AppUpdater } from 'kibana/public'; import { i18n } from '@kbn/i18n'; import { sortBy } from 'lodash'; @@ -84,6 +84,20 @@ export class DevToolsPlugin implements Plugin { public start() { if (this.getSortedDevTools().length === 0) { this.appStateUpdater.next(() => ({ navLinkStatus: AppNavLinkStatus.hidden })); + } else { + this.appStateUpdater.next(() => { + const deepLinks: AppSearchDeepLink[] = [...this.devTools.values()] + .filter( + // Some tools do not use a string title, so we filter those out + (tool) => !tool.enableRouting && !tool.isDisabled() && typeof tool.title === 'string' + ) + .map((tool) => ({ + id: tool.id, + title: tool.title as string, + path: `#/${tool.id}`, + })); + return { meta: { searchDeepLinks: deepLinks } }; + }); } } diff --git a/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx index 0ed9c5c919ddb1..9410fd00411e38 100644 --- a/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx +++ b/x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx @@ -173,6 +173,7 @@ export const routes: APMRouteDefinition[] = [ render: renderAsRedirectTo('/services'), breadcrumb: 'APM', }, + // !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/apm/public/plugin.ts { exact: true, path: '/services', @@ -181,6 +182,7 @@ export const routes: APMRouteDefinition[] = [ defaultMessage: 'Services', }), }, + // !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/apm/public/plugin.ts { exact: true, path: '/traces', @@ -326,6 +328,7 @@ export const routes: APMRouteDefinition[] = [ component: TraceLink, breadcrumb: null, }, + // !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/apm/public/plugin.ts { exact: true, path: '/service-map', diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 143076e56c831f..6ba9689535084e 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { i18n } from '@kbn/i18n'; import type { ConfigSchema } from '.'; import { AppMountParameters, @@ -143,6 +144,32 @@ export class ApmPlugin implements Plugin { appRoute: '/app/apm', icon: 'plugins/apm/public/icon.svg', category: DEFAULT_APP_CATEGORIES.observability, + meta: { + // !! Need to be kept in sync with the routes in x-pack/plugins/apm/public/components/app/Main/route_config/index.tsx + searchDeepLinks: [ + { + id: 'services', + title: i18n.translate('xpack.apm.breadcrumb.servicesTitle', { + defaultMessage: 'Services', + }), + path: '/services', + }, + { + id: 'traces', + title: i18n.translate('xpack.apm.breadcrumb.tracesTitle', { + defaultMessage: 'Traces', + }), + path: '/traces', + }, + { + id: 'service-map', + title: i18n.translate('xpack.apm.breadcrumb.serviceMapTitle', { + defaultMessage: 'Service Map', + }), + path: '/service-map', + }, + ], + }, async mount(params: AppMountParameters) { // Load application bundle and Get start services diff --git a/x-pack/plugins/infra/public/pages/logs/page_content.tsx b/x-pack/plugins/infra/public/pages/logs/page_content.tsx index 648915ad4075ca..d43fe198c50770 100644 --- a/x-pack/plugins/infra/public/pages/logs/page_content.tsx +++ b/x-pack/plugins/infra/public/pages/logs/page_content.tsx @@ -40,6 +40,7 @@ export const LogsPageContent: React.FunctionComponent = () => { initialize(); }); + // !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/infra/public/plugin.ts const streamTab = { app: 'logs', title: streamTabTitle, diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index 51cc4ca0984837..b43d7640f63907 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -120,6 +120,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => { > + {/** !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/infra/public/plugin.ts */} { // mount callback should not use setup dependencies, get start dependencies instead @@ -82,6 +115,32 @@ export class Plugin implements InfraClientPluginClass { order: 8200, appRoute: '/app/metrics', category: DEFAULT_APP_CATEGORIES.observability, + meta: { + // !! Need to be kept in sync with the routes in x-pack/plugins/infra/public/pages/metrics/index.tsx + searchDeepLinks: [ + { + id: 'inventory', + title: i18n.translate('xpack.infra.homePage.inventoryTabTitle', { + defaultMessage: 'Inventory', + }), + path: '/inventory', + }, + { + id: 'metrics-explorer', + title: i18n.translate('xpack.infra.homePage.metricsExplorerTabTitle', { + defaultMessage: 'Metrics Explorer', + }), + path: '/explorer', + }, + { + id: 'settings', + title: i18n.translate('xpack.infra.homePage.settingsTabTitle', { + defaultMessage: 'Settings', + }), + path: '/settings', + }, + ], + }, mount: async (params: AppMountParameters) => { // mount callback should not use setup dependencies, get start dependencies instead const [coreStart, pluginsStart] = await core.getStartServices();