2018-12-03 10:23:38 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class IssueBoardEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
|
|
|
expose :iid
|
|
|
|
expose :title
|
|
|
|
|
|
|
|
expose :confidential
|
|
|
|
expose :due_date
|
|
|
|
expose :project_id
|
|
|
|
expose :relative_position
|
2019-04-09 06:39:42 -04:00
|
|
|
expose :time_estimate
|
2020-02-24 04:08:51 -05:00
|
|
|
expose :closed do |issue|
|
|
|
|
issue.closed?
|
|
|
|
end
|
2018-12-03 10:23:38 -05:00
|
|
|
|
|
|
|
expose :project do |issue|
|
2021-06-15 17:10:04 -04:00
|
|
|
API::Entities::Project.represent issue.project, only: [:id, :path, :path_with_namespace]
|
2018-12-03 10:23:38 -05:00
|
|
|
end
|
|
|
|
|
2021-05-18 11:10:46 -04:00
|
|
|
expose :milestone, if: -> (issue) { issue.milestone } do |issue|
|
2018-12-13 12:47:50 -05:00
|
|
|
API::Entities::Milestone.represent issue.milestone, only: [:id, :title]
|
2018-12-03 10:23:38 -05:00
|
|
|
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-05-13 05:07:54 -04:00
|
|
|
Gitlab::UrlBuilder.build(issue, only_path: true)
|
2018-12-03 10:23:38 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :issue_sidebar_endpoint, if: -> (issue) { issue.project } do |issue|
|
2018-11-27 03:47:10 -05:00
|
|
|
project_issue_path(issue.project, issue, format: :json, serializer: 'sidebar_extras')
|
2018-12-03 10:23:38 -05:00
|
|
|
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
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
IssueBoardEntity.prepend_mod_with('IssueBoardEntity')
|