-
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] Ability to assign existing event filter to the policy flyout #121964
[Security Solution] [Endpoint] Ability to assign existing event filter to the policy flyout #121964
Conversation
…empty state message
…lter_to_the_policy_flyout-2029
'updated_at', | ||
'updated_by', | ||
].forEach((field) => { | ||
delete updatedCommentsEntry[field as keyof UpdateExceptionListItemSchema]; |
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.
Moved from the middleware to the service as the service is used in other places (with react-query)
return ( | ||
<> | ||
{isListLoading && ( | ||
<EuiProgress size="xs" color="primary" data-test-subj="artifactsAssignableListLoader" /> |
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.
Added a progress bar like we have in the other search list areas
); | ||
} | ||
|
||
export function useBulkUpdateEventFilters( |
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.
Generic bulk update action. Using this, we will be able to use the bulk API once is done without changing the components logic, only this hook
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.
nice!
Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt) |
@elasticmachine merge upstream |
…lter_to_the_policy_flyout-2029
'updated_at', | ||
'updated_by', | ||
].forEach((field) => { | ||
delete exception[field as keyof UpdateExceptionListItemSchema]; |
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.
Can we change the implementation so that we don't mutate the object that was passed on input to this method. I think that maybe this might work:
async updateOne(
{
created_at,
created_by,
created_at,
creatd_by,
list_id,
tie_breaker_id,
updated_at,
updated_by,
...exception
}: Immutable<UpdateExceptionListItemSchema>
): Promise<ExceptionListItemSchema> {
const [currentFilter, setCurrentFilter] = useState<string>(''); | ||
|
||
const bulkUpdateMutation = useBulkUpdateEventFilters({ | ||
onUpdateSuccess: (updatedExceptions: ExceptionListItemSchema[]) => { |
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.
I have not worked with react query, so I'm not sure about this - but should these all be memoized? are they triggering unnecessary react render cycles by having new instances created everytime?
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.
No, internally react-query is already taking care of this.
…lter_to_the_policy_flyout-2029
…_policy_flyout-2029' of github.com:dasansol92/kibana into feat/olm-ability_to_assign_existing_event_filter_to_the_policy_flyout-2029
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
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.
left some comments and am good if you need to merge this in order to make progress and address them in a subsequent PR.
...exception, | ||
tags: [...testTags, `policy:${policy.id}`], | ||
}; | ||
// Clean unnecessary fields for update action |
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.
is this the same code as the service file? if so, maybe create a utility that does this (TA has a similar one I think) and reuse it.
UpdateExceptionListItemSchema, | ||
} from '@kbn/securitysolution-io-ts-list-types'; | ||
|
||
const endpointGenerator = new EndpointDocGenerator('seed'); |
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.
Just FYI: This is fine being defined as a singleton, but note that if a new test case is inserted between others, you could get test failures because the data generated will then differ for the tests cases that are present after the one inserted.
My suggestion would be to initialize it for every test via beforeEach()
sort_order: undefined, | ||
}, | ||
}); | ||
const emptyList = { |
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.
can we avoid using mutable constants in the tests - can you convert this to a function that returns the object?
renderResult = mockedContext.render( | ||
<PolicyEventFiltersFlyout policyItem={policy} onClose={onCloseMock} /> | ||
); | ||
await waitFor(mockedApi.responseProvider.eventFiltersList); |
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.
I'm not sure this is doing what you expect it to be done. What is the intent - to wait for the data to be returned? If so, then you need to check for when it is actually called. maybe something like this:
await waitFor(
() => expect(mockedApi.responseProvider.eventFiltersList).toHaveBeenCalled()
);
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.
yeah. exactly. It was what I was looking for, thanks!
@paul-tavares Thanks for the suggestions, I will address it in a subsequent PR since I need some of the code here to move on with other issues |
Summary
For maintainers