-
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
[Security Solution] [Endpoint] Creates generic policy tab artifact component to be used for all of our artifacts #126685
Changes from 24 commits
5f8acfd
d8ef30d
fc1c6f2
399e009
474b3e8
f565083
bfb832c
1e228a6
39ee3b8
fced0a2
9f1fe11
a130ea1
b575edd
5320a7a
c69b0e3
4211893
c4b01a7
0fc7869
8ff085a
1a5bb51
d99ba65
92ee2c3
cbc8ef9
ed6c258
63f8f9a
c5e2545
999a339
f1bd38f
ef61835
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 |
---|---|---|
|
@@ -11,30 +11,39 @@ import { MANAGEMENT_DEFAULT_PAGE, MANAGEMENT_DEFAULT_PAGE_SIZE } from '../../com | |
import { parsePoliciesAndFilterToKql, parseQueryFilterToKQL } from '../../common/utils'; | ||
import { ExceptionsListApiClient } from '../../services/exceptions_list/exceptions_list_api_client'; | ||
|
||
const DEFAULT_OPTIONS = Object.freeze({}); | ||
|
||
export function useListArtifact( | ||
exceptionListApiClient: ExceptionsListApiClient, | ||
searcheableFields: string[], | ||
options: { | ||
filter: string; | ||
page: number; | ||
perPage: number; | ||
policies: string[]; | ||
filter?: string; | ||
page?: number; | ||
perPage?: number; | ||
policies?: string[]; | ||
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. I'm wondering if we should also support a 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. At this hook level I think is better to have an array and not a string. This can avoid us having wrong strings wit wrong structures coming from url. Agree this can change once we have a policy hook for parsing |
||
excludedPolicies?: string[]; | ||
} = { | ||
filter: '', | ||
page: MANAGEMENT_DEFAULT_PAGE, | ||
page: MANAGEMENT_DEFAULT_PAGE + 1, | ||
perPage: MANAGEMENT_DEFAULT_PAGE_SIZE, | ||
policies: [], | ||
excludedPolicies: [], | ||
}, | ||
customQueryOptions: UseQueryOptions<FoundExceptionListItemSchema, HttpFetchError> | ||
customQueryOptions: UseQueryOptions< | ||
FoundExceptionListItemSchema, | ||
HttpFetchError | ||
> = DEFAULT_OPTIONS, | ||
customQueryIds: string[] = [] | ||
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. You are introducing this just so that you can invalidate queries? 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. Exactly! |
||
): QueryObserverResult<FoundExceptionListItemSchema, HttpFetchError> { | ||
const { filter, page, perPage, policies } = options; | ||
const { filter, page, perPage, policies, excludedPolicies } = options; | ||
|
||
return useQuery<FoundExceptionListItemSchema, HttpFetchError>( | ||
['list', exceptionListApiClient, options], | ||
[...customQueryIds, 'list', exceptionListApiClient, options], | ||
() => { | ||
return exceptionListApiClient.find({ | ||
filter: parsePoliciesAndFilterToKql({ | ||
policies, | ||
excludedPolicies, | ||
kuery: parseQueryFilterToKQL(filter, searcheableFields), | ||
}), | ||
perPage, | ||
|
This file was deleted.
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.
Sooooo... I changed this hook in my PR as well and:
searchableFields
optional -defaults to theDEFAULT_EXCEPTION_LIST_ITEM_SEARCHABLE_FIELDS
options
be aPartial<>
instead of forcing the user to define every attribute. Looks like this in mine:I made these changes in order to keep the hook's primary responsibility (to get a list of data out) simple and down to a minimal set of input args needed to use it.
Ref: https://github.com/elastic/kibana/pull/126400/files#diff-01c4c157be58054f3b6dc1977f5bba98738cc8461f4f6d15b97710b3f4b12759R17
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.
done: 63f8f9a