Skip to content
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

Conversation

achyutjhunjhunwala
Copy link
Contributor

@achyutjhunjhunwala achyutjhunjhunwala commented May 12, 2023

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

@achyutjhunjhunwala achyutjhunjhunwala added the Team:APM All issues that need APM UI Team support label May 12, 2023
@achyutjhunjhunwala achyutjhunjhunwala requested a review from a team as a code owner May 12, 2023 10:43
@achyutjhunjhunwala achyutjhunjhunwala self-assigned this May 12, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@achyutjhunjhunwala achyutjhunjhunwala added release_note:skip Skip the PR/issue when compiling release notes v8.8.0 labels May 12, 2023
Comment on lines +50 to +55
const refreshIntervalFromUrl =
'refreshInterval' in query
? toNumber(query.refreshInterval)
: DEFAULT_REFRESH_INTERVAL;
const refreshPausedFromUrl =
'refreshPaused' in query ? query.refreshPaused : 'true';
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

https://github.com/achyutjhunjhunwala/kibana/blob/08925c46ae9241ec260903621cf21a6abe226f4a/x-pack/plugins/apm/public/components/shared/date_picker/apm_date_picker.tsx#L26-L31

const {
rangeFrom,
rangeTo,
refreshPaused: refreshPausedFromUrl = 'true',
refreshInterval: refreshIntervalFromUrl,
} = query;

Comment on lines 177 to 191
useEffectOnce(() => {
// Sync Refresh Interval with Search Bar
const refreshInterval = {
pause: toBoolean(refreshPausedFromUrl),
value: refreshIntervalFromUrl,
};
if (
!deepEqual(
timeFilterService.timefilter.getRefreshInterval(),
refreshInterval
)
) {
timeFilterService.timefilter.setRefreshInterval(refreshInterval);
}
});
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

@achyutjhunjhunwala achyutjhunjhunwala May 15, 2023

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

Copy link
Contributor Author

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

Comment on lines +227 to +230
const onRefresh = () => {
clearCache();
incrementTimeRangeId();
};
Copy link
Member

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?

Copy link
Contributor Author

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

Comment on lines 184 to 187
!deepEqual(
timeFilterService.timefilter.getRefreshInterval(),
refreshInterval
)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup can be removed

Copy link
Member

@dgieselaar dgieselaar left a 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 !

@achyutjhunjhunwala achyutjhunjhunwala enabled auto-merge (squash) May 15, 2023 12:54
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.5MB 3.5MB +536.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @achyutjhunjhunwala

@achyutjhunjhunwala achyutjhunjhunwala merged commit 12dd688 into elastic:main May 15, 2023
@achyutjhunjhunwala achyutjhunjhunwala deleted the fix-unified-search-refresh_issue branch May 15, 2023 14:56
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 15, 2023
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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request May 15, 2023
# 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>
jasonrhodes pushed a commit that referenced this pull request May 17, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v8.8.0 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants