Skip to content

Commit

Permalink
Add search deep links for APM, Metrics, Logs, and Dev Tools (#96135)
Browse files Browse the repository at this point in the history
* Add searchDeepLinks for APM

* Add searchDeepLinks for Metrics and Logs

* Add searchDeepLinks for Dev Tools

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
joshdover and kibanamachine authored Apr 19, 2021
1 parent 71e8118 commit 38ac8e5
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/plugins/dev_tools/public/dev_tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { ReactNode } from 'react';
import { AppMount } from 'src/core/public';

/**
Expand All @@ -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;

/**
Expand Down Expand Up @@ -55,7 +57,7 @@ export class DevToolApp {

constructor(
id: string,
title: string,
title: ReactNode,
mount: AppMount,
enableRouting: boolean,
order: number,
Expand Down
16 changes: 15 additions & 1 deletion src/plugins/dev_tools/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -84,6 +84,20 @@ export class DevToolsPlugin implements Plugin<DevToolsSetup, void> {
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 } };
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
27 changes: 27 additions & 0 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { i18n } from '@kbn/i18n';
import type { ConfigSchema } from '.';
import {
AppMountParameters,
Expand Down Expand Up @@ -143,6 +144,32 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
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<unknown>) {
// Load application bundle and Get start services
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/infra/public/pages/logs/page_content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/infra/public/pages/metrics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const InfrastructurePage = ({ match }: RouteComponentProps) => {
>
<EuiFlexGroup gutterSize={'none'} alignItems={'center'}>
<EuiFlexItem>
{/** !! Need to be kept in sync with the searchDeepLinks in x-pack/plugins/infra/public/plugin.ts */}
<RoutedTabs
tabs={[
{
Expand Down
59 changes: 59 additions & 0 deletions x-pack/plugins/infra/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,39 @@ export class Plugin implements InfraClientPluginClass {
euiIconType: 'logoObservability',
order: 8100,
appRoute: '/app/logs',
meta: {
// !! Need to be kept in sync with the routes in x-pack/plugins/infra/public/pages/logs/page_content.tsx
searchDeepLinks: [
{
id: 'stream',
title: i18n.translate('xpack.infra.logs.index.streamTabTitle', {
defaultMessage: 'Stream',
}),
path: '/stream',
},
{
id: 'anomalies',
title: i18n.translate('xpack.infra.logs.index.anomaliesTabTitle', {
defaultMessage: 'Anomalies',
}),
path: '/anomalies',
},
{
id: 'log-categories',
title: i18n.translate('xpack.infra.logs.index.logCategoriesBetaBadgeTitle', {
defaultMessage: 'Categories',
}),
path: '/log-categories',
},
{
id: 'settings',
title: i18n.translate('xpack.infra.logs.index.settingsTabTitle', {
defaultMessage: 'Settings',
}),
path: '/settings',
},
],
},
category: DEFAULT_APP_CATEGORIES.observability,
mount: async (params: AppMountParameters) => {
// mount callback should not use setup dependencies, get start dependencies instead
Expand All @@ -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();
Expand Down

0 comments on commit 38ac8e5

Please sign in to comment.