2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-18 21:19:04 -05:00
|
|
|
class IssueEntity < IssuableEntity
|
2017-11-01 13:35:14 -04:00
|
|
|
include TimeTrackableEntity
|
2019-09-13 09:26:31 -04:00
|
|
|
prepend_if_ee('::EE::IssueEntity') # rubocop: disable Cop/InjectEnterpriseEditionModule
|
2017-05-17 08:01:24 -04:00
|
|
|
|
2017-11-01 13:35:14 -04:00
|
|
|
expose :state
|
2017-12-07 16:56:59 -05:00
|
|
|
expose :milestone_id
|
|
|
|
expose :updated_by_id
|
|
|
|
expose :created_at
|
|
|
|
expose :updated_at
|
|
|
|
expose :milestone, using: API::Entities::Milestone
|
|
|
|
expose :labels, using: LabelEntity
|
|
|
|
expose :lock_version
|
|
|
|
expose :author_id
|
2016-11-18 21:19:04 -05:00
|
|
|
expose :confidential
|
2017-09-14 09:22:18 -04:00
|
|
|
expose :discussion_locked
|
2017-05-04 08:11:15 -04:00
|
|
|
expose :assignees, using: API::Entities::UserBasic
|
2016-11-18 21:19:04 -05:00
|
|
|
expose :due_date
|
|
|
|
expose :project_id
|
2017-05-17 08:01:24 -04:00
|
|
|
|
2019-07-10 16:04:02 -04:00
|
|
|
expose :moved_to_id do |issue|
|
2019-09-13 09:26:31 -04:00
|
|
|
if issue.moved? && can?(request.current_user, :read_issue, issue.moved_to)
|
2019-07-10 16:04:02 -04:00
|
|
|
issue.moved_to_id
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :duplicated_to_id do |issue|
|
|
|
|
if issue.duplicated? && can?(request.current_user, :read_issue, issue.duplicated_to)
|
|
|
|
issue.duplicated_to_id
|
|
|
|
end
|
2019-07-10 16:04:02 -04:00
|
|
|
end
|
|
|
|
|
2017-05-25 06:20:52 -04:00
|
|
|
expose :web_url do |issue|
|
2017-06-29 13:06:35 -04:00
|
|
|
project_issue_path(issue.project, issue)
|
2017-05-17 08:01:24 -04:00
|
|
|
end
|
2017-06-23 18:10:05 -04:00
|
|
|
|
|
|
|
expose :current_user do
|
|
|
|
expose :can_create_note do |issue|
|
2017-09-07 11:14:21 -04:00
|
|
|
can?(request.current_user, :create_note, issue)
|
2017-06-23 18:10:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :can_update do |issue|
|
|
|
|
can?(request.current_user, :update_issue, issue)
|
|
|
|
end
|
2018-04-06 14:19:37 -04:00
|
|
|
|
|
|
|
expose :can_award_emoji do |issue|
|
|
|
|
can?(request.current_user, :award_emoji, issue)
|
|
|
|
end
|
2017-06-23 18:10:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :create_note_path do |issue|
|
2017-08-11 07:53:51 -04:00
|
|
|
project_notes_path(issue.project, target_type: 'issue', target_id: issue.id)
|
2017-06-23 18:10:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expose :preview_note_path do |issue|
|
2019-04-04 09:08:34 -04:00
|
|
|
preview_markdown_path(issue.project, target_type: 'Issue', target_id: issue.iid)
|
2017-06-23 18:10:05 -04:00
|
|
|
end
|
2019-06-06 06:37:02 -04:00
|
|
|
|
|
|
|
expose :confidential_issues_docs_path, if: -> (issue) { issue.confidential? } do |issue|
|
|
|
|
help_page_path('user/project/issues/confidential_issues.md')
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :locked_discussion_docs_path, if: -> (issue) { issue.discussion_locked? } do |issue|
|
|
|
|
help_page_path('user/discussions/index.md', anchor: 'lock-discussions')
|
|
|
|
end
|
2019-12-13 19:08:27 -05:00
|
|
|
|
|
|
|
expose :is_project_archived do |issue|
|
|
|
|
issue.project.archived?
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :archived_project_docs_path, if: -> (issue) { issue.project.archived? } do |issue|
|
|
|
|
help_page_path('user/project/settings/index.md', anchor: 'archiving-a-project')
|
|
|
|
end
|
2016-11-18 21:19:04 -05:00
|
|
|
end
|