-
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][Detections] Handle conflicts on alert status update #75492
Changes from 15 commits
6cc4292
8c2586f
017c64a
8fc6a0d
4ec2342
832d7cd
32cae90
4a0f66d
9e2416b
7e7d9c3
a144782
74e2a8e
8cd9c97
46a18e6
f0ee82b
0b39164
0981519
3ad559d
7297fc2
0f094af
ec685be
270fe81
b4eb564
bc3cbb8
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 | ||||
---|---|---|---|---|---|---|
|
@@ -43,7 +43,7 @@ export type ReturnUseAddOrUpdateException = [ | |||||
export interface UseAddOrUpdateExceptionProps { | ||||||
http: HttpStart; | ||||||
onError: (arg: Error, code: number | null, message: string | null) => void; | ||||||
onSuccess: () => void; | ||||||
onSuccess: (updated: number, conficts: number) => void; | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -130,6 +130,8 @@ export const useAddOrUpdateException = ({ | |||||
}); | ||||||
} | ||||||
|
||||||
let conflicts = 0; | ||||||
let updated = 0; | ||||||
if (bulkCloseIndex != null) { | ||||||
const filter = getQueryFilter( | ||||||
'', | ||||||
|
@@ -139,20 +141,23 @@ export const useAddOrUpdateException = ({ | |||||
prepareExceptionItemsForBulkClose(exceptionItemsToAddOrUpdate), | ||||||
false | ||||||
); | ||||||
await updateAlertStatus({ | ||||||
|
||||||
const response = await updateAlertStatus({ | ||||||
query: { | ||||||
query: filter, | ||||||
}, | ||||||
status: 'closed', | ||||||
signal: abortCtrl.signal, | ||||||
}); | ||||||
conflicts = response.version_conflicts; | ||||||
updated = response.updated; | ||||||
} | ||||||
|
||||||
await addOrUpdateItems(exceptionItemsToAddOrUpdate); | ||||||
|
||||||
if (isSubscribed) { | ||||||
setIsLoading(false); | ||||||
onSuccess(); | ||||||
onSuccess(updated, conflicts); | ||||||
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. Super nit: could this also be shortened a bit to just be:
Suggested change
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 tried this, but |
||||||
} | ||||||
} catch (error) { | ||||||
if (isSubscribed) { | ||||||
|
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.
Not in any way blocking this PR, but just thinking, I think this component would benefit from using
useReducer
. The number ofuseState
s are growing and (just personally) working on adding error states in here recently, felt like it was getting crowded.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.
Makes sense to me! I don't think I will address it here, but if I get time, will take a stab at that soon.