2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-25 14:25:20 +00:00
|
|
|
module MilestoneActions
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def merge_requests
|
|
|
|
respond_to do |format|
|
2017-04-26 11:22:09 +00:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 14:25:20 +00:00
|
|
|
format.json do
|
|
|
|
render json: tabs_json("shared/milestones/_merge_requests_tab", {
|
2019-02-11 10:31:30 +00:00
|
|
|
merge_requests: @milestone.sorted_merge_requests(current_user), # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 14:25:20 +00:00
|
|
|
show_project_name: true
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def participants
|
|
|
|
respond_to do |format|
|
2017-04-26 11:22:09 +00:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 14:25:20 +00:00
|
|
|
format.json do
|
|
|
|
render json: tabs_json("shared/milestones/_participants_tab", {
|
2017-11-22 07:50:36 +00:00
|
|
|
users: @milestone.participants # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 14:25:20 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def labels
|
|
|
|
respond_to do |format|
|
2017-04-26 11:22:09 +00:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 14:25:20 +00:00
|
|
|
format.json do
|
|
|
|
render json: tabs_json("shared/milestones/_labels_tab", {
|
2017-11-22 07:50:36 +00:00
|
|
|
labels: @milestone.labels # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 14:25:20 +00:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tabs_json(partial, data = {})
|
|
|
|
{
|
|
|
|
html: view_to_html_string(partial, data)
|
|
|
|
}
|
|
|
|
end
|
2017-04-26 10:32:21 +00:00
|
|
|
|
2017-11-22 07:50:36 +00:00
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-26 11:22:09 +00:00
|
|
|
def milestone_redirect_path
|
2017-04-26 10:32:21 +00:00
|
|
|
if @project
|
2017-06-29 17:06:35 +00:00
|
|
|
project_milestone_path(@project, @milestone)
|
2017-06-08 16:43:05 +00:00
|
|
|
elsif @group
|
2017-04-26 10:32:21 +00:00
|
|
|
group_milestone_path(@group, @milestone.safe_title, title: @milestone.title)
|
2017-06-08 16:43:05 +00:00
|
|
|
else
|
|
|
|
dashboard_milestone_path(@milestone.safe_title, title: @milestone.title)
|
2017-04-26 10:32:21 +00:00
|
|
|
end
|
|
|
|
end
|
2017-11-22 07:50:36 +00:00
|
|
|
# rubocop:enable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 14:25:20 +00:00
|
|
|
end
|