-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[APM]Fix manual refresh and auto refresh issue #157472
[APM]Fix manual refresh and auto refresh issue #157472
Conversation
Pinging @elastic/apm-ui (Team:APM) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
const refreshIntervalFromUrl = | ||
'refreshInterval' in query | ||
? toNumber(query.refreshInterval) | ||
: DEFAULT_REFRESH_INTERVAL; | ||
const refreshPausedFromUrl = | ||
'refreshPaused' in query ? query.refreshPaused : 'true'; |
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 think these should be retrieved from advanced settings. @sqren?
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'm not a huge fan of this approach tbh - we essentially lose any routing type safety. But out of scope for this PR.
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 saw they were retrieved from the Query Bar in the previous implementation of Date Picker, so i replicated them here.
kibana/x-pack/plugins/apm/public/components/shared/date_picker/apm_date_picker.tsx
Lines 26 to 31 in 08925c4
const { | |
rangeFrom, | |
rangeTo, | |
refreshPaused: refreshPausedFromUrl = 'true', | |
refreshInterval: refreshIntervalFromUrl, | |
} = query; |
useEffectOnce(() => { | ||
// Sync Refresh Interval with Search Bar | ||
const refreshInterval = { | ||
pause: toBoolean(refreshPausedFromUrl), | ||
value: refreshIntervalFromUrl, | ||
}; | ||
if ( | ||
!deepEqual( | ||
timeFilterService.timefilter.getRefreshInterval(), | ||
refreshInterval | ||
) | ||
) { | ||
timeFilterService.timefilter.setRefreshInterval(refreshInterval); | ||
} | ||
}); |
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.
Why just once? What happens if we navigate using browser history?
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.
is there any way we can use the search bar as a purely controlled component? also realise this is out of scope for this PR but all this syncing back and forth is a bug waiting to happen IMHO
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.
Looks like there were some changes in my local which could have caused some issue. When i was placing it under regular useEffect, the toggle for enabling/disabling would behave as uncontrolled component and would not let me toggle it. But now i don't see that issue anymore. So i will move it back to useEffect.
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.
Regarding making it a controlled component, i can try that in the next PR, as far as i remember, when i started using the props from the component, to update the state from the URL, they were not working. But with fixes done on the Unified Search component, i can give it a try in the next PR
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.
Added a follow up ticket here - #157715
const onRefresh = () => { | ||
clearCache(); | ||
incrementTimeRangeId(); | ||
}; |
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.
was this never implemented in the unified search bar implementation?
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.
Do you mean on the original Unified Search Component from Platform ?
On our side, this was a miss which caused the refresh button to not work
!deepEqual( | ||
timeFilterService.timefilter.getRefreshInterval(), | ||
refreshInterval | ||
) |
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.
why do we need the (deep) equal check? what happens if it's the same value and we call setRefreshInterval
anyway? will it cause infinite recursion?
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.
Yup can be removed
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.
Approved in the interest of time, but eager to see us follow up with some changes that can make this code more robust. Thanks @achyutjhunjhunwala !
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Fixes - elastic#156363 Depends on - elastic#157468 ## Summary The PR fixes the issues 1. Where when manually Refresh button on the Unified Search Bar is clicked, the refresh would do nothing. 2. When setting refresh interval and enabling automatic refresh, the page won't refresh respecting the settings. 3. When refresh interval was set and enabled, now when the whole page was refreshed, these settings would be lost as these settings were not originally synced to the URL (cherry picked from commit 12dd688)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.8`: - [[APM]Fix manual refresh and auto refresh issue (#157472)](#157472) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Achyut Jhunjhunwala","email":"achyut.jhunjhunwala@elastic.co"},"sourceCommit":{"committedDate":"2023-05-15T14:55:49Z","message":"[APM]Fix manual refresh and auto refresh issue (#157472)\n\nFixes - #156363 on - #157468 Summary\r\n\r\nThe PR fixes the issues\r\n1. Where when manually Refresh button on the Unified Search Bar is\r\nclicked, the refresh would do nothing.\r\n2. When setting refresh interval and enabling automatic refresh, the\r\npage won't refresh respecting the settings.\r\n3. When refresh interval was set and enabled, now when the whole page\r\nwas refreshed, these settings would be lost as these settings were not\r\noriginally synced to the URL","sha":"12dd68848d0b191ce0d3833ebc262cf075e2c21f","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","v8.8.0","v8.9.0"],"number":157472,"url":"#157472 manual refresh and auto refresh issue (#157472)\n\nFixes - #156363 on - #157468 Summary\r\n\r\nThe PR fixes the issues\r\n1. Where when manually Refresh button on the Unified Search Bar is\r\nclicked, the refresh would do nothing.\r\n2. When setting refresh interval and enabling automatic refresh, the\r\npage won't refresh respecting the settings.\r\n3. When refresh interval was set and enabled, now when the whole page\r\nwas refreshed, these settings would be lost as these settings were not\r\noriginally synced to the URL","sha":"12dd68848d0b191ce0d3833ebc262cf075e2c21f"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"#157472 manual refresh and auto refresh issue (#157472)\n\nFixes - #156363 on - #157468 Summary\r\n\r\nThe PR fixes the issues\r\n1. Where when manually Refresh button on the Unified Search Bar is\r\nclicked, the refresh would do nothing.\r\n2. When setting refresh interval and enabling automatic refresh, the\r\npage won't refresh respecting the settings.\r\n3. When refresh interval was set and enabled, now when the whole page\r\nwas refreshed, these settings would be lost as these settings were not\r\noriginally synced to the URL","sha":"12dd68848d0b191ce0d3833ebc262cf075e2c21f"}}]}] BACKPORT--> Co-authored-by: Achyut Jhunjhunwala <achyut.jhunjhunwala@elastic.co>
Fixes - #156363 Depends on - #157468 ## Summary The PR fixes the issues 1. Where when manually Refresh button on the Unified Search Bar is clicked, the refresh would do nothing. 2. When setting refresh interval and enabling automatic refresh, the page won't refresh respecting the settings. 3. When refresh interval was set and enabled, now when the whole page was refreshed, these settings would be lost as these settings were not originally synced to the URL
Fixes - #156363
Depends on - #157468
Summary
The PR fixes the issues