From 5f6545f36cde706d1fbe7efc429b9c0d8273f96a Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 5 Sep 2017 10:22:37 +0100 Subject: Move issues index variable setting to a method This makes it easier to reuse in EE. --- app/controllers/concerns/issuable_collections.rb | 16 ++++++++++++++++ app/controllers/projects/issues_controller.rb | 15 +-------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index 23909bd2d39..0d0e53d4b76 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -10,6 +10,22 @@ module IssuableCollections private + def set_issues_index + @collection_type = "Issue" + @issues = issues_collection + @issues = @issues.page(params[:page]) + @issuable_meta_data = issuable_meta_data(@issues, @collection_type) + @total_pages = issues_page_count(@issues) + + return if redirect_out_of_range(@issues, @total_pages) + + if params[:label_name].present? + @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute + end + + @users = [] + end + def issues_collection issues_finder.execute.preload(:project, :author, :assignees, :labels, :milestone, project: :namespace) end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index ab9f132b502..8990c919ca0 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -10,6 +10,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action :check_issues_available! before_action :issue, except: [:index, :new, :create, :bulk_update] + before_action :set_issues_index, only: [:index] # Allow write(create) issue before_action :authorize_create_issue!, only: [:new, :create] @@ -23,20 +24,6 @@ class Projects::IssuesController < Projects::ApplicationController respond_to :html def index - @collection_type = "Issue" - @issues = issues_collection - @issues = @issues.page(params[:page]) - @issuable_meta_data = issuable_meta_data(@issues, @collection_type) - @total_pages = issues_page_count(@issues) - - return if redirect_out_of_range(@issues, @total_pages) - - if params[:label_name].present? - @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute - end - - @users = [] - if params[:assignee_id].present? assignee = User.find_by_id(params[:assignee_id]) @users.push(assignee) if assignee -- cgit v1.2.1