2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-25 10:25:20 -04:00
|
|
|
module MilestoneActions
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
def merge_requests
|
|
|
|
respond_to do |format|
|
2017-04-26 07:22:09 -04:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 10:25:20 -04:00
|
|
|
format.json do
|
|
|
|
render json: tabs_json("shared/milestones/_merge_requests_tab", {
|
2019-02-11 05:31:30 -05:00
|
|
|
merge_requests: @milestone.sorted_merge_requests(current_user), # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 10:25:20 -04:00
|
|
|
show_project_name: true
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def participants
|
|
|
|
respond_to do |format|
|
2017-04-26 07:22:09 -04:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 10:25:20 -04:00
|
|
|
format.json do
|
|
|
|
render json: tabs_json("shared/milestones/_participants_tab", {
|
2019-09-06 14:46:51 -04:00
|
|
|
users: @milestone.issue_participants_visible_by_user(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 10:25:20 -04:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-14 07:16:30 -04:00
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 10:25:20 -04:00
|
|
|
def labels
|
|
|
|
respond_to do |format|
|
2017-04-26 07:22:09 -04:00
|
|
|
format.html { redirect_to milestone_redirect_path }
|
2017-04-25 10:25:20 -04:00
|
|
|
format.json do
|
2019-05-14 07:16:30 -04:00
|
|
|
milestone_labels = @milestone.issue_labels_visible_by_user(current_user)
|
|
|
|
|
2017-04-25 10:25:20 -04:00
|
|
|
render json: tabs_json("shared/milestones/_labels_tab", {
|
2019-05-14 07:16:30 -04:00
|
|
|
labels: milestone_labels.map do |label|
|
2019-10-17 08:07:33 -04:00
|
|
|
label.present(issuable_subject: @milestone.resource_parent)
|
2019-05-14 07:16:30 -04:00
|
|
|
end
|
2017-04-25 10:25:20 -04:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-05-14 07:16:30 -04:00
|
|
|
# rubocop:enable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 10:25:20 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tabs_json(partial, data = {})
|
|
|
|
{
|
|
|
|
html: view_to_html_string(partial, data)
|
|
|
|
}
|
|
|
|
end
|
2017-04-26 06:32:21 -04:00
|
|
|
|
2017-11-22 02:50:36 -05:00
|
|
|
# rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2017-04-26 07:22:09 -04:00
|
|
|
def milestone_redirect_path
|
2019-11-07 16:06:14 -05:00
|
|
|
if @milestone.global_milestone?
|
|
|
|
url_for(action: :show, title: @milestone.title)
|
2017-06-08 12:43:05 -04:00
|
|
|
else
|
2019-11-07 16:06:14 -05:00
|
|
|
url_for(action: :show)
|
2017-04-26 06:32:21 -04:00
|
|
|
end
|
|
|
|
end
|
2017-11-22 02:50:36 -05:00
|
|
|
# rubocop:enable Gitlab/ModuleWithInstanceVariables
|
2017-04-25 10:25:20 -04:00
|
|
|
end
|