debian-mirror-gitlab/lib/api/entities/issue.rb

64 lines
2 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class Issue < IssueBasic
include ::API::Helpers::RelatedResourcesHelpers
expose(:has_tasks) do |issue, _|
2023-04-23 21:23:45 +05:30
!issue.tasks?
2020-03-13 15:44:24 +05:30
end
expose :task_status, if: -> (issue, _) do
2023-04-23 21:23:45 +05:30
!issue.tasks?
2020-03-13 15:44:24 +05:30
end
expose :_links do
expose :self do |issue|
expose_url(api_v4_project_issue_path(id: issue.project_id, issue_iid: issue.iid))
end
expose :notes do |issue|
expose_url(api_v4_projects_issues_notes_path(id: issue.project_id, noteable_id: issue.iid))
end
expose :award_emoji do |issue|
expose_url(api_v4_projects_issues_award_emoji_path(id: issue.project_id, issue_iid: issue.iid))
end
expose :project do |issue|
expose_url(api_v4_projects_path(id: issue.project_id))
end
2022-07-23 23:45:48 +05:30
expose :closed_as_duplicate_of do |issue|
2022-08-13 15:12:31 +05:30
if issue.duplicated? && options[:current_user]&.can?(:read_issue, issue.duplicated_to)
2022-07-23 23:45:48 +05:30
expose_url(
api_v4_project_issue_path(id: issue.duplicated_to.project_id, issue_iid: issue.duplicated_to.iid)
)
end
end
2020-03-13 15:44:24 +05:30
end
expose :references, with: IssuableReferences do |issue|
issue
end
2022-06-21 17:19:12 +05:30
expose :severity,
format_with: :upcase,
documentation: { type: "String", desc: "One of #{::IssuableSeverity.severities.keys.map(&:upcase)}" }
2020-03-13 15:44:24 +05:30
# Calculating the value of subscribed field triggers Markdown
# processing. We can't do that for multiple issues / merge
# requests in a single API request.
expose :subscribed, if: -> (_, options) { options.fetch(:include_subscribed, true) } do |issue, options|
issue.subscribed?(options[:current_user], options[:project] || issue.project)
end
expose :moved_to_id
2021-02-22 17:27:13 +05:30
expose :service_desk_reply_to
2020-03-13 15:44:24 +05:30
end
end
end
2021-06-08 01:23:25 +05:30
API::Entities::Issue.prepend_mod_with('API::Entities::Issue')