Add user preference to view project activity and starred project activity as default dashboard
Closes #2662
This commit is contained in:
parent
6d69181059
commit
0383afc66a
6 changed files with 38 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
Please view this file on the master branch, on stable branches it's out of date.
|
||||
|
||||
v 8.1.0 (unreleased)
|
||||
- Add user preference to view activities as default dashboard (Stan Hu)
|
||||
- Fix bug where projects would appear to be stuck in the forked import state (Stan Hu)
|
||||
- Fix Error 500 in creating merge requests with > 1000 diffs (Stan Hu)
|
||||
- Show CI status on all pages where commits list is rendered
|
||||
|
|
|
@ -22,6 +22,10 @@ class RootController < Dashboard::ProjectsController
|
|||
when 'stars'
|
||||
flash.keep
|
||||
redirect_to starred_dashboard_projects_path
|
||||
when 'project_activity'
|
||||
redirect_to activity_dashboard_path
|
||||
when 'starred_project_activity'
|
||||
redirect_to activity_dashboard_path(filter: 'starred')
|
||||
else
|
||||
return
|
||||
end
|
||||
|
|
|
@ -3,7 +3,9 @@ module PreferencesHelper
|
|||
# Maps `dashboard` values to more user-friendly option text
|
||||
DASHBOARD_CHOICES = {
|
||||
projects: 'Your Projects (default)',
|
||||
stars: 'Starred Projects'
|
||||
stars: 'Starred Projects',
|
||||
project_activity: "Your Projects' Activity",
|
||||
starred_project_activity: "Starred Projects' Activity"
|
||||
}.with_indifferent_access.freeze
|
||||
|
||||
# Returns an Array usable by a select field for more user-friendly option text
|
||||
|
|
|
@ -172,7 +172,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
# User's Dashboard preference
|
||||
# Note: When adding an option, it MUST go on the end of the array.
|
||||
enum dashboard: [:projects, :stars]
|
||||
enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity]
|
||||
|
||||
# User's Project preference
|
||||
# Note: When adding an option, it MUST go on the end of the array.
|
||||
|
|
|
@ -10,7 +10,7 @@ describe RootController do
|
|||
allow(subject).to receive(:current_user).and_return(user)
|
||||
end
|
||||
|
||||
context 'who has customized their dashboard setting' do
|
||||
context 'who has customized their dashboard setting for starred projects' do
|
||||
before do
|
||||
user.update_attribute(:dashboard, 'stars')
|
||||
end
|
||||
|
@ -21,6 +21,28 @@ describe RootController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'who has customized their dashboard setting for project activities' do
|
||||
before do
|
||||
user.update_attribute(:dashboard, 'project_activity')
|
||||
end
|
||||
|
||||
it 'redirects to the activity list' do
|
||||
get :index
|
||||
expect(response).to redirect_to activity_dashboard_path
|
||||
end
|
||||
end
|
||||
|
||||
context 'who has customized their dashboard setting for starred project activities' do
|
||||
before do
|
||||
user.update_attribute(:dashboard, 'starred_project_activity')
|
||||
end
|
||||
|
||||
it 'redirects to the activity list' do
|
||||
get :index
|
||||
expect(response).to redirect_to activity_dashboard_path(filter: 'starred')
|
||||
end
|
||||
end
|
||||
|
||||
context 'who uses the default dashboard setting' do
|
||||
it 'renders the default dashboard' do
|
||||
get :index
|
||||
|
|
|
@ -8,14 +8,18 @@ describe PreferencesHelper do
|
|||
end
|
||||
|
||||
it 'raises an exception when defined choices may be using the wrong key' do
|
||||
expect(User).to receive(:dashboards).and_return(foo: 'foo', bar: 'bar')
|
||||
dashboards = User.dashboards.dup
|
||||
dashboards[:projects_changed] = dashboards.delete :projects
|
||||
expect(User).to receive(:dashboards).and_return(dashboards)
|
||||
expect { helper.dashboard_choices }.to raise_error(KeyError)
|
||||
end
|
||||
|
||||
it 'provides better option descriptions' do
|
||||
expect(helper.dashboard_choices).to match_array [
|
||||
['Your Projects (default)', 'projects'],
|
||||
['Starred Projects', 'stars']
|
||||
['Starred Projects', 'stars'],
|
||||
["Your Projects' Activity", 'project_activity'],
|
||||
["Starred Projects' Activity", 'starred_project_activity']
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue