-
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
[Cases] Fix bug in cases bulk action in the alerts table #160526
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
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.
Tested and works fine 👍
@@ -146,6 +146,10 @@ export const useBulkAddToCaseActions = ({ | |||
onClick: (alerts?: TimelineItem[]) => { | |||
selectCaseModal.open({ | |||
getAttachments: ({ theCase }) => { | |||
if (theCase == null) { | |||
return alerts ? casesService?.helpers.groupAlertsByRule(alerts) ?? [] : []; |
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.
can alerts
actually be missing? If this is triggered via the bulk actions it shouldn't ever, right?
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.
I don't remember why but I followed the pattern used in the other action. Maybe there is a reason. I agree with you. It shouldn't be undefined.
@@ -124,6 +126,55 @@ describe('bulk action hooks', () => { | |||
expect(openExistingCase).toHaveBeenCalled(); | |||
}); | |||
|
|||
it('should open the flyout from the case modal', async () => { |
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.
An e2e test for this would also be nice if there is time. Looked a bit for them but dunno if there even are any regarding bulk actions in the alerts table.
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.
I don't think we have. Do you mind if we do it on another PR? I have this issue to track it #160240.
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
To update your PR or re-run it, just comment with: cc @cnasikas |
) ## Summary In 8.8 we move the logic of the cases action from solutions to the alerts table. A bug was introduced when you try to attach an alert to a new case through the cases modal. Before https://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6 Error in `console` ``` Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id') at getAttachments (use_bulk_actions.ts:100:1) at use_cases_add_to_existing_case_modal.tsx:52:1 at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1) at all_cases_selector_modal.tsx:36:1 at all_cases_list.tsx:208:1 at table_filters.tsx:128:1 at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1) at invokeGuardedCallback (react-dom.development.js:4056:1) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1) ``` After https://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624 ### 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) ## Release notes Fix a bug in the alerts table where you cannot create a new case when attaching alerts to a case from the cases modal (cherry picked from commit df21ba0)
) ## Summary In 8.8 we move the logic of the cases action from solutions to the alerts table. A bug was introduced when you try to attach an alert to a new case through the cases modal. Before https://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6 Error in `console` ``` Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id') at getAttachments (use_bulk_actions.ts:100:1) at use_cases_add_to_existing_case_modal.tsx:52:1 at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1) at all_cases_selector_modal.tsx:36:1 at all_cases_list.tsx:208:1 at table_filters.tsx:128:1 at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1) at invokeGuardedCallback (react-dom.development.js:4056:1) at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1) ``` After https://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624 ### 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) ## Release notes Fix a bug in the alerts table where you cannot create a new case when attaching alerts to a case from the cases modal (cherry picked from commit df21ba0)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…) (#160542) # Backport This will backport the following commits from `main` to `8.8`: - [[Cases] Fix bug in cases bulk action in the alerts table (#160526)](#160526) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Christos Nasikas","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-26T15:32:29Z","message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","Feature:Cases","v8.9.0","v8.8.2","v8.10.0"],"number":160526,"url":"https://github.com/elastic/kibana/pull/160526","mergeCommit":{"message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9","8.8"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160526","number":160526,"mergeCommit":{"message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}}]}] BACKPORT--> Co-authored-by: Christos Nasikas <[email protected]>
…) (#160543) # Backport This will backport the following commits from `main` to `8.9`: - [[Cases] Fix bug in cases bulk action in the alerts table (#160526)](#160526) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Christos Nasikas","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-26T15:32:29Z","message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","Feature:Cases","v8.9.0","v8.8.2","v8.10.0"],"number":160526,"url":"https://github.com/elastic/kibana/pull/160526","mergeCommit":{"message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9","8.8"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160526","number":160526,"mergeCommit":{"message":"[Cases] Fix bug in cases bulk action in the alerts table (#160526)\n\n## Summary\n\nIn 8.8 we move the logic of the cases action from solutions to the\nalerts table. A bug was introduced when you try to attach an alert to a\nnew case through the cases modal.\n\nBefore\n\n\nhttps://github.com/elastic/kibana/assets/7871006/771a5d28-e279-43d4-b72e-2dfb6689bae6\n\nError in `console`\n\n```\nUncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id')\n at getAttachments (use_bulk_actions.ts:100:1)\n at use_cases_add_to_existing_case_modal.tsx:52:1\n at onRowClick (use_cases_add_to_existing_case_modal.tsx:107:1)\n at all_cases_selector_modal.tsx:36:1\n at all_cases_list.tsx:208:1\n at table_filters.tsx:128:1\n at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)\n at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)\n at invokeGuardedCallback (react-dom.development.js:4056:1)\n at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070:1)\n```\n\nAfter \n\n\nhttps://github.com/elastic/kibana/assets/7871006/89e44018-49cf-41f7-8e07-01c6eb197624\n\n### Checklist\n\nDelete any items that are not applicable to this PR.\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n\n### For maintainers\n\n- [x] This was checked for breaking API changes and was [labeled\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n## Release notes\nFix a bug in the alerts table where you cannot create a new case when\nattaching alerts to a case from the cases modal","sha":"df21ba0e11d24b9e7db70152b6ab421fc10db69c"}}]}] BACKPORT--> Co-authored-by: Christos Nasikas <[email protected]>
This PR didn't make it into the latest build candidate of v8.8.2. Updating the labels. |
Summary
In 8.8 we move the logic of the cases action from solutions to the alerts table. A bug was introduced when you try to attach an alert to a new case through the cases modal.
Before
Screen.Recording.2023-06-26.at.5.26.32.PM.mov
Error in
console
After
Screen.Recording.2023-06-26.at.5.25.41.PM.mov
Checklist
Delete any items that are not applicable to this PR.
For maintainers
Release notes
Fix a bug in the alerts table where you cannot create a new case when attaching alerts to a case from the cases modal