debian-mirror-gitlab/app/controllers/concerns/milestone_actions.rb

66 lines
1.9 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module MilestoneActions
extend ActiveSupport::Concern
def merge_requests
respond_to do |format|
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_merge_requests_tab", {
2019-03-13 22:55:13 +05:30
merge_requests: @milestone.sorted_merge_requests(current_user), # rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
show_project_name: true
})
end
end
end
def participants
respond_to do |format|
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_participants_tab", {
2019-09-30 23:59:55 +05:30
users: @milestone.issue_participants_visible_by_user(current_user) # rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
})
end
end
end
2019-07-31 22:56:46 +05:30
# rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
def labels
respond_to do |format|
format.html { redirect_to milestone_redirect_path }
format.json do
2019-07-31 22:56:46 +05:30
milestone_labels = @milestone.issue_labels_visible_by_user(current_user)
2017-08-17 22:00:37 +05:30
render json: tabs_json("shared/milestones/_labels_tab", {
2019-07-31 22:56:46 +05:30
labels: milestone_labels.map do |label|
2019-12-21 20:55:43 +05:30
label.present(issuable_subject: @milestone.resource_parent)
2019-07-31 22:56:46 +05:30
end
2017-08-17 22:00:37 +05:30
})
end
end
end
2019-07-31 22:56:46 +05:30
# rubocop:enable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
private
def tabs_json(partial, data = {})
{
html: view_to_html_string(partial, data)
}
end
2018-03-17 18:26:18 +05:30
# rubocop:disable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
def milestone_redirect_path
if @project
2017-09-10 17:25:29 +05:30
project_milestone_path(@project, @milestone)
elsif @group
2017-08-17 22:00:37 +05:30
group_milestone_path(@group, @milestone.safe_title, title: @milestone.title)
2017-09-10 17:25:29 +05:30
else
dashboard_milestone_path(@milestone.safe_title, title: @milestone.title)
2017-08-17 22:00:37 +05:30
end
end
2018-03-17 18:26:18 +05:30
# rubocop:enable Gitlab/ModuleWithInstanceVariables
2017-08-17 22:00:37 +05:30
end