From 21f884d5442a5234fe7a2310adb03d8bebd76d2b Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Thu, 7 May 2020 15:33:54 +0200 Subject: [PATCH] [APM] use navigateToApp for infra/metrics/uptime links Closes #64804. --- .../TransactionActionMenu.tsx | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx index 4092e0148286e..cc73f6bbc1ce9 100644 --- a/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx +++ b/x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx @@ -6,7 +6,8 @@ import { EuiButtonEmpty } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React, { FunctionComponent, useMemo, useState } from 'react'; +import React, { FunctionComponent, useMemo, useState, MouseEvent } from 'react'; +import url from 'url'; import { Filter } from '../../../../common/custom_link/custom_link_types'; import { Transaction } from '../../../../typings/es_schemas/ui/transaction'; import { @@ -82,7 +83,39 @@ export const TransactionActionMenu: FunctionComponent = ({ basePath: core.http.basePath, location, urlParams - }); + }).map(sectionList => + sectionList.map(section => ({ + ...section, + actions: section.actions.map(action => { + const { href } = action; + + // use navigateToApp as a temporary workaround for faster navigation between observability apps. + // see https://github.com/elastic/kibana/issues/65682 + + return { + ...action, + onClick: (event: MouseEvent) => { + const parsed = url.parse(href); + + const appPathname = core.http.basePath.remove( + parsed.pathname ?? '' + ); + + const [, , app, ...rest] = appPathname.split('/'); + + if (app === 'uptime' || app === 'infra' || app === 'logs') { + event.preventDefault(); + core.application.navigateToApp(app, { + path: `${rest.join('/')}${ + parsed.search ? `&${parsed.search}` : '' + }` + }); + } + } + }; + }) + })) + ); const closePopover = () => { setIsActionPopoverOpen(false); @@ -151,6 +184,7 @@ export const TransactionActionMenu: FunctionComponent = ({ key={action.key} label={action.label} href={action.href} + onClick={action.onClick} /> ))}