summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-04-15 21:35:48 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2016-04-18 17:32:47 -0500
commitded5efad1ffddb5f1bf8585802bb25e588eee6ea (patch)
tree4316fe025a5deb0197df77a3dff40500c5651e26
parent17b60d681828567e47c8a62ef312abc46e2beeea (diff)
downloadgitlab-ce-ded5efad1ffddb5f1bf8585802bb25e588eee6ea.tar.gz
Allow filtering by Owned projects
-rw-r--r--app/controllers/concerns/filter_projects.rb5
-rw-r--r--app/views/shared/projects/_dropdown.html.haml10
-rw-r--r--features/dashboard/dashboard.feature5
-rw-r--r--features/steps/shared/issuable.rb14
4 files changed, 33 insertions, 1 deletions
diff --git a/app/controllers/concerns/filter_projects.rb b/app/controllers/concerns/filter_projects.rb
index f63b703d101..091412a7c93 100644
--- a/app/controllers/concerns/filter_projects.rb
+++ b/app/controllers/concerns/filter_projects.rb
@@ -10,6 +10,11 @@ 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?
+
+ if params[:personal].present? and current_user
+ projects = projects.personal(current_user)
+ end
+
projects
end
end
diff --git a/app/views/shared/projects/_dropdown.html.haml b/app/views/shared/projects/_dropdown.html.haml
index e7e04621ff4..681d182daee 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,10 @@
%li
= link_to filter_projects_path(sort: @sort, archived: true), class: ("is-active" if params[:archived].present?) do
Show archived projects
+ %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/features/dashboard/dashboard.feature b/features/dashboard/dashboard.feature
index db73309804c..c88cd0c9c22 100644
--- a/features/dashboard/dashboard.feature
+++ b/features/dashboard/dashboard.feature
@@ -79,3 +79,8 @@ Feature: Dashboard
And I sort the list by "Oldest updated"
And I visit project "Shop" merge requests page
Then The list should be sorted by "Oldest updated"
+
+ @javascript @focus
+ Scenario: Sort owned Projects
+ Then I filter the list by "Owned by me"
+ Then The list should be filtered by "Owned by me"
diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb
index a58b3cb7e16..c09be48080c 100644
--- a/features/steps/shared/issuable.rb
+++ b/features/steps/shared/issuable.rb
@@ -138,6 +138,20 @@ module SharedIssuable
end
end
+ step 'I filter the list by "Owned by me"' do
+ find('button.dropdown-toggle.btn').click
+
+ page.within('ul.dropdown-menu.dropdown-menu-align-right') do
+ click_link "Owned by me"
+ end
+ end
+
+ step 'The list should be filtered by "Owned by me"' do
+ page.within('ul.dropdown-menu.dropdown-menu-align-right') do
+ expect(page).to have_selector('a', text: 'Owned by me')
+ end
+ end
+
step 'I should see "1 of 1" in the sidebar' do
expect_sidebar_content('1 of 1')
end