-
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] [Exceptions] Adds options to create a shared exception list and to create a single item from the manage exceptions view #144575
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
fd62185
initial work
dhurley14 cfebdbe
adds exception list import button + flyout, updates title of page and…
dhurley14 36fc5b9
working import
dhurley14 0ac8f00
merge with main
dhurley14 9647b1f
import list + override or as new list
dhurley14 2465249
fix type failures (still some warnings present) and general code cleanup
dhurley14 c2002ea
Merge remote-tracking branch 'upstream/main' into exceptions-all-list…
dhurley14 2a2fa40
adds delete action to actions menu bar
dhurley14 5d8b600
WIP - adding overflow actions
dhurley14 6921cee
Merge branch 'main' into exceptions-all-lists-view
dhurley14 a244e83
display flyout - not working right now, WIP
dhurley14 38c2713
properly formatted exceptions cards
dhurley14 9679dc3
display title of exception list in blue color
dhurley14 9c1245e
cleanup
dhurley14 833ff73
cleanup + start usage of pagination hooks
dhurley14 b3e7d29
working on pagination, sort of working
dhurley14 7d0cca9
working pagination, finally
dhurley14 47d95b1
adds comment explaining bug in pagination, also reset default paginat…
dhurley14 1a2d1b5
undo changes to getNewExceptionItem function
dhurley14 ae09187
undo changes that made ruleName an optional parameter for ExceptionBu…
dhurley14 c69f21b
add ternary logic for pageCount in pagination of exception list cards
dhurley14 002850a
Merge remote-tracking branch 'upstream/main' into interim-exceptions-…
dhurley14 bdf8045
update snapshots, fix test mocks to include new properties, update te…
dhurley14 a8dfd88
try to fix cypress, I think I fixed all the jests tests though
dhurley14 6d87807
fixes jest test expected text in breadcrumbs
dhurley14 0cc8118
fixes cypress tests
dhurley14 8139f2d
Merge remote-tracking branch 'upstream/main' into interim-exceptions-…
dhurley14 316d952
refactors cypress tests
MadameSheema 9206a37
move import flyout to separate file
dhurley14 c7add87
fix alignItems in the exception list card
dhurley14 179c272
fix flex boxes
dhurley14 d88996b
use styled flex item for badges
dhurley14 28e3af9
add title badge component to clean up code a little bit
dhurley14 32231ef
fix pagination location
dhurley14 a7f0897
don't refresh exceptions table
dhurley14 6e87260
merge with main
dhurley14 265cfa7
Merge branch 'main' into interim-exceptions-all-lists
dhurley14 8a4d040
adds i18n
dhurley14 1e8d0de
cleanup useEffect if statements
dhurley14 a92fa17
remove ts expect error
dhurley14 6b3391b
Merge remote-tracking branch 'upstream/main' into interim-exceptions-…
dhurley14 d25a76a
fix cypress test - delete should be disabled and adds translation fil…
dhurley14 b715fcf
Merge remote-tracking branch 'upstream/main' into interim-exceptions-…
dhurley14 dd6995c
move components out of rules exceptions
dhurley14 d620366
adds exception item flyout
dhurley14 2c6e961
Merge remote-tracking branch 'upstream/main' into more-exceptions-work
dhurley14 57198a8
Merge remote-tracking branch 'upstream/main' into more-exceptions-work
dhurley14 4525e00
add create shared exception list flyout - still need to create suppor…
dhurley14 fe10daf
working shared exceptions list route and flyout
dhurley14 100fc45
merge with main
dhurley14 d612b00
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 2eaa507
Merge remote-tracking branch 'upstream/main' into more-exceptions-work
dhurley14 b748ff8
fix type errors
dhurley14 ce5788a
Merge branch 'more-exceptions-work' of github.com:dhurley14/kibana in…
dhurley14 17ecc55
fix merge conflict
dhurley14 0c5081c
adds missing translation
dhurley14 dc7c006
fixes i18n for package
dhurley14 287a795
cleanup i18n, removes unused files, removes commented out code
dhurley14 48c2ade
more i18n updates
dhurley14 2b24a88
Merge branch 'main' into more-exceptions-work
dhurley14 2396070
fixes misspelling of function
dhurley14 f5f3ec3
adds constant for api route for creating a shared exception list, upd…
dhurley14 ba31ece
Merge branch 'main' into more-exceptions-work
dhurley14 2f2579d
remove the commented out code
dhurley14 1f44dc8
Merge branch 'more-exceptions-work' of github.com:dhurley14/kibana in…
dhurley14 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
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
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
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
188 changes: 188 additions & 0 deletions
188
...ns/security_solution/public/exceptions/manage_exceptions/create_shared_exception_list.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,188 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { ChangeEvent } from 'react'; | ||
import React, { memo, useState, useCallback, useRef, useEffect } from 'react'; | ||
import { | ||
EuiFlyout, | ||
EuiTitle, | ||
EuiFlyoutHeader, | ||
EuiFlyoutBody, | ||
EuiText, | ||
EuiFieldText, | ||
EuiSpacer, | ||
EuiTextArea, | ||
EuiFlyoutFooter, | ||
EuiFlexGroup, | ||
EuiButtonEmpty, | ||
EuiButton, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
import type { HttpSetup } from '@kbn/core-http-browser'; | ||
import type { ErrorToastOptions, Toast, ToastInput } from '@kbn/core-notifications-browser'; | ||
import { i18n as translate } from '@kbn/i18n'; | ||
import type { ListDetails } from '@kbn/securitysolution-exception-list-components'; | ||
|
||
import { useCreateSharedExceptionListWithOptionalSignal } from './use_create_shared_list'; | ||
import { | ||
CREATE_SHARED_LIST_TITLE, | ||
CREATE_SHARED_LIST_NAME_FIELD, | ||
CREATE_SHARED_LIST_DESCRIPTION, | ||
CREATE_BUTTON, | ||
CLOSE_FLYOUT, | ||
CREATE_SHARED_LIST_DESCRIPTION_PLACEHOLDER, | ||
CREATE_SHARED_LIST_NAME_FIELD_PLACEHOLDER, | ||
SUCCESS_TITLE, | ||
getSuccessText, | ||
} from './translations'; | ||
|
||
export const CreateSharedListFlyout = memo( | ||
({ | ||
handleRefresh, | ||
http, | ||
handleCloseFlyout, | ||
addSuccess, | ||
addError, | ||
}: { | ||
handleRefresh: () => void; | ||
http: HttpSetup; | ||
addSuccess: (toastOrTitle: ToastInput, options?: unknown) => Toast; | ||
addError: (error: unknown, options: ErrorToastOptions) => Toast; | ||
handleCloseFlyout: () => void; | ||
}) => { | ||
const { start: createSharedExceptionList, ...createSharedExceptionListState } = | ||
useCreateSharedExceptionListWithOptionalSignal(); | ||
const ctrl = useRef(new AbortController()); | ||
|
||
enum DetailProperty { | ||
name = 'name', | ||
description = 'description', | ||
} | ||
|
||
const [newListDetails, setNewListDetails] = useState<ListDetails>({ | ||
name: '', | ||
description: '', | ||
}); | ||
const onChange = ( | ||
{ target }: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>, | ||
detailProperty: DetailProperty.name | DetailProperty.description | ||
) => { | ||
const { value } = target; | ||
setNewListDetails({ ...newListDetails, [detailProperty]: value }); | ||
}; | ||
|
||
const handleCreateSharedExceptionList = useCallback(() => { | ||
if (!createSharedExceptionListState.loading && newListDetails.name !== '') { | ||
ctrl.current = new AbortController(); | ||
|
||
createSharedExceptionList({ | ||
http, | ||
signal: ctrl.current.signal, | ||
name: newListDetails.name, | ||
description: newListDetails.description ?? '', | ||
}); | ||
} | ||
}, [createSharedExceptionList, createSharedExceptionListState.loading, newListDetails, http]); | ||
|
||
const handleCreateSuccess = useCallback( | ||
(response) => { | ||
addSuccess({ | ||
text: getSuccessText(newListDetails.name), | ||
title: SUCCESS_TITLE, | ||
}); | ||
handleRefresh(); | ||
|
||
handleCloseFlyout(); | ||
}, | ||
[addSuccess, handleCloseFlyout, handleRefresh, newListDetails] | ||
); | ||
|
||
const handleCreateError = useCallback( | ||
(error) => { | ||
if (!error.message.includes('AbortError') && !error?.body?.message.includes('AbortError')) { | ||
addError(error, { | ||
title: translate.translate( | ||
'xpack.securitySolution.exceptions.createSharedExceptionListErrorTitle', | ||
{ | ||
defaultMessage: 'creation error', | ||
} | ||
), | ||
}); | ||
} | ||
}, | ||
[addError] | ||
); | ||
|
||
useEffect(() => { | ||
if (!createSharedExceptionListState.loading) { | ||
if (createSharedExceptionListState?.result) { | ||
handleCreateSuccess(createSharedExceptionListState.result); | ||
} else if (createSharedExceptionListState?.error) { | ||
handleCreateError(createSharedExceptionListState?.error); | ||
} | ||
} | ||
}, [ | ||
createSharedExceptionListState?.error, | ||
createSharedExceptionListState.loading, | ||
createSharedExceptionListState.result, | ||
handleCreateError, | ||
handleCreateSuccess, | ||
]); | ||
|
||
return ( | ||
<EuiFlyout | ||
ownFocus | ||
size="s" | ||
onClose={handleCloseFlyout} | ||
data-test-subj="createSharedExceptionListFlyout" | ||
> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="m"> | ||
<h2 data-test-subj="createSharedExceptionListTitle">{CREATE_SHARED_LIST_TITLE}</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<EuiText>{CREATE_SHARED_LIST_NAME_FIELD}</EuiText> | ||
<EuiFieldText | ||
placeholder={CREATE_SHARED_LIST_NAME_FIELD_PLACEHOLDER} | ||
value={newListDetails.name} | ||
onChange={(e) => onChange(e, DetailProperty.name)} | ||
aria-label="Use aria labels when no actual label is in use" | ||
/> | ||
<EuiSpacer /> | ||
<EuiText>{CREATE_SHARED_LIST_DESCRIPTION}</EuiText> | ||
<EuiTextArea | ||
placeholder={CREATE_SHARED_LIST_DESCRIPTION_PLACEHOLDER} | ||
value={newListDetails.description} | ||
onChange={(e) => onChange(e, DetailProperty.description)} | ||
aria-label="Stop the hackers" | ||
/> | ||
</EuiFlyoutBody> | ||
<EuiFlyoutFooter> | ||
<EuiFlexGroup justifyContent="spaceBetween"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty iconType="cross" onClick={handleCloseFlyout} flush="left"> | ||
{CLOSE_FLYOUT} | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
data-test-subj="exception-lists-form-create-shared" | ||
onClick={handleCreateSharedExceptionList} | ||
disabled={newListDetails.name === ''} | ||
> | ||
{CREATE_BUTTON} | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlyoutFooter> | ||
</EuiFlyout> | ||
); | ||
} | ||
); | ||
|
||
CreateSharedListFlyout.displayName = 'CreateSharedListFlyout'; |
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
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.
❤️