diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-10 16:01:38 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-08-14 14:53:42 +0300 |
commit | c1f9403e45e636651010929b6113add34f8e6a8a (patch) | |
tree | 1f4dba647c4de1f43b01082c71fd70884c7ec54e /app/helpers/pagination_helper.rb | |
parent | 21a6898b10ed75f6260e72467b9e1f839d48456c (diff) |
Use Prev/Next pagination for exploring projects
This changes the pagination of the "Explore" pages so they use a simpler
pagination system that only shows "Prev" and "Next" buttons. This
removes the need for getting the total number of rows to display, a
process that can easily take up to 2 seconds when browsing through a
large list of projects.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/27390
Diffstat (limited to 'app/helpers/pagination_helper.rb')
-rw-r--r-- | app/helpers/pagination_helper.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb new file mode 100644 index 00000000000..83dd76a01dd --- /dev/null +++ b/app/helpers/pagination_helper.rb @@ -0,0 +1,21 @@ +module PaginationHelper + def paginate_collection(collection, remote: nil) + if collection.is_a?(Kaminari::PaginatableWithoutCount) + paginate_without_count(collection) + elsif collection.respond_to?(:total_pages) + paginate_with_count(collection, remote: remote) + end + end + + def paginate_without_count(collection) + render( + 'kaminari/gitlab/without_count', + previous_path: path_to_prev_page(collection), + next_path: path_to_next_page(collection) + ) + end + + def paginate_with_count(collection, remote: nil) + paginate(collection, remote: remote, theme: 'gitlab') + end +end |