Skip to content

[TRNT-4339] Add timezone selector in UI#4165

Merged
antgamdia merged 29 commits into
TRNT-4339from
TRNT-4339-2
Apr 29, 2026
Merged

[TRNT-4339] Add timezone selector in UI#4165
antgamdia merged 29 commits into
TRNT-4339from
TRNT-4339-2

Conversation

@antgamdia

@antgamdia antgamdia commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Description

This series of PRs aims to make the UI totally timezone-aware, depending on each user's preference. Not a browser preference, but a Trento user setting.

Next PR: #4169

Related # TRNT-4339


In this PR, we use an existing UI component to render a list of timezones and pass it as a payload for the user/profile settings. This PR is just about the frontend changes, nothing backend-related here.

The logic is simple: display a list of timezones. However, where does this list come from?
For instance, both Intl or the @date-fns wrapper we use have some support for timezones. One could possibly do Intl.supportedValuesOf("timeZone") to enumerate the timezones, and it works...
BUT: the list does not point to the latest version from IANA. For instance, in my browser, I just got Europe/Kiev but it was changed by the 2023c release (see source) to Europe/Kyiv.

By relying on a 3rd party dependency, we stay 100% aligned with any IANA tz release in the future. Note that this also updates the DST per country, so, in case of some political decisions around DST, the IANA database should quickly reflect that.

Some decisions:

  • Only "Edit user" and "user's profile" will have the timezone selector
  • Timezone for the default super admin is always Etc/UTC, and this is not modifiable (like other decisions)

Current status:

image

Note that for the UTC offset (like GMT+2) the current DST settings are taken into account. For instance, at the time of writing, Europe is in DST, meaning that we Europe/Madrid is GMT+2, but once in winter, it will be like GMT+1 again.

How was this tested?

IRL, unit and e2e tests

Did you update the documentation?

N/A

Additional information

Note: tests are currently failing because the backend is receiving more fields than it can handle. Subsequent stacked PRs will solve that.

Other proposals

There are some visual alternatives we can discuss, but they haven't been implemented in this PR:

Grouping by zone:

image

Adding country (requires yet another dependency)

image

Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
@antgamdia antgamdia added the env Create an ephimeral environment for the pr branch label Apr 9, 2026
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
@antgamdia antgamdia changed the base branch from main to TRNT-4339-1 April 10, 2026 11:49
@antgamdia antgamdia added enhancement New feature or request javascript Pull requests that update Javascript code and removed env Create an ephimeral environment for the pr branch labels Apr 10, 2026
Comment thread assets/js/lib/timezones/index.js
@antgamdia antgamdia mentioned this pull request Apr 15, 2026
3 tasks
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
@antgamdia antgamdia changed the base branch from TRNT-4339-1 to main April 15, 2026 14:54
@antgamdia antgamdia changed the base branch from main to TRNT-4339 April 15, 2026 15:26
@antgamdia antgamdia marked this pull request as ready for review April 15, 2026 15:27
@antgamdia

Copy link
Copy Markdown
Contributor Author

Personal note: check #4192 once merged

Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
@antgamdia

Copy link
Copy Markdown
Contributor Author

Personal note: check #4192 once merged

Done at fb00436

@antgamdia antgamdia requested a review from arbulu89 April 28, 2026 11:29

@arbulu89 arbulu89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @antgamdia
I have written some "easy to fix" comments first.
Besides, I have some thoughts on how we save the timezones in this custom cache, and maybe we can do the next.
At the end, the code execution is blocked the first time we run the generateTimezoneOptions (unless we do it async), so why not simply have:

const timezones = generateTimezoneOptions();
export timezones;

Without any caching code, just a simple functional method.
I think the result is basically the same (this happens always at the beginning, not in the first page that needs it).
I don't know, the caching thing looks "premature optimization" for a couple of hundreds element list.

Otherwise, if we want to go fancy, we could do the same in a redux saga, but it looks an overkill.

What do you think?
Both are acceptable and similar anyway.

Comment thread assets/package.json Outdated
Comment thread assets/js/state/user.js
Comment thread assets/js/pages/Users/UserForm.jsx Outdated
Comment thread assets/js/pages/Users/UserForm.jsx Outdated
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
@antgamdia

Copy link
Copy Markdown
Contributor Author

Feedback addressed; thanks a lot!

@antgamdia antgamdia requested a review from arbulu89 April 28, 2026 18:43
Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>

@arbulu89 arbulu89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great!
Really nice!

@antgamdia

Copy link
Copy Markdown
Contributor Author

Merging to feature branch: TRNT-4339

@antgamdia antgamdia merged commit ec9441f into TRNT-4339 Apr 29, 2026
43 of 51 checks passed
@antgamdia antgamdia deleted the TRNT-4339-2 branch April 29, 2026 12:06
antgamdia added a commit that referenced this pull request May 4, 2026
* [TRNT-4339] Add timezone selector in UI (#4165)
* [TRNT-4339] Add timezone in the backend (#4169)
* [TRNT-4339] Add timezone conversion in the frontend (#4174)
* [TRNT-4339] Add warning if selected tz does not match browser's (#4197)
* [TRNT-4339] Allow setting timezone at user creation (#4200)
---------

Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request javascript Pull requests that update Javascript code

Development

Successfully merging this pull request may close these issues.

3 participants