[ResponseOps][Rules] Add loading state to rule params data views selector#203654
Conversation
|
Pinging @elastic/response-ops (Team:ResponseOps) |
There was a problem hiding this comment.
I looked at the code and wanted to discuss some ideas along with what you did.
- Stop relying on cache.
const ids = await dataViews.getIds(true); <--- refreshes the cache. We will always make a call to get the data views.
- Load data views only on mount.
useEffect(() => {
loadPersistedDataViews();
}, []); <--- remove the loadPersistedDataViews dependency. We want to run on mount once.
-
Could we use React Query? I assume the effort is big as the components are being shared in various solutions.
-
Remove this check.
if (!allDataViewItems) {
return null;
}
Yes, that's what I did in order to manage the case where the DV cache is initialized but empty. In hindsight, I think we also need a separate loading state because the initialized but empty cache would still fall under the case of "ready" data. This could be the reason why the issue is not always reproducible the same way!
I agree, the effect should be the same though, it's just the exhaustive deps lint rule that advises to add the callback to the dependencies, but it should be referentially stable and execute one time only.
Of course that was my first thought 😂 I agree that it would take a bit of time though, so how about we start with an intermediate solution and then add a work item for the migration to RQ?
Right, it should never execute since |
The
Totally agree. Let's do the intermediate solution and fix the bug. |
…m:umbopepato/kibana into 198502-fix-empty-rule-data-views-selector
💚 Build Succeeded
Metrics [docs]Page load bundle
History
|
|
Starting backport for target branches: 7.17, 8.16, 8.17, 8.x https://github.com/elastic/kibana/actions/runs/12356146557 |
…ctor (elastic#203654) ## Summary Introduces a loading state in the data views select popover and renders a loading indicator when DVs are not available yet. This makes sure that even if the `savedObjectsClient.find` call of the data views service takes a long time, we don't show an empty popover in the meantime. https://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1 ## References Fixes elastic#198502 ## Release note Fix race condition in alerting rules data view selector (cherry picked from commit 713d4bb)
…ctor (elastic#203654) ## Summary Introduces a loading state in the data views select popover and renders a loading indicator when DVs are not available yet. This makes sure that even if the `savedObjectsClient.find` call of the data views service takes a long time, we don't show an empty popover in the meantime. https://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1 ## References Fixes elastic#198502 ## Release note Fix race condition in alerting rules data view selector (cherry picked from commit 713d4bb)
…ctor (elastic#203654) ## Summary Introduces a loading state in the data views select popover and renders a loading indicator when DVs are not available yet. This makes sure that even if the `savedObjectsClient.find` call of the data views service takes a long time, we don't show an empty popover in the meantime. https://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1 ## References Fixes elastic#198502 ## Release note Fix race condition in alerting rules data view selector (cherry picked from commit 713d4bb)
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
…ws selector (#203654) (#204422) # Backport This will backport the following commits from `main` to `8.16`: - [[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)](#203654) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Umberto Pepato","email":"umbopepato@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-16T15:43:13Z","message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","v9.0.0","backport:all-open"],"title":"[ResponseOps][Rules] Add loading state to rule params data views selector","number":203654,"url":"https://github.com/elastic/kibana/pull/203654","mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203654","number":203654,"mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}}]}] BACKPORT--> Co-authored-by: Umberto Pepato <umbopepato@users.noreply.github.com>
…ws selector (#203654) (#204423) # Backport This will backport the following commits from `main` to `8.17`: - [[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)](#203654) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Umberto Pepato","email":"umbopepato@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-16T15:43:13Z","message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","v9.0.0","backport:all-open"],"title":"[ResponseOps][Rules] Add loading state to rule params data views selector","number":203654,"url":"https://github.com/elastic/kibana/pull/203654","mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203654","number":203654,"mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}}]}] BACKPORT--> Co-authored-by: Umberto Pepato <umbopepato@users.noreply.github.com>
…s selector (#203654) (#204424) # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)](#203654) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Umberto Pepato","email":"umbopepato@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-12-16T15:43:13Z","message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:ResponseOps","v9.0.0","backport:all-open"],"title":"[ResponseOps][Rules] Add loading state to rule params data views selector","number":203654,"url":"https://github.com/elastic/kibana/pull/203654","mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203654","number":203654,"mergeCommit":{"message":"[ResponseOps][Rules] Add loading state to rule params data views selector (#203654)\n\n## Summary\r\n\r\nIntroduces a loading state in the data views select popover and renders\r\na loading indicator when DVs are not available yet. This makes sure that\r\neven if the `savedObjectsClient.find` call of the data views service\r\ntakes a long time, we don't show an empty popover in the meantime.\r\n\r\n\r\nhttps://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1\r\n\r\n## References\r\n\r\nFixes #198502 \r\n\r\n## Release note\r\n\r\nFix race condition in alerting rules data view selector","sha":"713d4bbcb2d9f5e707d06c1d298287edd3e694d0"}}]}] BACKPORT--> Co-authored-by: Umberto Pepato <umbopepato@users.noreply.github.com>
|
This PR didn't make it on time to be in the latest 8.16.2 BC. Updating the labels. |
…ctor (elastic#203654) ## Summary Introduces a loading state in the data views select popover and renders a loading indicator when DVs are not available yet. This makes sure that even if the `savedObjectsClient.find` call of the data views service takes a long time, we don't show an empty popover in the meantime. https://github.com/user-attachments/assets/5bbe0c68-3ceb-4d7f-91fd-357db4caa5c1 ## References Fixes elastic#198502 ## Release note Fix race condition in alerting rules data view selector

Summary
Introduces a loading state in the data views select popover and renders a loading indicator when DVs are not available yet. This makes sure that even if the
savedObjectsClient.findcall of the data views service takes a long time, we don't show an empty popover in the meantime.Screen.Recording.2024-12-10.at.18.34.41.mov
References
Fixes #198502
Release note
Fix race condition in alerting rules data view selector