|
6 | 6 |
|
7 | 7 | import { EuiButtonEmpty } from '@elastic/eui'; |
8 | 8 | import { i18n } from '@kbn/i18n'; |
9 | | -import React, { FunctionComponent, useMemo, useState } from 'react'; |
| 9 | +import React, { FunctionComponent, useMemo, useState, MouseEvent } from 'react'; |
| 10 | +import url from 'url'; |
10 | 11 | import { Filter } from '../../../../common/custom_link/custom_link_types'; |
11 | 12 | import { Transaction } from '../../../../typings/es_schemas/ui/transaction'; |
12 | 13 | import { |
@@ -82,7 +83,39 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({ |
82 | 83 | basePath: core.http.basePath, |
83 | 84 | location, |
84 | 85 | urlParams |
85 | | - }); |
| 86 | + }).map(sectionList => |
| 87 | + sectionList.map(section => ({ |
| 88 | + ...section, |
| 89 | + actions: section.actions.map(action => { |
| 90 | + const { href } = action; |
| 91 | + |
| 92 | + // use navigateToApp as a temporary workaround for faster navigation between observability apps. |
| 93 | + // see https://github.com/elastic/kibana/issues/65682 |
| 94 | + |
| 95 | + return { |
| 96 | + ...action, |
| 97 | + onClick: (event: MouseEvent) => { |
| 98 | + const parsed = url.parse(href); |
| 99 | + |
| 100 | + const appPathname = core.http.basePath.remove( |
| 101 | + parsed.pathname ?? '' |
| 102 | + ); |
| 103 | + |
| 104 | + const [, , app, ...rest] = appPathname.split('/'); |
| 105 | + |
| 106 | + if (app === 'uptime' || app === 'metrics' || app === 'logs') { |
| 107 | + event.preventDefault(); |
| 108 | + core.application.navigateToApp(app, { |
| 109 | + path: `${rest.join('/')}${ |
| 110 | + parsed.search ? `&${parsed.search}` : '' |
| 111 | + }` |
| 112 | + }); |
| 113 | + } |
| 114 | + } |
| 115 | + }; |
| 116 | + }) |
| 117 | + })) |
| 118 | + ); |
86 | 119 |
|
87 | 120 | const closePopover = () => { |
88 | 121 | setIsActionPopoverOpen(false); |
@@ -151,6 +184,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({ |
151 | 184 | key={action.key} |
152 | 185 | label={action.label} |
153 | 186 | href={action.href} |
| 187 | + onClick={action.onClick} |
154 | 188 | /> |
155 | 189 | ))} |
156 | 190 | </SectionLinks> |
|
0 commit comments