Skip to content

Add Time Zone Select - #6437

Merged
tvdeyen merged 10 commits into
solidusio:mainfrom
blish:timezone-select
Aug 13, 2026
Merged

Add Time Zone Select#6437
tvdeyen merged 10 commits into
solidusio:mainfrom
blish:timezone-select

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Apr 15, 2026

Copy link
Copy Markdown
Member

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

CleanShot 2026-08-12 at 13 21 22@2x CleanShot 2026-08-12 at 13 43 27@2x

Backend

CleanShot 2026-08-12 at 13 34 04@2x CleanShot 2026-08-12 at 14 02 44@2x

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@tvdeyen tvdeyen added the type:enhancement Proposed or newly added feature label Apr 15, 2026
@tvdeyen tvdeyen self-assigned this Apr 15, 2026
@github-actions github-actions Bot added changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus_admin labels Apr 15, 2026
@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.16%. Comparing base (62ec49d) to head (c0bd481).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen
tvdeyen force-pushed the timezone-select branch 4 times, most recently from 899d5a5 to c8011a0 Compare April 23, 2026 08:11
@tvdeyen
tvdeyen marked this pull request as ready for review April 23, 2026 08:12
@tvdeyen
tvdeyen requested a review from a team as a code owner April 23, 2026 08:12
@tvdeyen tvdeyen removed their assignment Apr 24, 2026
Comment thread admin/spec/controllers/solidus_admin/base_controller_spec.rb
Comment thread admin/spec/controllers/solidus_admin/base_controller_spec.rb
Comment thread admin/spec/controllers/solidus_admin/base_controller_spec.rb
Comment thread admin/spec/controllers/solidus_admin/base_controller_spec.rb
Comment thread admin/spec/features/users_spec.rb
Comment thread backend/spec/controllers/spree/admin/stock_items_controller_spec.rb
Comment thread core/app/helpers/spree/core/controller_helpers/timezone.rb
Comment thread core/app/helpers/spree/core/controller_helpers/timezone.rb
Comment thread core/app/helpers/spree/core/controller_helpers/timezone.rb
Comment thread core/app/helpers/spree/core/controller_helpers/timezone.rb
Comment thread admin/app/components/solidus_admin/users/edit/component.html.erb Outdated
@tvdeyen
tvdeyen force-pushed the timezone-select branch 2 times, most recently from 57e3df4 to b57c763 Compare August 12, 2026 11:40
@tvdeyen
tvdeyen requested a review from jarednorman August 12, 2026 11:42
@tvdeyen

tvdeyen commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

@jarednorman please re-review.

@tvdeyen

tvdeyen commented Aug 12, 2026

Copy link
Copy Markdown
Member Author

Accompany SAD PR solidusio/solidus_auth_devise#275

@tvdeyen
tvdeyen force-pushed the timezone-select branch 2 times, most recently from 1889258 to 4a57b8f Compare August 12, 2026 12:10
Comment thread admin/app/components/solidus_admin/users/edit/component.html.erb

@jarednorman jarednorman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor nit. Otherwise lgtm.

Comment thread admin/app/components/solidus_admin/users/edit/component.html.erb Outdated

# Checks if we need to change the timezone or not.
def timezone_change_needed?
params[:solidus_timezone].present? || session[:solidus_timezone].blank?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait, does this mean that change your user's time zone doesn't trigger the time zone to change in the session?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

@tvdeyen tvdeyen Aug 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in c0bd481

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

c0bd481

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.
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.
@jarednorman

Copy link
Copy Markdown
Member

Definitely warrants going into our next minor version bump.

@tvdeyen
tvdeyen merged commit 4697059 into solidusio:main Aug 13, 2026
39 checks passed
@tvdeyen
tvdeyen deleted the timezone-select branch August 13, 2026 21:38
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Solidus Public Roadmap Aug 13, 2026
@github-project-automation github-project-automation Bot moved this from Review to Done in Solidus Admin Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_admin changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem type:enhancement Proposed or newly added feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants