Skip to content

Commit

Permalink
[APM] use navigateToApp for infra/metrics/uptime links
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed May 7, 2020
1 parent d935600 commit 49fcddb
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -82,7 +83,36 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
basePath: core.http.basePath,
location,
urlParams
});
}).map(sectionList =>
sectionList.map(section => ({
...section,
actions: section.actions.map(action => {
const { href } = action;

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);
Expand Down Expand Up @@ -151,6 +181,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = ({
key={action.key}
label={action.label}
href={action.href}
onClick={action.onClick}
/>
))}
</SectionLinks>
Expand Down

0 comments on commit 49fcddb

Please sign in to comment.