diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 18:38:24 +0000 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /app/helpers/preferences_helper.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) | |
download | gitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app/helpers/preferences_helper.rb')
-rw-r--r-- | app/helpers/preferences_helper.rb | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 8a79217c929..070089d6ef8 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -9,19 +9,6 @@ module PreferencesHelper ] end - # Maps `dashboard` values to more user-friendly option text - DASHBOARD_CHOICES = { - projects: _("Your Projects (default)"), - stars: _("Starred Projects"), - project_activity: _("Your Projects' Activity"), - starred_project_activity: _("Starred Projects' Activity"), - groups: _("Your Groups"), - todos: _("Your To-Do List"), - issues: _("Assigned Issues"), - merge_requests: _("Assigned Merge Requests"), - operations: _("Operations Dashboard") - }.with_indifferent_access.freeze - # Returns an Array usable by a select field for more user-friendly option text def dashboard_choices dashboards = User.dashboards.keys @@ -31,10 +18,25 @@ module PreferencesHelper dashboards.map do |key| # Use `fetch` so `KeyError` gets raised when a key is missing - [DASHBOARD_CHOICES.fetch(key), key] + [localized_dashboard_choices.fetch(key), key] end end + # Maps `dashboard` values to more user-friendly option text + def localized_dashboard_choices + { + projects: _("Your Projects (default)"), + stars: _("Starred Projects"), + project_activity: _("Your Projects' Activity"), + starred_project_activity: _("Starred Projects' Activity"), + groups: _("Your Groups"), + todos: _("Your To-Do List"), + issues: _("Assigned Issues"), + merge_requests: _("Assigned Merge Requests"), + operations: _("Operations Dashboard") + }.with_indifferent_access.freeze + end + def project_view_choices [ ['Files and Readme (default)', :files], @@ -75,9 +77,9 @@ module PreferencesHelper # Ensure that anyone adding new options updates `DASHBOARD_CHOICES` too def validate_dashboard_choices!(user_dashboards) - if user_dashboards.size != DASHBOARD_CHOICES.size + if user_dashboards.size != localized_dashboard_choices.size raise "`User` defines #{user_dashboards.size} dashboard choices," \ - " but `DASHBOARD_CHOICES` defined #{DASHBOARD_CHOICES.size}." + " but `localized_dashboard_choices` defined #{localized_dashboard_choices.size}." end end |