2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class IssueBoardEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
format_with(:upcase) do |item|
|
|
|
|
item.try(:upcase)
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
expose :id
|
|
|
|
expose :iid
|
|
|
|
expose :title
|
|
|
|
|
|
|
|
expose :confidential
|
|
|
|
expose :due_date
|
|
|
|
expose :project_id
|
|
|
|
expose :relative_position
|
2019-07-31 22:56:46 +05:30
|
|
|
expose :time_estimate
|
2020-04-08 14:13:33 +05:30
|
|
|
expose :closed do |issue|
|
|
|
|
issue.closed?
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
expose :project do |issue|
|
2021-09-04 01:27:46 +05:30
|
|
|
API::Entities::Project.represent issue.project, only: [:id, :path, :path_with_namespace]
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
expose :milestone, if: -> (issue) { issue.milestone } do |issue|
|
2019-02-15 15:39:39 +05:30
|
|
|
API::Entities::Milestone.represent issue.milestone, only: [:id, :title]
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :assignees do |issue|
|
|
|
|
API::Entities::UserBasic.represent issue.assignees, only: [:id, :name, :username, :avatar_url]
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :labels do |issue|
|
|
|
|
LabelEntity.represent issue.labels, project: issue.project, only: [:id, :title, :description, :color, :priority, :text_color]
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :reference_path, if: -> (issue) { issue.project } do |issue, options|
|
|
|
|
options[:include_full_project_path] ? issue.to_reference(full: true) : issue.to_reference
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :real_path, if: -> (issue) { issue.project } do |issue|
|
2022-07-16 23:28:13 +05:30
|
|
|
Gitlab::UrlBuilder.build(issue, only_path: true)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
expose :issue_sidebar_endpoint, if: -> (issue) { issue.project } do |issue|
|
|
|
|
project_issue_path(issue.project, issue, format: :json, serializer: 'sidebar_extras')
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :toggle_subscription_endpoint, if: -> (issue) { issue.project } do |issue|
|
|
|
|
toggle_subscription_project_issue_path(issue.project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :assignable_labels_endpoint, if: -> (issue) { issue.project } do |issue|
|
|
|
|
project_labels_path(issue.project, format: :json, include_ancestor_groups: true)
|
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
expose :issue_type,
|
|
|
|
as: :type,
|
|
|
|
format_with: :upcase,
|
|
|
|
documentation: { type: "String", desc: "One of #{::WorkItems::Type.base_types.keys.map(&:upcase)}" }
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
IssueBoardEntity.prepend_mod_with('IssueBoardEntity')
|