2015-06-05 15:53:57 -04:00
|
|
|
# Helper methods for per-User preferences
|
|
|
|
module PreferencesHelper
|
2015-10-05 11:22:47 -04:00
|
|
|
def layout_choices
|
|
|
|
[
|
2015-10-05 12:09:05 -04:00
|
|
|
['Fixed', :fixed],
|
|
|
|
['Fluid', :fluid]
|
2015-10-05 11:22:47 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2015-06-12 20:39:48 -04:00
|
|
|
# Maps `dashboard` values to more user-friendly option text
|
|
|
|
DASHBOARD_CHOICES = {
|
|
|
|
projects: 'Your Projects (default)',
|
2015-09-25 20:04:20 -04:00
|
|
|
stars: 'Starred Projects',
|
|
|
|
project_activity: "Your Projects' Activity",
|
2016-03-24 06:12:45 -04:00
|
|
|
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-10 04:42:02 -04:00
|
|
|
|
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-10 04:42:02 -04:00
|
|
|
|
2015-06-12 20:39:48 -04:00
|
|
|
if defined.size != DASHBOARD_CHOICES.size
|
|
|
|
# Ensure that anyone adding new options updates this method too
|
2016-11-30 02:34:29 -05:00
|
|
|
raise "`User` defines #{defined.size} dashboard choices," \
|
2015-06-12 20:39:48 -04:00
|
|
|
" but `DASHBOARD_CHOICES` defined #{DASHBOARD_CHOICES.size}."
|
2015-06-10 04:42:02 -04:00
|
|
|
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
|
2015-06-10 04:42:02 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-13 12:24:15 -04:00
|
|
|
def project_view_choices
|
|
|
|
[
|
2017-03-06 15:49:31 -05:00
|
|
|
['Files and Readme (default)', :files],
|
2017-10-16 16:21:51 -04:00
|
|
|
['Activity', :activity],
|
|
|
|
['Readme', :readme]
|
2015-07-13 12:24:15 -04:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2017-09-11 11:44:42 -04:00
|
|
|
def user_application_theme
|
|
|
|
@user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class
|
|
|
|
end
|
|
|
|
|
2015-08-26 14:33:44 -04:00
|
|
|
def user_color_scheme
|
|
|
|
Gitlab::ColorSchemes.for_user(current_user).css_class
|
2015-06-05 15:53:57 -04:00
|
|
|
end
|
|
|
|
end
|