diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-28 12:08:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-28 12:08:05 +0300 |
commit | 4c788f43cbcd70bcceb4e40891d329952aa016d0 (patch) | |
tree | 9cd741579d79355a207ab74d37f26af768281fa0 /app/serializers | |
parent | 616129d41caac06a1ea0b0a36d1b3018eabac833 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/draft_note_entity.rb | 39 | ||||
-rw-r--r-- | app/serializers/draft_note_serializer.rb | 4 |
2 files changed, 43 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 diff --git a/app/serializers/draft_note_serializer.rb b/app/serializers/draft_note_serializer.rb new file mode 100644 index 00000000000..282d7f9bdda --- /dev/null +++ b/app/serializers/draft_note_serializer.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true +class DraftNoteSerializer < BaseSerializer + entity DraftNoteEntity +end |