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

70 lines
2.3 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
2021-01-03 14:25:43 +05:30
def issues
respond_to do |format|
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_issues_tab", {
2023-03-04 22:38:38 +05:30
issues: @milestone.sorted_issues(current_user), # rubocop:disable Gitlab/ModuleWithInstanceVariables
show_project_name: Gitlab::Utils.to_boolean(params[:show_project_name])
})
2021-01-03 14:25:43 +05:30
end
end
end
2017-08-17 22:00:37 +05:30
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", {
2023-03-04 22:38:38 +05:30
merge_requests: @milestone.sorted_merge_requests(current_user).preload_milestoneish_associations, # rubocop:disable Gitlab/ModuleWithInstanceVariables
show_project_name: Gitlab::Utils.to_boolean(params[:show_project_name])
})
2017-08-17 22:00:37 +05:30
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", {
2023-03-04 22:38:38 +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", {
2023-03-04 22:38:38 +05:30
labels: milestone_labels.map do |label|
label.present(issuable_subject: @milestone.resource_parent)
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
def milestone_redirect_path
2020-06-23 00:09:42 +05:30
url_for(action: :show)
2017-08-17 22:00:37 +05:30
end
end