Add Time Zone Select - #6437
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6437 +/- ##
=======================================
Coverage 92.15% 92.16%
=======================================
Files 1035 1036 +1
Lines 21163 21188 +25
=======================================
+ Hits 19502 19527 +25
Misses 1661 1661 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
899d5a5 to
c8011a0
Compare
c8011a0 to
def12cd
Compare
57e3df4 to
b57c763
Compare
|
@jarednorman please re-review. |
|
Accompany SAD PR solidusio/solidus_auth_devise#275 |
1889258 to
4a57b8f
Compare
jarednorman
left a comment
There was a problem hiding this comment.
Minor nit. Otherwise lgtm.
|
|
||
| # Checks if we need to change the timezone or not. | ||
| def timezone_change_needed? | ||
| params[:solidus_timezone].present? || session[:solidus_timezone].blank? |
There was a problem hiding this comment.
Wait, does this mean that change your user's time zone doesn't trigger the time zone to change in the session?
There was a problem hiding this comment.
Yeah, good catch. Resetting the session from a model update hook is probably not what we want. We could clear the session after we update the user in the controller(s). I will figure something out
There was a problem hiding this comment.
I changed it such that the session only gets resetted, if the user is the current admin user. Changing another users preferred timezone should not mess with the admin users timezone in the session.
There was a problem hiding this comment.
Am I proud of the controller tests? Probably not. Are they working? Yes. And at least they're hand written 😄
By including this module into a controller it will run all controller actions within the defined timezone. The timezone is taken from the params, the session, user preference (if existing), or the default timezone of the app. The resolved timezone is then stored in the session for future reference.
Use the `Spree::Core::ControllerHelpers::Timezone` module to wrap all admin actions inside the selected timezone.
Use the `Spree::Core::ControllerHelpers::Timezone` module to wrap all admin actions inside the selected timezone. Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Spans do not self close and this actually has a closing tag anyway. Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
If the user has a timezone column we show a select to let admins set the preferred time zone of the user.
If the user has a timezone column we show a select to let admins set the preferred time zone of the user.
We use that in the new main navigation sidebar to match the icons we use in the new Admin in the legacy backend. The timezone select we now display is missing the icon we already have in the new admin.
4a57b8f to
f8ecf57
Compare
After switching the current users preferred time zone in the admin/backend we want that to reflect in the session even if the session already has a timezone stored.
f8ecf57 to
c0bd481
Compare
|
Definitely warrants going into our next minor version bump. |
Summary
Adding a timezone select into the various admin/backend navigations we have. Allows for users to see dates in the admin in the selected timezone. If the current solidus user record has a preferred timezone this is used instead. The resolved timezone is stored in the users session.
Admin
Backend
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: