summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/concerns/filter_projects.rb2
-rw-r--r--app/views/shared/projects/_dropdown.html.haml11
-rw-r--r--spec/features/dashboard_filter_spec.rb30
4 files changed, 43 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d707c126c98..361e33eb6b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -110,6 +110,7 @@ v 8.7.0 (unreleased)
- Updated print style for issues
- Use GitHub Issue/PR number as iid to keep references
- Import GitHub labels
+ - Add option to filter by "Owned projects" on dashboard page
- Import GitHub milestones
- Fix emoji catgories in the emoji picker
- Execute system web hooks on push to the project
diff --git a/app/controllers/concerns/filter_projects.rb b/app/controllers/concerns/filter_projects.rb
index f63b703d101..586f97c5eb4 100644
--- a/app/controllers/concerns/filter_projects.rb
+++ b/app/controllers/concerns/filter_projects.rb
@@ -10,6 +10,8 @@ module FilterProjects
def filter_projects(projects)
projects = projects.search(params[:filter_projects]) if params[:filter_projects].present?
projects = projects.non_archived if params[:archived].blank?
+ projects = projects.personal(current_user) if params[:personal].present? && current_user
+
projects
end
end
diff --git a/app/views/shared/projects/_dropdown.html.haml b/app/views/shared/projects/_dropdown.html.haml
index e7e04621ff4..1169bed0382 100644
--- a/app/views/shared/projects/_dropdown.html.haml
+++ b/app/views/shared/projects/_dropdown.html.haml
@@ -1,4 +1,5 @@
- @sort ||= sort_value_recently_updated
+- personal = params[:personal]
- archived = params[:archived]
.dropdown.inline
%button.dropdown-toggle.btn{type: 'button', 'data-toggle' => 'dropdown'}
@@ -10,7 +11,7 @@
Sort by
- projects_sort_options_hash.each do |value, title|
%li
- = link_to filter_projects_path(sort: value, archived: archived), class: ("is-active" if @sort == value) do
+ = link_to filter_projects_path(sort: value, archived: archived, personal: personal), class: ("is-active" if @sort == value) do
= title
%li.divider
@@ -20,3 +21,11 @@
%li
= link_to filter_projects_path(sort: @sort, archived: true), class: ("is-active" if params[:archived].present?) do
Show archived projects
+ - if current_user
+ %li.divider
+ %li
+ = link_to filter_projects_path(sort: @sort, personal: nil), class: ("is-active" unless personal) do
+ Owned by anyone
+ %li
+ = link_to filter_projects_path(sort: @sort, personal: true), class: ("is-active" if personal) do
+ Owned by me
diff --git a/spec/features/dashboard_filter_spec.rb b/spec/features/dashboard_filter_spec.rb
new file mode 100644
index 00000000000..3d20813161a
--- /dev/null
+++ b/spec/features/dashboard_filter_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe "Dashboard projects filters", feature: true, js: true do
+
+ context 'filtering personal projects' do
+ before do
+ user = create(:user)
+ project = create(:project, name: "Victorialand", namespace: user.namespace)
+ project.team << [user, :master]
+
+ login_as(user)
+ visit dashboard_projects_path
+
+ open_filter_dropdown
+ click_link "Owned by me"
+ end
+
+ it 'filters by projects "Owned by me"' do
+ sleep 1
+ open_filter_dropdown
+ page.within('ul.dropdown-menu.dropdown-menu-align-right') do
+ expect(page).to have_css('.is-active', text: 'Owned by me')
+ end
+ end
+ end
+
+ def open_filter_dropdown
+ find('button.dropdown-toggle.btn').click
+ end
+end