Skip to content

Commit

Permalink
integrates with resolver pr
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee committed Mar 2, 2020
1 parent ce5d25b commit 5500167
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
AlertsAPIQueryParams,
CreateStructuredSelector,
} from '../../types';
import { Immutable, LegacyEndpointEvent } from '../../../../../common/types';
import { Immutable } from '../../../../../common/types';

const createStructuredSelector: CreateStructuredSelector = createStructuredSelectorWithBadType;
/**
Expand Down Expand Up @@ -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;
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -43,10 +47,15 @@ export const AlertDetailsOverview = memo(() => {
defaultMessage: 'Resolver',
}
),
content: 'Resolver',
content: (
<>
<EuiSpacer />
{selectedAlertIsLegacyEndpointEvent && <AlertDetailResolver />}
</>
),
},
];
}, []);
}, [selectedAlertIsLegacyEndpointEvent]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EndpointPluginServices>();
const { store } = storeFactory(context);
// Different shit
const alertDetailsData = useAlertListSelector(selectors.selectedAlertDetailsData);
if (alertDetailsData === undefined) {
return null;
}

return (
<div className={className} data-test-subj="alertResolver" data-testid="alertResolver">
<Provider store={store}>
<Resolver selectedEvent={selectedEvent} />
</Provider>
</div>
);
React.memo(({ className }: { className?: string }) => {
const alertDetailsData = useAlertListSelector(selectors.selectedAlertDetailsData);
if (alertDetailsData === undefined) {
return null;
}
)
const context = useKibana<EndpointPluginServices>();
const { store } = storeFactory(context);

return (
<div className={className} data-test-subj="alertResolver" data-testid="alertResolver">
<Provider store={store}>
<Resolver selectedEvent={(alertDetailsData as unknown) as LegacyEndpointEvent} />
</Provider>
</div>
);
})
)`
height: 100%;
width: 100%;
Expand Down

0 comments on commit 5500167

Please sign in to comment.