-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cases] Remove case info from alerts when deleting an alert attachment (
#154024) ## Summary Users can remove alerts from a case by deleting the whole alert attachment. This PR removes the case id from the alerts when deleting an attachment of type alert. It does not remove the case info from all alerts attached to a case when deleting a case. It also fixes a bug where the success toaster will not show when deleting an attachment. Related: #146864, #140800 ## Testing 1. Create a case and attach some alerts to the case. 2. Verify that the alerts table (in security or in o11y) shows the case the alert is attached to. You can enable the cases column by pressing "Fields", searching for "Cases", and then selecting the field. 3. Go to the case and find the alerts' user activity. 4. Press the `...` and press "Remove alerts(s)" 5. Go back to the alert table and verify that the case is not shown in the Cases column for each alert. Please check that when you remove alert(s), attachments (ml, etc), and comments you get a success toaster with the correct text. ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
22 changed files
with
1,041 additions
and
53 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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 { CommentAttributes } from '../api'; | ||
import { CommentType } from '../api'; | ||
import { | ||
isCommentRequestTypeExternalReference, | ||
isCommentRequestTypePersistableState, | ||
} from './attachments'; | ||
|
||
describe('attachments utils', () => { | ||
describe('isCommentRequestTypeExternalReference', () => { | ||
const externalReferenceAttachment = { | ||
type: CommentType.externalReference as const, | ||
} as CommentAttributes; | ||
|
||
const commentTypeWithoutAlert = Object.values(CommentType).filter( | ||
(type) => type !== CommentType.externalReference | ||
); | ||
|
||
it('returns false for type: externalReference', () => { | ||
expect(isCommentRequestTypeExternalReference(externalReferenceAttachment)).toBe(true); | ||
}); | ||
|
||
it.each(commentTypeWithoutAlert)('returns false for type: %s', (type) => { | ||
const attachment = { | ||
type, | ||
} as CommentAttributes; | ||
|
||
expect(isCommentRequestTypeExternalReference(attachment)).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isCommentRequestTypePersistableState', () => { | ||
const persistableStateAttachment = { | ||
type: CommentType.persistableState as const, | ||
} as CommentAttributes; | ||
|
||
const commentTypeWithoutAlert = Object.values(CommentType).filter( | ||
(type) => type !== CommentType.persistableState | ||
); | ||
|
||
it('returns false for type: persistableState', () => { | ||
expect(isCommentRequestTypePersistableState(persistableStateAttachment)).toBe(true); | ||
}); | ||
|
||
it.each(commentTypeWithoutAlert)('returns false for type: %s', (type) => { | ||
const attachment = { | ||
type, | ||
} as CommentAttributes; | ||
|
||
expect(isCommentRequestTypePersistableState(attachment)).toBe(false); | ||
}); | ||
}); | ||
}); |
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
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
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
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.