debian-mirror-gitlab/app/serializers/project_note_entity.rb

28 lines
1.1 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
class ProjectNoteEntity < NoteEntity
2018-11-20 20:47:30 +05:30
expose :human_access, if: -> (note, _) { note.project.present? } do |note|
2018-05-09 12:01:36 +05:30
note.project.team.human_max_access(note.author_id)
end
expose :toggle_award_path, if: -> (note, _) { note.emoji_awardable? } do |note|
toggle_award_emoji_project_note_path(note.project, note.id)
end
2018-11-20 20:47:30 +05:30
expose :path, if: -> (note, _) { note.id } do |note|
2018-05-09 12:01:36 +05:30
project_note_path(note.project, note)
end
expose :resolve_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
resolve_project_merge_request_discussion_path(note.project, note.noteable, note.discussion_id)
end
expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
new_project_issue_path(note.project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id)
end
expose :delete_attachment_path, if: -> (note, _) { note.attachment? } do |note|
delete_attachment_project_note_path(note.project, note)
end
end