Skip to content

Commit edbbf9a

Browse files
authored
[7.8] [APM] use navigateToApp for infra/metrics/uptime links (#65832)
1 parent f59df00 commit edbbf9a

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

x-pack/plugins/apm/public/components/shared/TransactionActionMenu/TransactionActionMenu.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
import { EuiButtonEmpty } from '@elastic/eui';
88
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';
1011
import { Filter } from '../../../../common/custom_link/custom_link_types';
1112
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
1213
import {
@@ -82,7 +83,39 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
8283
basePath: core.http.basePath,
8384
location,
8485
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+
);
86119

87120
const closePopover = () => {
88121
setIsActionPopoverOpen(false);
@@ -151,6 +184,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
151184
key={action.key}
152185
label={action.label}
153186
href={action.href}
187+
onClick={action.onClick}
154188
/>
155189
))}
156190
</SectionLinks>

0 commit comments

Comments
 (0)