88import styled from 'styled-components' ;
99import {
1010 EuiDescriptionList ,
11- EuiHorizontalRule ,
1211 EuiListGroup ,
1312 EuiListGroupItem ,
14- EuiIcon ,
1513 EuiText ,
1614 EuiFlexGroup ,
1715 EuiFlexItem ,
@@ -23,17 +21,14 @@ import { FormattedMessage } from '@kbn/i18n/react';
2321import { i18n } from '@kbn/i18n' ;
2422import { isPolicyOutOfDate } from '../../utils' ;
2523import { HostInfo , HostMetadata , HostStatus } from '../../../../../../common/endpoint/types' ;
26- import { useEndpointSelector , useAgentDetailsIngestUrl } from '../hooks' ;
27- import { useNavigateToAppEventHandler } from '../../../../../common/hooks/endpoint/use_navigate_to_app_event_handler' ;
24+ import { useEndpointSelector } from '../hooks' ;
2825import { policyResponseStatus , uiQueryParams } from '../../store/selectors' ;
2926import { POLICY_STATUS_TO_BADGE_COLOR , HOST_STATUS_TO_BADGE_COLOR } from '../host_constants' ;
3027import { FormattedDateAndTime } from '../../../../../common/components/endpoint/formatted_date_time' ;
3128import { useNavigateByRouterEventHandler } from '../../../../../common/hooks/endpoint/use_navigate_by_router_event_handler' ;
32- import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app' ;
3329import { getEndpointDetailsPath } from '../../../../common/routing' ;
3430import { SecurityPageName } from '../../../../../app/types' ;
3531import { useFormatUrl } from '../../../../../common/components/link_to' ;
36- import { AgentDetailsReassignPolicyAction } from '../../../../../../../fleet/public' ;
3732import { EndpointPolicyLink } from '../components/endpoint_policy_link' ;
3833import { OutOfDate } from '../components/out_of_date' ;
3934
@@ -44,8 +39,6 @@ const HostIds = styled(EuiListGroupItem)`
4439 }
4540` ;
4641
47- const openReassignFlyoutSearch = '?openReassignFlyout=true' ;
48-
4942export const EndpointDetails = memo (
5043 ( {
5144 details,
@@ -56,19 +49,34 @@ export const EndpointDetails = memo(
5649 policyInfo ?: HostInfo [ 'policy_info' ] ;
5750 hostStatus : HostStatus ;
5851 } ) => {
59- const agentId = details . elastic . agent . id ;
60- const {
61- url : agentDetailsUrl ,
62- appId : ingestAppId ,
63- appPath : agentDetailsAppPath ,
64- } = useAgentDetailsIngestUrl ( agentId ) ;
6552 const queryParams = useEndpointSelector ( uiQueryParams ) ;
6653 const policyStatus = useEndpointSelector (
6754 policyResponseStatus
6855 ) as keyof typeof POLICY_STATUS_TO_BADGE_COLOR ;
6956 const { formatUrl } = useFormatUrl ( SecurityPageName . administration ) ;
7057
71- const detailsResultsUpper = useMemo ( ( ) => {
58+ const [ policyResponseUri , policyResponseRoutePath ] = useMemo ( ( ) => {
59+ // eslint-disable-next-line @typescript-eslint/naming-convention
60+ const { selected_endpoint, show, ...currentUrlParams } = queryParams ;
61+ return [
62+ formatUrl (
63+ getEndpointDetailsPath ( {
64+ name : 'endpointPolicyResponse' ,
65+ ...currentUrlParams ,
66+ selected_endpoint : details . agent . id ,
67+ } )
68+ ) ,
69+ getEndpointDetailsPath ( {
70+ name : 'endpointPolicyResponse' ,
71+ ...currentUrlParams ,
72+ selected_endpoint : details . agent . id ,
73+ } ) ,
74+ ] ;
75+ } , [ details . agent . id , formatUrl , queryParams ] ) ;
76+
77+ const policyStatusClickHandler = useNavigateByRouterEventHandler ( policyResponseRoutePath ) ;
78+
79+ const detailsResults = useMemo ( ( ) => {
7280 return [
7381 {
7482 title : i18n . translate ( 'xpack.securitySolution.endpoint.details.os' , {
@@ -106,55 +114,9 @@ export const EndpointDetails = memo(
106114 </ EuiText >
107115 ) ,
108116 } ,
109- ] ;
110- } , [ details , hostStatus ] ) ;
111-
112- const [ policyResponseUri , policyResponseRoutePath ] = useMemo ( ( ) => {
113- // eslint-disable-next-line @typescript-eslint/naming-convention
114- const { selected_endpoint, show, ...currentUrlParams } = queryParams ;
115- return [
116- formatUrl (
117- getEndpointDetailsPath ( {
118- name : 'endpointPolicyResponse' ,
119- ...currentUrlParams ,
120- selected_endpoint : details . agent . id ,
121- } )
122- ) ,
123- getEndpointDetailsPath ( {
124- name : 'endpointPolicyResponse' ,
125- ...currentUrlParams ,
126- selected_endpoint : details . agent . id ,
127- } ) ,
128- ] ;
129- } , [ details . agent . id , formatUrl , queryParams ] ) ;
130-
131- const agentDetailsWithFlyoutPath = `${ agentDetailsAppPath } ${ openReassignFlyoutSearch } ` ;
132- const agentDetailsWithFlyoutUrl = `${ agentDetailsUrl } ${ openReassignFlyoutSearch } ` ;
133- const handleReassignEndpointsClick = useNavigateToAppEventHandler < AgentDetailsReassignPolicyAction > (
134- ingestAppId ,
135- {
136- path : agentDetailsWithFlyoutPath ,
137- state : {
138- onDoneNavigateTo : [
139- 'securitySolution:administration' ,
140- {
141- path : getEndpointDetailsPath ( {
142- name : 'endpointDetails' ,
143- selected_endpoint : details . agent . id ,
144- } ) ,
145- } ,
146- ] ,
147- } ,
148- }
149- ) ;
150-
151- const policyStatusClickHandler = useNavigateByRouterEventHandler ( policyResponseRoutePath ) ;
152-
153- const detailsResultsPolicy = useMemo ( ( ) => {
154- return [
155117 {
156118 title : i18n . translate ( 'xpack.securitySolution.endpoint.details.policy' , {
157- defaultMessage : 'Integration Policy' ,
119+ defaultMessage : 'Policy' ,
158120 } ) ,
159121 description : (
160122 < EuiFlexGroup alignItems = "center" >
@@ -198,7 +160,7 @@ export const EndpointDetails = memo(
198160 } ,
199161 {
200162 title : i18n . translate ( 'xpack.securitySolution.endpoint.details.policyStatus' , {
201- defaultMessage : 'Policy Response ' ,
163+ defaultMessage : 'Policy Status ' ,
202164 } ) ,
203165 description : (
204166 // https://github.com/elastic/eui/issues/4530
@@ -210,7 +172,7 @@ export const EndpointDetails = memo(
210172 onClick = { policyStatusClickHandler }
211173 onClickAriaLabel = { i18n . translate (
212174 'xpack.securitySolution.endpoint.details.policyStatus' ,
213- { defaultMessage : 'Policy Response ' }
175+ { defaultMessage : 'Policy Status ' }
214176 ) }
215177 >
216178 < EuiText size = "m" >
@@ -223,10 +185,12 @@ export const EndpointDetails = memo(
223185 </ EuiBadge >
224186 ) ,
225187 } ,
226- ] ;
227- } , [ details , policyResponseUri , policyStatus , policyStatusClickHandler , policyInfo ] ) ;
228- const detailsResultsLower = useMemo ( ( ) => {
229- return [
188+ {
189+ title : i18n . translate ( 'xpack.securitySolution.endpoint.details.endpointVersion' , {
190+ defaultMessage : 'Endpoint Version' ,
191+ } ) ,
192+ description : < EuiText > { details . agent . version } </ EuiText > ,
193+ } ,
230194 {
231195 title : i18n . translate ( 'xpack.securitySolution.endpoint.details.ipAddress' , {
232196 defaultMessage : 'IP Address' ,
@@ -241,70 +205,23 @@ export const EndpointDetails = memo(
241205 </ EuiListGroup >
242206 ) ,
243207 } ,
244- {
245- title : i18n . translate ( 'xpack.securitySolution.endpoint.details.hostname' , {
246- defaultMessage : 'Hostname' ,
247- } ) ,
248- description : < EuiText className = "eui-textBreakAll" > { details . host . hostname } </ EuiText > ,
249- } ,
250- {
251- title : i18n . translate ( 'xpack.securitySolution.endpoint.details.endpointVersion' , {
252- defaultMessage : 'Endpoint Version' ,
253- } ) ,
254- description : < EuiText > { details . agent . version } </ EuiText > ,
255- } ,
256208 ] ;
257- } , [ details . agent . version , details . host . hostname , details . host . ip ] ) ;
209+ } , [
210+ details ,
211+ hostStatus ,
212+ policyResponseUri ,
213+ policyStatus ,
214+ policyStatusClickHandler ,
215+ policyInfo ,
216+ ] ) ;
258217
259218 return (
260219 < >
261220 < EuiSpacer size = "l" />
262221 < EuiDescriptionList
263222 type = "column"
264- listItems = { detailsResultsUpper }
265- data-test-subj = "endpointDetailsUpperList"
266- />
267- < EuiHorizontalRule margin = "m" />
268- < EuiDescriptionList
269- type = "column"
270- listItems = { detailsResultsPolicy }
271- data-test-subj = "endpointDetailsPolicyList"
272- />
273- < EuiSpacer size = "m" />
274- < LinkToApp
275- appId = { ingestAppId }
276- appPath = { agentDetailsWithFlyoutPath }
277- href = { agentDetailsWithFlyoutUrl }
278- onClick = { handleReassignEndpointsClick }
279- data-test-subj = "endpointDetailsLinkToIngest"
280- >
281- < EuiFlexGroup
282- direction = "row"
283- gutterSize = "xs"
284- justifyContent = "flexStart"
285- alignItems = "center"
286- >
287- < EuiFlexItem grow = { false } >
288- < EuiIcon type = "managementApp" className = "linkToAppIcon" />
289- </ EuiFlexItem >
290- < EuiFlexItem grow = { false } >
291- < EuiText >
292- < FormattedMessage
293- id = "xpack.securitySolution.endpoint.details.linkToIngestTitle"
294- defaultMessage = "Reassign Policy"
295- />
296- </ EuiText >
297- </ EuiFlexItem >
298- < EuiFlexItem grow = { false } >
299- < EuiIcon type = "popout" className = "linkToAppPopoutIcon" />
300- </ EuiFlexItem >
301- </ EuiFlexGroup >
302- </ LinkToApp >
303- < EuiHorizontalRule margin = "m" />
304- < EuiDescriptionList
305- type = "column"
306- listItems = { detailsResultsLower }
307- data-test-subj = "endpointDetailsLowerList"
223+ listItems = { detailsResults }
224+ data-test-subj = "endpointDetailsList"
308225 />
309226 </ >
310227 ) ;
0 commit comments