-
Notifications
You must be signed in to change notification settings - Fork 8.6k
DEV: use the only source for time shortcut options on all date pickers #16366
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
DEV: use the only source for time shortcut options on all date pickers #16366
Conversation
4c0e316
to
73f2d38
Compare
73f2d38
to
e767b07
Compare
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 this looks like a great cleanup, and as you said you've tested all this manually. Thanks for doing this work, much appreciated 🙏
e767b07
to
003afe7
Compare
|
||
_date: null, | ||
_time: null, | ||
|
||
init() { | ||
this._super(...arguments); | ||
this.userTimezone = this.currentUser.resolvedTimezone(this.currentUser); |
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.
This API looks a bit weird. Why is resolvedTimezone
on the currentUser
object? Shouldn't it be a helper method?
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 is weird. It's not the first call, see #15749 (comment). I'll fix it in a separate PR in next days.
003afe7
to
65a1f38
Compare
65a1f38
to
9b5e5f1
Compare
Some time ago, we added a new time-shortcut-picker. That picker had more customizable API than the old future-date-input and used a new builder of time shortcut options. Then we were going to switch
future-date-input
to the new options builder and make its API looks like the API oftime-shortcut-picker
, which would make it much more customizable. I did that change in #12985, but that PR was closed without merging due to various reasons (PR was too big, had flaky specs and was opened just before a release and then got outdated).Now I'm doing this job again, this time in two steps to make it safer and easier to review. The steps are
future-date-input
looks like API of thetime-shortcut-picker
(this will be provided in the next PR)Note that still there is some duplication in code, I'm going to dry the code up more on the second step.
Note also that I haven't added many tests in this PR because tests that're needed for covering this change were already added before, mostly in #13836.
Also, the time shortcut options in the old set weren't timezone aware:
discourse/app/assets/javascripts/select-kit/addon/components/future-date-input-selector.js
Line 27 in cecdef8
so, probably we had some subtle timezone-related bugs which will be fixed by this PR.