Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
878732b4
Commit
878732b4
authored
Jun 10, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a form field to customize the dashboard preference
cherry-picked
parent
5e0a8126
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
2 deletions
+58
-2
app/helpers/preferences_helper.rb
app/helpers/preferences_helper.rb
+21
-0
app/views/profiles/preferences/show.html.haml
app/views/profiles/preferences/show.html.haml
+17
-2
spec/helpers/preferences_helper_spec.rb
spec/helpers/preferences_helper_spec.rb
+20
-0
No files found.
app/helpers/preferences_helper.rb
0 → 100644
View file @
878732b4
# Helper methods for per-User preferences
module
PreferencesHelper
# Populates the dashboard preference select field with more user-friendly
# values.
def
dashboard_choices
orig
=
User
.
dashboards
.
keys
choices
=
[
[
'Projects (default)'
,
orig
[
0
]],
[
'Starred Projects'
,
orig
[
1
]]
]
if
orig
.
size
!=
choices
.
size
# Assure that anyone adding new options updates this method too
raise
RuntimeError
,
"`User` defines
#{
orig
.
size
}
dashboard choices,"
+
" but
#{
__method__
}
defined
#{
choices
.
size
}
"
else
choices
end
end
end
app/views/profiles/preferences/show.html.haml
View file @
878732b4
-
page_title
"Design"
-
page_title
'Preferences'
%h3
.page-title
%h3
.page-title
=
page_title
=
page_title
%p
.light
%p
.light
Appearance settings will be saved to your profile and made available across all devices.
These settings allow you to customize the appearance and behavior of the site.
They are saved with your account and will persist to any device you use to
access the site.
%hr
%hr
=
form_for
@user
,
url:
profile_preferences_path
,
remote:
true
,
method: :put
,
html:
{
class:
'js-preferences-form'
}
do
|
f
|
=
form_for
@user
,
url:
profile_preferences_path
,
remote:
true
,
method: :put
,
html:
{
class:
'js-preferences-form'
}
do
|
f
|
...
@@ -52,3 +54,16 @@
...
@@ -52,3 +54,16 @@
.preview
=
image_tag
"
#{
color_scheme
}
-scheme-preview.png"
.preview
=
image_tag
"
#{
color_scheme
}
-scheme-preview.png"
=
f
.
radio_button
:color_scheme_id
,
color_scheme_id
=
f
.
radio_button
:color_scheme_id
,
color_scheme_id
=
color_scheme
.
tr
(
'-_'
,
' '
).
titleize
=
color_scheme
.
tr
(
'-_'
,
' '
).
titleize
.panel.panel-default
.panel-heading
Behavior
.panel-body
.form-group
=
f
.
label
:dashboard
,
class:
'control-label'
.col-sm-10
=
f
.
select
:dashboard
,
dashboard_choices
,
{},
class:
'form-control'
%p
.help-block.hint
This setting allows you to customize the default Dashboard page.
.panel-footer
=
f
.
submit
'Save'
,
class:
'btn btn-save'
spec/helpers/preferences_helper_spec.rb
0 → 100644
View file @
878732b4
require
'spec_helper'
describe
PreferencesHelper
do
describe
'dashboard_choices'
do
it
'raises an exception when defined choices may be missing'
do
dashboards
=
User
.
dashboards
expect
(
User
).
to
receive
(
:dashboards
).
and_return
(
dashboards
.
merge
(
foo:
'foo'
))
expect
{
dashboard_choices
}.
to
raise_error
end
it
'provides better option descriptions'
do
choices
=
dashboard_choices
expect
(
choices
[
0
]).
to
eq
[
'Projects (default)'
,
'projects'
]
expect
(
choices
[
1
]).
to
eq
[
'Starred Projects'
,
'stars'
]
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment