2015-06-05 19:53:57 +00:00
|
|
|
# Helper methods for per-User preferences
|
|
|
|
module PreferencesHelper
|
2015-10-05 15:22:47 +00:00
|
|
|
def layout_choices
|
|
|
|
[
|
2015-10-05 16:09:05 +00:00
|
|
|
['Fixed', :fixed],
|
|
|
|
['Fluid', :fluid]
|
2015-10-05 15:22:47 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2015-06-13 00:39:48 +00:00
|
|
|
# Maps `dashboard` values to more user-friendly option text
|
|
|
|
DASHBOARD_CHOICES = {
|
|
|
|
projects: 'Your Projects (default)',
|
2015-09-26 00:04:20 +00:00
|
|
|
stars: 'Starred Projects',
|
|
|
|
project_activity: "Your Projects' Activity",
|
2016-03-24 10:12:45 +00:00
|
|
|
starred_project_activity: "Starred Projects' Activity",
|
|
|
|
groups: "Your Groups",
|
|
|
|
todos: "Your Todos"
|
2015-06-13 00:39:48 +00:00
|
|
|
}.with_indifferent_access.freeze
|
2015-06-10 08:42:02 +00:00
|
|
|
|
2015-06-13 00:39:48 +00:00
|
|
|
# Returns an Array usable by a select field for more user-friendly option text
|
|
|
|
def dashboard_choices
|
|
|
|
defined = User.dashboards
|
2015-06-10 08:42:02 +00:00
|
|
|
|
2015-06-13 00:39:48 +00:00
|
|
|
if defined.size != DASHBOARD_CHOICES.size
|
|
|
|
# Ensure that anyone adding new options updates this method too
|
2016-11-30 07:34:29 +00:00
|
|
|
raise "`User` defines #{defined.size} dashboard choices," \
|
2015-06-13 00:39:48 +00:00
|
|
|
" but `DASHBOARD_CHOICES` defined #{DASHBOARD_CHOICES.size}."
|
2015-06-10 08:42:02 +00:00
|
|
|
else
|
2015-06-13 00:39:48 +00:00
|
|
|
defined.map do |key, _|
|
|
|
|
# Use `fetch` so `KeyError` gets raised when a key is missing
|
|
|
|
[DASHBOARD_CHOICES.fetch(key), key]
|
|
|
|
end
|
2015-06-10 08:42:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-13 16:24:15 +00:00
|
|
|
def project_view_choices
|
|
|
|
[
|
2017-03-06 20:49:31 +00:00
|
|
|
['Files and Readme (default)', :files],
|
2017-10-16 20:21:51 +00:00
|
|
|
['Activity', :activity],
|
|
|
|
['Readme', :readme]
|
2015-07-13 16:24:15 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2017-09-11 15:44:42 +00:00
|
|
|
def user_application_theme
|
|
|
|
@user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class
|
|
|
|
end
|
|
|
|
|
2015-08-26 18:33:44 +00:00
|
|
|
def user_color_scheme
|
|
|
|
Gitlab::ColorSchemes.for_user(current_user).css_class
|
2015-06-05 19:53:57 +00:00
|
|
|
end
|
|
|
|
end
|