Commit ac34ce86 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'add-activity-dashboard-preference' into 'master'

Add user preference to view project activity and starred project activity as default dashboard

Screenshot:

![image](https://gitlab.com/gitlab-org/gitlab-ce/uploads/5e39fa66da50e01dd9ed1c8a9ce01ea9/image.png)

Closes #2662

See merge request !1446
parents e86e87fa 0383afc6
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased) 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 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) - Fix Error 500 in creating merge requests with > 1000 diffs (Stan Hu)
- Show CI status on all pages where commits list is rendered - Show CI status on all pages where commits list is rendered
......
...@@ -22,6 +22,10 @@ class RootController < Dashboard::ProjectsController ...@@ -22,6 +22,10 @@ class RootController < Dashboard::ProjectsController
when 'stars' when 'stars'
flash.keep flash.keep
redirect_to starred_dashboard_projects_path 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 else
return return
end end
......
...@@ -3,7 +3,9 @@ module PreferencesHelper ...@@ -3,7 +3,9 @@ module PreferencesHelper
# Maps `dashboard` values to more user-friendly option text # Maps `dashboard` values to more user-friendly option text
DASHBOARD_CHOICES = { DASHBOARD_CHOICES = {
projects: 'Your Projects (default)', 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 }.with_indifferent_access.freeze
# Returns an Array usable by a select field for more user-friendly option text # Returns an Array usable by a select field for more user-friendly option text
......
...@@ -172,7 +172,7 @@ class User < ActiveRecord::Base ...@@ -172,7 +172,7 @@ class User < ActiveRecord::Base
# User's Dashboard preference # User's Dashboard preference
# Note: When adding an option, it MUST go on the end of the array. # 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 # User's Project preference
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
......
...@@ -10,7 +10,7 @@ describe RootController do ...@@ -10,7 +10,7 @@ describe RootController do
allow(subject).to receive(:current_user).and_return(user) allow(subject).to receive(:current_user).and_return(user)
end end
context 'who has customized their dashboard setting' do context 'who has customized their dashboard setting for starred projects' do
before do before do
user.update_attribute(:dashboard, 'stars') user.update_attribute(:dashboard, 'stars')
end end
...@@ -21,6 +21,28 @@ describe RootController do ...@@ -21,6 +21,28 @@ describe RootController do
end end
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 context 'who uses the default dashboard setting' do
it 'renders the default dashboard' do it 'renders the default dashboard' do
get :index get :index
......
...@@ -8,14 +8,18 @@ describe PreferencesHelper do ...@@ -8,14 +8,18 @@ describe PreferencesHelper do
end end
it 'raises an exception when defined choices may be using the wrong key' do 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) expect { helper.dashboard_choices }.to raise_error(KeyError)
end end
it 'provides better option descriptions' do it 'provides better option descriptions' do
expect(helper.dashboard_choices).to match_array [ expect(helper.dashboard_choices).to match_array [
['Your Projects (default)', 'projects'], ['Your Projects (default)', 'projects'],
['Starred Projects', 'stars'] ['Starred Projects', 'stars'],
["Your Projects' Activity", 'project_activity'],
["Starred Projects' Activity", 'starred_project_activity']
] ]
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment