[8.6] [Enterprise Search] Fix buggy data loading for index details page (#148032) (#148149)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Enterprise Search] Fix buggy data loading for index details page
(#148032)](https://github.com/elastic/kibana/pull/148032)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sloane
Perrault","email":"sloane.perrault@elastic.co"},"sourceCommit":{"committedDate":"2022-12-28T14:29:48Z","message":"[Enterprise
Search] Fix buggy data loading for index details page (#148032)\n\n##
Summary\r\n\r\nCalling this on mount and on `setIndexName` which is
issued via React\r\n`useEffect` would cause a data race. This would
sometimes cause the last\r\nviewed index to be fetched at first and the
data for the index actually\r\nbeing viewed wouldn't show until the
first poll.\r\n\r\n<details>\r\n<summary>🐛 Buggy
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1410658/195652568-7e269b45-17ae-4941-96e5-0bcc2fae1af5.mov\r\n\r\n</details>\r\n\r\n<details>\r\n<summary>🔧
Fixed
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1699281/209221538-4f518689-f44e-468b-870a-226503760d9b.mov\r\n\r\n</details>\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cc38847c4ef2d50336bab3ed163c37fbd3a80d1d","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:EnterpriseSearch","backport:prev-minor","v8.7.0"],"number":148032,"url":"https://github.com/elastic/kibana/pull/148032","mergeCommit":{"message":"[Enterprise
Search] Fix buggy data loading for index details page (#148032)\n\n##
Summary\r\n\r\nCalling this on mount and on `setIndexName` which is
issued via React\r\n`useEffect` would cause a data race. This would
sometimes cause the last\r\nviewed index to be fetched at first and the
data for the index actually\r\nbeing viewed wouldn't show until the
first poll.\r\n\r\n<details>\r\n<summary>🐛 Buggy
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1410658/195652568-7e269b45-17ae-4941-96e5-0bcc2fae1af5.mov\r\n\r\n</details>\r\n\r\n<details>\r\n<summary>🔧
Fixed
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1699281/209221538-4f518689-f44e-468b-870a-226503760d9b.mov\r\n\r\n</details>\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cc38847c4ef2d50336bab3ed163c37fbd3a80d1d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/148032","number":148032,"mergeCommit":{"message":"[Enterprise
Search] Fix buggy data loading for index details page (#148032)\n\n##
Summary\r\n\r\nCalling this on mount and on `setIndexName` which is
issued via React\r\n`useEffect` would cause a data race. This would
sometimes cause the last\r\nviewed index to be fetched at first and the
data for the index actually\r\nbeing viewed wouldn't show until the
first poll.\r\n\r\n<details>\r\n<summary>🐛 Buggy
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1410658/195652568-7e269b45-17ae-4941-96e5-0bcc2fae1af5.mov\r\n\r\n</details>\r\n\r\n<details>\r\n<summary>🔧
Fixed
behavior</summary>\r\n\r\n\r\nhttps://user-images.githubusercontent.com/1699281/209221538-4f518689-f44e-468b-870a-226503760d9b.mov\r\n\r\n</details>\r\n\r\n###
For maintainers\r\n\r\n- [x] This was checked for breaking API changes
and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"cc38847c4ef2d50336bab3ed163c37fbd3a80d1d"}}]}]
BACKPORT-->

Co-authored-by: Sloane Perrault <sloane.perrault@elastic.co>
This commit is contained in:
Kibana Machine 2022-12-28 10:38:28 -05:00 committed by GitHub
parent 93183bddac
commit 973aba5971
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 5 deletions

View file

@ -34,7 +34,7 @@ const DEFAULT_VALUES = {
connectorId: null,
error: null,
fetchIndexApiData: undefined,
fetchIndexApiStatus: Status.LOADING,
fetchIndexApiStatus: Status.IDLE,
hasAdvancedFilteringFeature: false,
hasBasicFilteringFeature: false,
hasFilteringFeature: false,

View file

@ -130,10 +130,6 @@ export const IndexViewLogic = kea<MakeLogicType<IndexViewValues, IndexViewAction
],
},
events: ({ actions }) => ({
afterMount: () => {
const { indexName } = IndexNameLogic.values;
actions.startFetchIndexPoll(indexName);
},
beforeUnmount: () => {
actions.stopFetchIndexPoll();
actions.resetFetchIndexApi();