Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-01-29 18:22:58 +0300
committerJan Provaznik <jprovaznik@gitlab.com>2018-01-30 17:43:44 +0300
commitb02a6bed85000db63189b68fe8ce6154c283bc39 (patch)
tree5c23232cf1db3527ae2499a12628f4293ba48e5e /app/controllers/concerns
parent501d81c523b2cf53128e62ea2d7c4dff6681928d (diff)
Make pagination optional for issuables
On epics roadmap page we list all epics in the given time frame without pagination (at least for the first iteration), in this case it would be nice to use the existing issuables index logic except pagination (see MR gitlab-ee!4281). For this reason this patch allows to easily disable pagination. Related gitlab-ee!4281
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r--app/controllers/concerns/issuable_collections.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index b25e753a5ad..2fa0f98e344 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -12,11 +12,9 @@ module IssuableCollections
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def set_issuables_index
- @issuables = issuables_collection
- @issuables = @issuables.page(params[:page])
- @issuable_meta_data = issuable_meta_data(@issuables, collection_type)
- @total_pages = issuable_page_count
+ @issuables = issuables_collection
+ set_pagination
return if redirect_out_of_range(@total_pages)
if params[:label_name].present?
@@ -35,14 +33,26 @@ module IssuableCollections
@users.push(author) if author
end
end
+
+ def set_pagination
+ return if pagination_disabled?
+
+ @issuables = @issuables.page(params[:page])
+ @issuable_meta_data = issuable_meta_data(@issuables, collection_type)
+ @total_pages = issuable_page_count
+ end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
+ def pagination_disabled?
+ false
+ end
+
def issuables_collection
finder.execute.preload(preload_for_collection)
end
def redirect_out_of_range(total_pages)
- return false if total_pages.zero?
+ return false if total_pages.nil? || total_pages.zero?
out_of_range = @issuables.current_page > total_pages # rubocop:disable Gitlab/ModuleWithInstanceVariables