[Security Solution] [Exceptions] Adds a modal to confirm deletion of exception list (#145034)

This commit is contained in:
Devin W. Hurley 2022-11-14 10:35:36 -05:00 committed by GitHub
parent 6c9cc6626b
commit e27be55bae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 20 deletions

View file

@ -32,6 +32,8 @@ export const exportExceptionList = () => {
export const deleteExceptionListWithoutRuleReference = () => {
cy.get(EXCEPTIONS_OVERFLOW_ACTIONS_BTN).first().click();
cy.get(EXCEPTIONS_TABLE_DELETE_BTN).first().click();
cy.get(EXCEPTIONS_TABLE_MODAL).should('exist');
cy.get(EXCEPTIONS_TABLE_MODAL_CONFIRM_BTN).first().click();
cy.get(EXCEPTIONS_TABLE_MODAL).should('not.exist');
};

View file

@ -129,20 +129,12 @@ export const SharedLists = React.memo(() => {
({ id, listId, namespaceType }: { id: string; listId: string; namespaceType: NamespaceType }) =>
async () => {
try {
if (exceptionsListsRef[id] != null && exceptionsListsRef[id].rules.length === 0) {
await deleteExceptionList({
id,
namespaceType,
onError: handleDeleteError,
onSuccess: handleDeleteSuccess(listId),
});
if (refreshExceptions != null) {
refreshExceptions();
}
} else {
if (exceptionsListsRef[id] != null) {
setReferenceModalState({
contentText: i18n.referenceErrorMessage(exceptionsListsRef[id].rules.length),
contentText:
exceptionsListsRef[id].rules.length > 0
? i18n.referenceErrorMessage(exceptionsListsRef[id].rules.length)
: i18n.defaultDeleteListMessage(exceptionsListsRef[id].name),
rulesReferences: exceptionsListsRef[id].rules.map(({ name }) => name),
isLoading: true,
listId: id,
@ -155,13 +147,7 @@ export const SharedLists = React.memo(() => {
handleDeleteError(error);
}
},
[
deleteExceptionList,
exceptionsListsRef,
handleDeleteError,
handleDeleteSuccess,
refreshExceptions,
]
[exceptionsListsRef, handleDeleteError]
);
const handleExportSuccess = useCallback(

View file

@ -133,6 +133,12 @@ export const REFERENCE_MODAL_TITLE = i18n.translate(
}
);
export const defaultDeleteListMessage = (listName: string) =>
i18n.translate('xpack.securitySolution.exceptions.referenceModalDefaultDescription', {
defaultMessage: 'Are you sure you wish to DELETE exception list with the name {listName}?',
values: { listName },
});
export const REFERENCE_MODAL_CANCEL_BUTTON = i18n.translate(
'xpack.securitySolution.exceptions.referenceModalCancelButton',
{