gitlab-org--gitlab-foss/app/controllers/concerns/milestone_actions.rb

64 lines
1.8 KiB
Ruby
Raw Normal View History

# 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", {
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", {
users: @milestone.issue_participants_visible_by_user(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-04-25 10:25:20 -04:00
})
end
end
end
# 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
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", {
labels: milestone_labels.map do |label|
label.present(issuable_subject: @milestone.resource_parent)
end
2017-04-25 10:25:20 -04:00
})
end
end
end
# 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
# rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-04-26 07:22:09 -04:00
def milestone_redirect_path
if @milestone.global_milestone?
url_for(action: :show, title: @milestone.title)
else
url_for(action: :show)
2017-04-26 06:32:21 -04:00
end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
2017-04-25 10:25:20 -04:00
end