-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Endpoint] add resolver middleware #58288
Changes from 8 commits
7a41134
e67ac7a
57133a6
d17e339
2c0df81
8ae65ae
c809dcd
0626d65
d291a46
bcda2d5
a609c11
c6a513e
2600144
24fb4fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,13 @@ import { | |
createSelector, | ||
createStructuredSelector as createStructuredSelectorWithBadType, | ||
} from 'reselect'; | ||
import { Immutable } from '../../../../../common/types'; | ||
import { | ||
AlertListState, | ||
AlertingIndexUIQueryParams, | ||
AlertsAPIQueryParams, | ||
CreateStructuredSelector, | ||
} from '../../types'; | ||
import { Immutable, LegacyEndpointEvent } from '../../../../../common/types'; | ||
|
||
const createStructuredSelector: CreateStructuredSelector = createStructuredSelectorWithBadType; | ||
/** | ||
|
@@ -92,3 +92,15 @@ export const hasSelectedAlert: (state: AlertListState) => boolean = createSelect | |
uiQueryParams, | ||
({ selected_alert: selectedAlert }) => selectedAlert !== undefined | ||
); | ||
|
||
export const selectedEvent: ( | ||
state: AlertListState | ||
) => LegacyEndpointEvent | undefined = createSelector( | ||
uiQueryParams, | ||
alertListData, | ||
({ selected_alert: selectedAlert }, alertList) => { | ||
return (alertList.find( | ||
alert => alert.event.id === selectedAlert | ||
) as unknown) as LegacyEndpointEvent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO stop it |
||
} | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import { urlFromQueryParams } from './url_from_query_params'; | |
import { AlertData } from '../../../../../common/types'; | ||
import * as selectors from '../../store/alerts/selectors'; | ||
import { useAlertListSelector } from './hooks/use_alerts_selector'; | ||
import { AlertDetailResolver } from './resolver'; | ||
|
||
export const AlertIndex = memo(() => { | ||
const history = useHistory(); | ||
|
@@ -86,6 +87,7 @@ 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 => { | ||
|
@@ -132,12 +134,11 @@ export const AlertIndex = memo(() => { | |
} | ||
|
||
const row = alertListData[rowIndex % pageSize]; | ||
|
||
if (columnId === 'alert_type') { | ||
return ( | ||
<Link | ||
data-testid="alertTypeCellLink" | ||
to={urlFromQueryParams({ ...queryParams, selected_alert: 'TODO' })} | ||
to={urlFromQueryParams({ ...queryParams, selected_alert: row.event.id })} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ row could resolve to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kqualters-elastic We use |
||
> | ||
{i18n.translate( | ||
'xpack.endpoint.application.endpoint.alerts.alertType.maliciousFileDescription', | ||
|
@@ -213,7 +214,9 @@ export const AlertIndex = memo(() => { | |
</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody /> | ||
<EuiFlyoutBody> | ||
<AlertDetailResolver selectedEvent={selectedEvent} /> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
)} | ||
<EuiPage data-test-subj="alertListPage" data-testid="alertListPage"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { Provider } from 'react-redux'; | ||
import { useKibana } from '../../../../../../../../src/plugins/kibana_react/public'; | ||
import { Resolver } from '../../../../embeddables/resolver/view'; | ||
import { EndpointPluginServices } from '../../../../plugin'; | ||
import { LegacyEndpointEvent } from '../../../../../common/types'; | ||
import { storeFactory } from '../../../../embeddables/resolver/store'; | ||
|
||
export const AlertDetailResolver = styled( | ||
React.memo( | ||
({ className, selectedEvent }: { className?: string; selectedEvent?: LegacyEndpointEvent }) => { | ||
const context = useKibana<EndpointPluginServices>(); | ||
const { store } = storeFactory(context); | ||
return ( | ||
<div className={className} data-test-subj="alertResolver" data-testid="alertResolver"> | ||
<Provider store={store}> | ||
<Resolver selectedEvent={selectedEvent} /> | ||
</Provider> | ||
</div> | ||
); | ||
} | ||
) | ||
)` | ||
height: 100%; | ||
width: 100%; | ||
display: flex; | ||
flex-grow: 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ just |
||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ export class ResolverEmbeddableFactory extends EmbeddableFactory { | |
return true; | ||
} | ||
|
||
public async create(initialInput: EmbeddableInput, parent?: IContainer) { | ||
public async create(initialInput: EmbeddableInput, parent: IContainer) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? |
||
return new ResolverEmbeddable(initialInput, {}, parent); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kqualters-elastic - maybe not for this PR, but we should consider using the kibana-react components for sharing
coreStart
in the app. I think the use of hooks rather than to forcecoreStart
down to each route's View would be better DX. If we did not want to use the kibana-react components, we could just create our own reactContext
and set of hooks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, updated to do just that.