Read about our upcoming Code of Conduct on this issue

issuable_collections_action.rb 1.26 KB
Newer Older
1
2
# frozen_string_literal: true

3
module IssuableCollectionsAction
4
  extend ActiveSupport::Concern
5
  include IssuableCollections
6
  include IssuesCalendar
7

8
  # rubocop:disable Gitlab/ModuleWithInstanceVariables
9
  def issues
10
    @issues = issuables_collection
11
12
              .non_archived
              .page(params[:page])
Tap's avatar
Tap committed
13

14
    @issuable_meta_data = issuable_meta_data(@issues, collection_type, current_user)
15

16
17
    respond_to do |format|
      format.html
18
      format.atom { render layout: 'xml.atom' }
19
20
    end
  end
21
22
23
24

  def merge_requests
    @merge_requests = issuables_collection.page(params[:page])

25
    @issuable_meta_data = issuable_meta_data(@merge_requests, collection_type, current_user)
26
  end
27
  # rubocop:enable Gitlab/ModuleWithInstanceVariables
28

29
  def issues_calendar
30
    render_issues_calendar(issuables_collection)
31
32
  end

33
34
  private

George Koltsov's avatar
George Koltsov committed
35
  def sorting_field
36
37
38
39
40
41
42
43
44
45
    case action_name
    when 'issues'
      Issue::SORTING_PREFERENCE_FIELD
    when 'merge_requests'
      MergeRequest::SORTING_PREFERENCE_FIELD
    else
      nil
    end
  end

46
  def finder_type
47
48
49
50
51
52
53
54
55
56
57
58
    case action_name
    when 'issues', 'issues_calendar'
      IssuesFinder
    when 'merge_requests'
      MergeRequestsFinder
    else
      nil
    end
  end

  def finder_options
    super.merge(non_archived: true)
59
  end
60
end