-
Notifications
You must be signed in to change notification settings - Fork 136
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
refactor(ui): auto refresh button #1105
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
3c48d16
to
9938b30
Compare
/cc @baurine @breeswish |
}, 1000) as unknown as number | ||
) | ||
return () => clearTimeout(timer) | ||
}, [autoRefreshSeconds, isLoading, getRemainingRefreshSeconds()]) |
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.
The CI is passing without complaining about missing deps.. It doesn't look right. Could you take a look? @baurine
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.
OK, let me check it.
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 a correct behavior of your component should be:
- When auto refresh is on, a tick starts.
- At any time it is set to disabled, the tick paused.
- At any time it is set to enabled, the tick continues.
- When auto refresh settings is changed, the tick skips if the new refresh interval is set to a value smaller than remaining ticks.
- When auto refresh is off, the tick stops.
The loading behavior can be naturally expressed with the disabled
property, as you should not allow user to click refresh button again when there is a request on-going. In this case, you will want to set the disabled
when using this component. This also applies to the auto refresh: there is no need for the tick to continue if there is a request on-going, since the last request is not finished yet. This means, disabled
should be applied to both manual refresh and auto refresh. One property for all, which is great.
bfc997b
to
a16eced
Compare
) { | ||
setRemainingRefreshSeconds(autoRefreshSeconds) | ||
} | ||
}, [autoRefreshSeconds]) |
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.
the deps check is not working @baurine PTAL~
Codecov Report
@@ Coverage Diff @@
## master #1105 +/- ##
=========================================
Coverage ? 23.12%
=========================================
Files ? 102
Lines ? 9981
Branches ? 0
=========================================
Hits ? 2308
Misses ? 7523
Partials ? 150
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
const onChangeMetricType = useCallback( | ||
(v: DataTag) => { | ||
setMetricType(v) | ||
resetAutoRefresh() |
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 believe it is intentional that the there is no need to reset the refresh when metric type is changed, since there will be no data fetching operations during this.
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.
It looks better to recover the remaining seconds. And there's data fetching logic caused by metric type at L195-L200. Is this as expected? PTAL.
} | ||
}, 1000) | ||
return () => clearTimeout(timer.current!) | ||
}, [autoRefreshSeconds, disabled, getRemainingRefreshSeconds()]) |
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 feel this kind of way to implement the timer is a little hacky, and not accurate. There is a gap between the effects, maybe use interval is better.
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.
Yes, it's not accurate and it's on purpose. This may be necessary if we want to pause or resume timer instantly. Any good ideas?
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 874a57b
|
* refactor(ui): auto refresh button * chore: update translation * fix: remain seconds * refine: refresh button * fix: onRefresh * fix: auto refresh * fix: continue tick * chore: add some comments * tweak: remaining refresh seconds * chore: clean code Co-authored-by: Wenxuan <breezewish@pingcap.com>
* Revert "Release v2021.12.06.1 (#1084)" This reverts commit bcc43a0. * Compitable with different TiDB versions for conprof and non-root-login features (#1047) * make conprof independent * check feature enable * add check feature enable middleware * hide menu if feature is not enabled * refactor non root login switch by new design * i18n * yarn fmt * renaming * adjust fe code * refine * remove unused log * build(deps): bump ws from 5.2.2 to 5.2.3 in /ui (#1055) * CICD: Update the release pipeline for recent PD format policies (#1054) * fix i18n wording (#1056) * Refactor: Change util module to util package (#1052) * Refactor: Fix godot incorrectly add dot suffix to annotations (#1059) * lint: Add goheader for copyright lints (#1062) * Refactor: Migrate to use the `rest` package in util/ (#1060) * fix(*): globally delete/update data by GORM (#1065) * ui: bump dependencies (#1066) * refactor: Switch to use ziputil, netutil, reflectutil and fileswap (#1067) * Fix request header being pinned after pd profiling (#1069) * Integrate speedscope (#1064) * fix potential panic when GetPDInstances (#1075) Signed-off-by: crazycs <chen.two.cs@gmail.com> * Refactor: a new httpclient (#1073) * Refactor: Switch to use util/distro in all places (#1078) * chore: support import relative file URL (#1082) * Refactor: Move tools into a standalone module (#1079) * Fix script to embed the ui (#1088) * Fix script to embed the ui * Hack write_strings * Refactor feature flag to support more modules (#1057) * Drop sysutil dependency (#1093) * chore: add graph generation (#1085) * Refactor: Add TopologyProvider (#1098) * esbuild: i18n + dep (#1101) * script: Add a script to generate version matrix (#1104) * distro: support dynamic config (#1094) * chore: support multiple profiling types (#1095) * fix(distro): check distro_strings.json fmt by prettier (#1106) * script: fix generate assets (#1107) * Add integration test (#1083) * debug_api: Switch to use the new util (#1103) * refactor(ui): auto refresh button (#1105) * refactor(ui): auto refresh button * chore: update translation * fix: remain seconds * refine: refresh button * fix: onRefresh * fix: auto refresh * fix: continue tick * chore: add some comments * tweak: remaining refresh seconds * chore: clean code Co-authored-by: Wenxuan <breezewish@pingcap.com> * ui: refine conprof (#1102) * update wording * not check prom any more * replace time range component * i18n * support view profile by diffrent ways * extract ActionsButton * change download data format * refine * comments * Revert "comments" This reverts commit 3b03fdb. * fix view cpu profile fail * update state * hide action button if disable * address feedback * update release-version * sync with master Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Wenxuan <breezewish@pingcap.com> Co-authored-by: Suhaha <jklopsdfw@gmail.com> Co-authored-by: Yini Xu <34967660+YiniXu9506@users.noreply.github.com> Co-authored-by: crazycs <crazycs520@gmail.com>
Related PR: #1099