-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[SIEM][Exceptions] - ExceptionsViewer UI component part 2 #68294
Merged
Merged
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
24ed91f
moved and_or_badge to common folder and added tests
yctercero 629b832
updated references to new and_or_badge location
yctercero 335a720
built out exception item component for viewer
yctercero dd2b8c8
added exception item component stories for easy testing
yctercero 990d656
updated text to use i18n in spots missed
yctercero bac11c9
added tests for exception detail component and updated braking tests
yctercero 9496085
finished adding tests and fixing lint issue
yctercero f3a1fba
fixed test timestamps to be UTC
yctercero a8a68fa
fix failing test that was passing locally
yctercero f0aeda8
tests
yctercero b19237f
fix dates
yctercero 3a31452
fixes per feedback
yctercero 7ad2a23
Merge branch 'master' of github.com:yctercero/kibana into all-exc-view
yctercero 053c5d7
cleanup
yctercero c24c1ff
updated tests
yctercero 8b91e10
Merge branch 'master' of github.com:yctercero/kibana into all-exc-view
yctercero 878547e
updated translations to use securitySolution after rename
yctercero 410ecb9
Merge branch 'all-exc-view' of https://github.com/yctercero/kibana in…
yctercero bc7b81e
updated useExceptionList hook to use different refresh pattern, updat…
yctercero 798b1dd
moved exception item component into its own folder
yctercero 29810e7
added search bar, toggle, and buttons
yctercero da467bf
added exceptions viewer component
yctercero c953d0f
Merge branch 'master' of github.com:yctercero/kibana into exceptions-…
yctercero 32f66d2
fix merge issue
yctercero 8de7469
some cleanup
yctercero c333567
modified list scripts for help with testing
yctercero 8a51155
added exceptions hook for general api usage, updated exception item
yctercero 9196387
updated per feedback to allow for different filtering
yctercero 3117815
Merge branch 'master' of github.com:yctercero/kibana into exceptions-…
yctercero aea3b16
temp disabled complexity linter for rules/details/index, this file is…
yctercero 854892a
cleanup
yctercero 5303cc9
updated hook tests and clean up
yctercero 6027cbb
updated and added more tests, cleaned up linter issues and per page s…
yctercero 2f8eb18
update typing
yctercero 77fd167
Merge branch 'master' into exceptions-viewer-2
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
x-pack/plugins/lists/public/exceptions/hooks/use_api.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* 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 { useMemo } from 'react'; | ||
|
||
import * as Api from '../api'; | ||
import { HttpStart } from '../../../../../../src/core/public'; | ||
import { ExceptionListItemSchema, ExceptionListSchema } from '../../../common/schemas'; | ||
import { ApiCallMemoProps } from '../types'; | ||
|
||
export interface ExceptionsApi { | ||
deleteExceptionItem: (arg: ApiCallMemoProps) => Promise<void>; | ||
deleteExceptionList: (arg: ApiCallMemoProps) => Promise<void>; | ||
getExceptionItem: ( | ||
arg: ApiCallMemoProps & { onSuccess: (arg: ExceptionListItemSchema) => void } | ||
) => Promise<void>; | ||
getExceptionList: ( | ||
arg: ApiCallMemoProps & { onSuccess: (arg: ExceptionListSchema) => void } | ||
) => Promise<void>; | ||
} | ||
|
||
export const useApi = (http: HttpStart): ExceptionsApi => { | ||
return useMemo( | ||
(): ExceptionsApi => ({ | ||
async deleteExceptionItem({ | ||
id, | ||
namespaceType, | ||
onSuccess, | ||
onError, | ||
}: ApiCallMemoProps): Promise<void> { | ||
const abortCtrl = new AbortController(); | ||
|
||
try { | ||
await Api.deleteExceptionListItemById({ | ||
http, | ||
id, | ||
namespaceType, | ||
signal: abortCtrl.signal, | ||
}); | ||
onSuccess(); | ||
} catch (error) { | ||
onError(error); | ||
} | ||
}, | ||
async deleteExceptionList({ | ||
id, | ||
namespaceType, | ||
onSuccess, | ||
onError, | ||
}: ApiCallMemoProps): Promise<void> { | ||
const abortCtrl = new AbortController(); | ||
|
||
try { | ||
await Api.deleteExceptionListById({ | ||
http, | ||
id, | ||
namespaceType, | ||
signal: abortCtrl.signal, | ||
}); | ||
onSuccess(); | ||
} catch (error) { | ||
onError(error); | ||
} | ||
}, | ||
async getExceptionItem({ | ||
id, | ||
namespaceType, | ||
onSuccess, | ||
onError, | ||
}: ApiCallMemoProps & { onSuccess: (arg: ExceptionListItemSchema) => void }): Promise<void> { | ||
const abortCtrl = new AbortController(); | ||
|
||
try { | ||
const item = await Api.fetchExceptionListItemById({ | ||
http, | ||
id, | ||
namespaceType, | ||
signal: abortCtrl.signal, | ||
}); | ||
onSuccess(item); | ||
} catch (error) { | ||
onError(error); | ||
} | ||
}, | ||
async getExceptionList({ | ||
id, | ||
namespaceType, | ||
onSuccess, | ||
onError, | ||
}: ApiCallMemoProps & { onSuccess: (arg: ExceptionListSchema) => void }): Promise<void> { | ||
const abortCtrl = new AbortController(); | ||
|
||
try { | ||
const list = await Api.fetchExceptionListById({ | ||
http, | ||
id, | ||
namespaceType, | ||
signal: abortCtrl.signal, | ||
}); | ||
onSuccess(list); | ||
} catch (error) { | ||
onError(error); | ||
} | ||
}, | ||
}), | ||
[http] | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 way of exposing the list API's! Makes for a clean separation of concerns between usage in hooks, and exposing the plugin's API as a whole 🙂
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.
Yea, the other way felt strange and saw this pattern elsewhere.