summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps <info@camilstaps.nl>2019-01-28 18:51:49 +0100
committerCamil Staps <info@camilstaps.nl>2019-08-07 20:49:15 +0200
commita052f68116363109b5d49c9738e711a12257ac7d (patch)
tree4142b923ae57edf3e997501b8ca80955a02f7921
parent6baff6504b234e209a5e1d78349dbd2589d5d7e8 (diff)
downloadgitlab-ce-a052f68116363109b5d49c9738e711a12257ac7d.tar.gz
Add pagination to {project}/starrers view
-rw-r--r--app/controllers/projects/starrers_controller.rb8
-rw-r--r--app/finders/users_star_projects_finder.rb9
-rw-r--r--app/helpers/projects_helper.rb5
-rw-r--r--app/helpers/users_helper.rb5
-rw-r--r--app/views/projects/starrers/index.html.haml5
5 files changed, 12 insertions, 20 deletions
diff --git a/app/controllers/projects/starrers_controller.rb b/app/controllers/projects/starrers_controller.rb
index 6ca49fceff6..ac105faa550 100644
--- a/app/controllers/projects/starrers_controller.rb
+++ b/app/controllers/projects/starrers_controller.rb
@@ -6,14 +6,12 @@ class Projects::StarrersController < Projects::ApplicationController
# Authorize
before_action :require_non_empty_project
- # rubocop: disable CodeReuse/ActiveRecord
def index
@sort = params[:sort].presence || sort_value_name
- params[:project] = @project
-
@starrers = UsersStarProjectsFinder.new(params).execute
- @starrers = @starrers.sort_by_attribute(@sort)
+ @starrers = @starrers.by_project(@project)
+
+ @starrers = @starrers.sort_by_attribute(@sort).page(params[:page])
end
- # rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/users_star_projects_finder.rb b/app/finders/users_star_projects_finder.rb
index 66b83fa8f8e..5a031a1f0cd 100644
--- a/app/finders/users_star_projects_finder.rb
+++ b/app/finders/users_star_projects_finder.rb
@@ -12,7 +12,6 @@ class UsersStarProjectsFinder
def execute
stars = UsersStarProject.all.order_id_desc
stars = by_search(stars)
- stars = by_project(stars)
stars
end
@@ -20,12 +19,6 @@ class UsersStarProjectsFinder
private
def by_search(items)
- return items unless params[:search].present?
-
- items.search(params[:search])
- end
-
- def by_project(items)
- params[:project].present? ? items.by_project(params[:project]) : items
+ params[:search].present? ? items.search(params[:search]) : items
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 8d0079a4dd3..71c9c121e48 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -601,6 +601,11 @@ module ProjectsHelper
end
end
+ def filter_starrer_path(options = {})
+ options = params.slice(:sort).merge(options).permit!
+ "#{request.path}?#{options.to_param}"
+ end
+
def sidebar_projects_paths
%w[
projects#show
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 7e8edc19a38..e38e3378e07 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -108,9 +108,4 @@ module UsersHelper
items
end
-
- def filter_user_path(options = {})
- options = params.slice(:sort).merge(options).permit!
- "#{request.path}?#{options.to_param}"
- end
end
diff --git a/app/views/projects/starrers/index.html.haml b/app/views/projects/starrers/index.html.haml
index 662da94107a..3d39331ec62 100644
--- a/app/views/projects/starrers/index.html.haml
+++ b/app/views/projects/starrers/index.html.haml
@@ -4,7 +4,7 @@
.nav-text
%span.flex-project-title
= _("Starrers of <strong>%{project_name}</strong>").html_safe % { project_name: sanitize_project_name(@project.name) }
- %span.badge.badge-pill= @starrers.size
+ %span.badge.badge-pill= @starrers.total_count
- if @starrers.size > 0
.nav-controls
= form_tag request.original_url, method: :get, class: 'form-inline user-search-form flex-users-form' do
@@ -20,10 +20,11 @@
= _("Sort by")
- starrers_sort_options_hash.each do |value, title|
%li
- = link_to filter_user_path(sort: value), class: ("is-active" if @sort == value) do
+ = link_to filter_starrer_path(sort: value), class: ("is-active" if @sort == value) do
= title
- if @starrers.size > 0
.row.prepend-top-10
= render partial: 'starrer', collection: @starrers, as: :starrer
+ = paginate @starrers, theme: 'gitlab'
- else
.nothing-here-block Nobody has starred this repository yet