Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/serializers/draft_note_entity.rb
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/serializers/draft_note_entity.rb')
-rw-r--r--app/serializers/draft_note_entity.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/app/serializers/draft_note_entity.rb b/app/serializers/draft_note_entity.rb
new file mode 100644
index 00000000000..cab4849ebc9
--- /dev/null
+++ b/app/serializers/draft_note_entity.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+class DraftNoteEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :id
+ expose :author, using: NoteUserEntity
+ expose :merge_request_id
+ expose :position, if: -> (note, _) { note.on_diff? }
+ expose :line_code
+ expose :file_identifier_hash
+ expose :file_hash
+ expose :file_path
+ expose :note
+ expose :rendered_note, as: :note_html
+ expose :references
+ expose :discussion_id
+ expose :resolve_discussion
+ expose :noteable_type
+
+ expose :current_user do
+ expose :can_edit do |note|
+ can?(current_user, :admin_note, note)
+ end
+
+ expose :can_award_emoji do |note|
+ note.emoji_awardable?
+ end
+
+ expose :can_resolve do |note|
+ note.resolvable? && can?(current_user, :resolve_note, note)
+ end
+ end
+
+ private
+
+ def current_user
+ request.current_user
+ end
+end