Skip to content

Remove default value for time zone user preference

📖 What does this MR do?

Related to #340795 (closed)

In gitlab-foss!26554 (merged) we added a timezone column to the user_preferences table. In !66493 (merged) we used the timezone value to display a user's local time on their profile. One issue we ran into is that since timezone defaults to UTC there is no way to tell if a user has explicitly set their timezone and therefore we always display local time on a user's profile. This can cause confusion because if a user has not explicitly set their timezone local time is displayed in UTC on their profile. Furthermore there is currently no way for a user to clear their timezone so that local time is not displayed on their profile.

This MR aims to solve these issues by implementing the following changes:

  1. Remove the default_value_for statement so a timezone value is not set for new users.
  2. Modify the time zone dropdown to allow an empty value
  3. Add an option to the dropdown to allow users to clear their timezone
  4. Only display local time on a user's profile if they have set their timezone

The only other place TimezoneDropdown is used is on the pipelines schedules page. I have included screenshots below to show that it has not changed.

📷 Screenshots

View Before After
Profile with time zone set Screen_Shot_2021-09-22_at_11.10.58_AM Screen_Shot_2021-09-22_at_11.05.01_AM
Profile without time zone set Screen_Shot_2021-09-22_at_11.11.45_AM Screen_Shot_2021-09-22_at_11.04.26_AM
Edit profile time zone selected Screen_Shot_2021-09-22_at_11.12.46_AM Screen_Shot_2021-09-23_at_2.20.57_PM
Edit profile time zone not selected Screen_Shot_2021-09-22_at_11.12.17_AM Screen_Shot_2021-09-22_at_11.03.14_AM
New pipeline schedule (no changes) Screen_Shot_2021-09-22_at_11.13.24_AM Screen_Shot_2021-09-22_at_11.01.37_AM

💻 How to setup and validate locally

  1. Login as an admin (root on GDK).
  2. Navigate to admin/users/new and fill out the form.
  3. Find the newly created user in /admin/users and click Impersonate.
  4. Navigate to your profile. Local time should not be displayed.
  5. Navigate to /-/profile and select a time zone. Save the form.
  6. Navigate to your profile. Local time should be displayed.

🚦 MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Hegman

Merge request reports