gitlab-org--gitlab-foss/app/helpers/preferences_helper.rb

52 lines
1.4 KiB
Ruby
Raw Normal View History

# Helper methods for per-User preferences
module PreferencesHelper
def layout_choices
[
['Fixed', :fixed],
['Fluid', :fluid]
]
end
2015-06-12 20:39:48 -04:00
# 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 Todos"
2015-06-12 20:39:48 -04:00
}.with_indifferent_access.freeze
2015-06-12 20:39:48 -04:00
# Returns an Array usable by a select field for more user-friendly option text
def dashboard_choices
defined = User.dashboards
2015-06-12 20:39:48 -04:00
if defined.size != DASHBOARD_CHOICES.size
# Ensure that anyone adding new options updates this method too
raise "`User` defines #{defined.size} dashboard choices," \
2015-06-12 20:39:48 -04:00
" but `DASHBOARD_CHOICES` defined #{DASHBOARD_CHOICES.size}."
else
2015-06-12 20:39:48 -04:00
defined.map do |key, _|
# Use `fetch` so `KeyError` gets raised when a key is missing
[DASHBOARD_CHOICES.fetch(key), key]
end
end
end
def project_view_choices
[
['Files and Readme (default)', :files],
2017-10-16 16:21:51 -04:00
['Activity', :activity],
['Readme', :readme]
]
end
def user_application_theme
@user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class
end
def user_color_scheme
Gitlab::ColorSchemes.for_user(current_user).css_class
end
end