Skip to content

Commit 075b8c9

Browse files
committed
Merge branch 'task/endpointlist-actions' of github.com:parkiino/kibana into task/endpointlist-actions
2 parents 72925ef + 85127ae commit 075b8c9

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

x-pack/plugins/security_solution/public/common/hooks/endpoint/use_navigate_to_app_event_handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type NavigateToAppHandlerOptions<S = unknown> = NavigateToAppOptions & {
1212
state?: S;
1313
onClick?: EventHandlerCallback;
1414
};
15-
type EventHandlerCallback = MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
15+
type EventHandlerCallback = MouseEventHandler<HTMLButtonElement | HTMLAnchorElement | Element>;
1616

1717
/**
1818
* Provides an event handlers that can be used with (for example) `onClick` to prevent the

x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { i18n } from '@kbn/i18n';
2727
import { FormattedMessage } from '@kbn/i18n/react';
2828
import { createStructuredSelector } from 'reselect';
2929
import { useDispatch } from 'react-redux';
30+
import { EuiContextMenuItemProps } from '@elastic/eui/src/components/context_menu/context_menu_item';
31+
import { NavigateToAppOptions } from 'kibana/public';
3032
import { EndpointDetailsFlyout } from './details';
3133
import * as selectors from '../store/selectors';
3234
import { useEndpointSelector } from './hooks';
@@ -397,21 +399,21 @@ export const EndpointList = () => {
397399
return (
398400
<TableRowActions
399401
items={[
400-
<EuiContextMenuItem icon="logoSecurity" key="hostDetailsLink">
401-
<LinkToApp
402-
data-test-subj="hostLink"
403-
appId="securitySolution"
404-
appPath={`hosts/${item.metadata.host.hostname}`}
405-
href={`${services?.application?.getUrlForApp('securitySolution')}/hosts/${
406-
item.metadata.host.hostname
407-
}`}
408-
>
409-
<FormattedMessage
410-
id="xpack.securitySolution.endpoint.list.actions.hostDetails"
411-
defaultMessage="View Host Details"
412-
/>
413-
</LinkToApp>
414-
</EuiContextMenuItem>,
402+
<EuiContextMenuItemNavByRouter
403+
data-test-subj="hostLink"
404+
icon="logoSecurity"
405+
key="hostDetailsLink"
406+
navigateAppId="securitySolution"
407+
navigateOptions={{ path: `hosts/${item.metadata.host.hostname}` }}
408+
href={`${services?.application?.getUrlForApp('securitySolution')}/hosts/${
409+
item.metadata.host.hostname
410+
}`}
411+
>
412+
<FormattedMessage
413+
id="xpack.securitySolution.endpoint.list.actions.hostDetails"
414+
defaultMessage="View Host Details"
415+
/>
416+
</EuiContextMenuItemNavByRouter>,
415417
<EuiContextMenuItem icon="logoObservability" key="agentConfigLink">
416418
<LinkToApp
417419
data-test-subj="agentPolicyLink"
@@ -563,3 +565,20 @@ export const EndpointList = () => {
563565
</AdministrationListPage>
564566
);
565567
};
568+
569+
const EuiContextMenuItemNavByRouter = memo<
570+
Omit<EuiContextMenuItemProps, 'onClick'> & {
571+
navigateAppId: string;
572+
navigateOptions: NavigateToAppOptions;
573+
children: React.ReactNode;
574+
}
575+
>(({ navigateAppId, navigateOptions, children, ...otherMenuItemProps }) => {
576+
const handleOnClick = useNavigateToAppEventHandler(navigateAppId, navigateOptions);
577+
578+
return (
579+
<EuiContextMenuItem {...otherMenuItemProps} onClick={handleOnClick}>
580+
{children}
581+
</EuiContextMenuItem>
582+
);
583+
});
584+
EuiContextMenuItemNavByRouter.displayName = 'EuiContextMenuItemNavByRouter';

0 commit comments

Comments
 (0)