From 55001674b41f90b6ae8d407a0f5958a6c3db62be Mon Sep 17 00:00:00 2001 From: Davis Plumlee Date: Mon, 2 Mar 2020 13:06:49 -0500 Subject: [PATCH] integrates with resolver pr --- .../endpoint/store/alerts/selectors.ts | 13 +++++--- .../view/alerts/details/overview/index.tsx | 13 ++++++-- .../endpoint/view/alerts/index.tsx | 1 - .../endpoint/view/alerts/resolver.tsx | 33 +++++++++---------- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts index d81bf3e34c85b..7ce7c2d08691e 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts +++ b/x-pack/plugins/endpoint/public/applications/endpoint/store/alerts/selectors.ts @@ -15,7 +15,7 @@ import { AlertsAPIQueryParams, CreateStructuredSelector, } from '../../types'; -import { Immutable, LegacyEndpointEvent } from '../../../../../common/types'; +import { Immutable } from '../../../../../common/types'; const createStructuredSelector: CreateStructuredSelector = createStructuredSelectorWithBadType; /** @@ -98,6 +98,11 @@ export const hasSelectedAlert: (state: AlertListState) => boolean = createSelect /** * Determine if the alert event is most likely compatible with LegacyEndpointEvent. */ -function isAlertEventLegacyEndpointEvent(event: { endgame?: {} }): event is LegacyEndpointEvent { - return event.endgame !== undefined && 'unique_pid' in event.endgame; -} +export const selectedAlertIsLegacyEndpointEvent: ( + state: AlertListState +) => boolean = createSelector(selectedAlertDetailsData, function(event) { + if (event === undefined) { + return false; + } + return 'endgame' in event; +}); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/details/overview/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/details/overview/index.tsx index 043933a91e9ce..080c70ca43bae 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/details/overview/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/details/overview/index.tsx @@ -11,12 +11,16 @@ import { useAlertListSelector } from '../../hooks/use_alerts_selector'; import * as selectors from '../../../../store/alerts/selectors'; import { MetadataPanel } from './metadata_panel'; import { FormattedDate } from '../../formatted_date'; +import { AlertDetailResolver } from '../../resolver'; export const AlertDetailsOverview = memo(() => { const alertDetailsData = useAlertListSelector(selectors.selectedAlertDetailsData); if (alertDetailsData === undefined) { return null; } + const selectedAlertIsLegacyEndpointEvent = useAlertListSelector( + selectors.selectedAlertIsLegacyEndpointEvent + ); const tabs = useMemo(() => { return [ @@ -43,10 +47,15 @@ export const AlertDetailsOverview = memo(() => { defaultMessage: 'Resolver', } ), - content: 'Resolver', + content: ( + <> + + {selectedAlertIsLegacyEndpointEvent && } + + ), }, ]; - }, []); + }, [selectedAlertIsLegacyEndpointEvent]); return ( <> diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx index 4bddc08778711..5d405f8c6fbae 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/index.tsx @@ -93,7 +93,6 @@ export const AlertIndex = memo(() => { const alertListData = useAlertListSelector(selectors.alertListData); const hasSelectedAlert = useAlertListSelector(selectors.hasSelectedAlert); const queryParams = useAlertListSelector(selectors.uiQueryParams); - const selectedEvent = useAlertListSelector(selectors.selectedEvent); const onChangeItemsPerPage = useCallback( newPageSize => { diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/resolver.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/resolver.tsx index fb2b08d343daf..45448b8b000de 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/resolver.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/alerts/resolver.tsx @@ -16,25 +16,22 @@ import { useAlertListSelector } from './hooks/use_alerts_selector'; import * as selectors from '../../store/alerts/selectors'; export const AlertDetailResolver = styled( - React.memo( - ({ className, selectedEvent }: { className?: string; selectedEvent?: LegacyEndpointEvent }) => { - const context = useKibana(); - const { store } = storeFactory(context); - // Different shit - const alertDetailsData = useAlertListSelector(selectors.selectedAlertDetailsData); - if (alertDetailsData === undefined) { - return null; - } - - return ( -
- - - -
- ); + React.memo(({ className }: { className?: string }) => { + const alertDetailsData = useAlertListSelector(selectors.selectedAlertDetailsData); + if (alertDetailsData === undefined) { + return null; } - ) + const context = useKibana(); + const { store } = storeFactory(context); + + return ( +
+ + + +
+ ); + }) )` height: 100%; width: 100%;