milestones_controller.rb 1.21 KB
Newer Older
1 2
# frozen_string_literal: true

3
class Dashboard::MilestonesController < Dashboard::ApplicationController
4 5
  include MilestoneActions

6
  before_action :projects
7
  before_action :groups, only: :index
8
  before_action :milestone, only: [:show, :merge_requests, :participants, :labels]
Douwe Maan's avatar
Douwe Maan committed
9 10

  def index
11
    respond_to do |format|
12
      format.html do
13
        @milestone_states = Milestone.states_count(@projects.select(:id), @groups.select(:id))
14 15
        @milestones = Kaminari.paginate_array(milestones).page(params[:page])
      end
16
      format.json do
17
        render json: milestones
18 19
      end
    end
Douwe Maan's avatar
Douwe Maan committed
20 21 22 23
  end

  def show
  end
24 25 26

  private

27
  def group_milestones
Jacopo's avatar
Jacopo committed
28
    DashboardGroupMilestone.build_collection(groups, params)
29 30 31 32 33 34 35
  end

  # See [#39545](https://gitlab.com/gitlab-org/gitlab-ce/issues/39545) for info about the deprecation of dynamic milestones
  def dynamic_milestones
    DashboardMilestone.build_collection(@projects, params)
  end

36
  def milestones
37
    @milestones = group_milestones + dynamic_milestones
38 39 40
  end

  def milestone
41
    @milestone = DashboardMilestone.build(@projects, params[:title])
42 43
    render_404 unless @milestone
  end
44 45

  def groups
46
    @groups ||= GroupsFinder.new(current_user, all_available: false).execute
47
  end
Douwe Maan's avatar
Douwe Maan committed
48
end