diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 21:09:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-15 21:09:36 +0300 |
commit | 09093c1278f2b3347465bf5939fda215592f0d1f (patch) | |
tree | 07976e435f6c73de8faf7a4cc891ebcfacee62d1 /app/serializers | |
parent | 0d83264a7a24b33de933437355c77a4fe47e5419 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/discussion_entity.rb | 15 | ||||
-rw-r--r-- | app/serializers/merge_request_basic_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/merge_request_poll_cached_widget_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/route_entity.rb | 8 | ||||
-rw-r--r-- | app/serializers/route_serializer.rb | 5 |
5 files changed, 30 insertions, 2 deletions
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb index e302672042e..77881eaba0c 100644 --- a/app/serializers/discussion_entity.rb +++ b/app/serializers/discussion_entity.rb @@ -20,6 +20,14 @@ class DiscussionEntity < Grape::Entity discussion_path(discussion) end + expose :positions, if: -> (d, _) { display_merge_ref_discussions?(d) } do |discussion| + discussion.diff_note_positions.map(&:position) + end + + expose :line_codes, if: -> (d, _) { display_merge_ref_discussions?(d) } do |discussion| + discussion.diff_note_positions.map(&:line_code) + end + expose :individual_note?, as: :individual_note expose :resolvable do |discussion| discussion.resolvable? @@ -59,4 +67,11 @@ class DiscussionEntity < Grape::Entity def current_user request.current_user end + + def display_merge_ref_discussions?(discussion) + return unless discussion.diff_discussion? + return if discussion.legacy_diff_discussion? + + Feature.enabled?(:merge_ref_head_comments, discussion.project) + end end diff --git a/app/serializers/merge_request_basic_entity.rb b/app/serializers/merge_request_basic_entity.rb index 973e971b4c0..82baf4a4a78 100644 --- a/app/serializers/merge_request_basic_entity.rb +++ b/app/serializers/merge_request_basic_entity.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class MergeRequestBasicEntity < Grape::Entity - expose :merge_status + expose :public_merge_status, as: :merge_status expose :merge_error expose :state expose :source_branch_exists?, as: :source_branch_exists diff --git a/app/serializers/merge_request_poll_cached_widget_entity.rb b/app/serializers/merge_request_poll_cached_widget_entity.rb index 2f8eb6650e8..72f629b3507 100644 --- a/app/serializers/merge_request_poll_cached_widget_entity.rb +++ b/app/serializers/merge_request_poll_cached_widget_entity.rb @@ -6,7 +6,7 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity expose :merge_commit_sha expose :short_merge_commit_sha expose :merge_error - expose :merge_status + expose :public_merge_status, as: :merge_status expose :merge_user_id expose :source_branch expose :source_project_id diff --git a/app/serializers/route_entity.rb b/app/serializers/route_entity.rb new file mode 100644 index 00000000000..158fda5e00e --- /dev/null +++ b/app/serializers/route_entity.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class RouteEntity < Grape::Entity + expose :id + expose :source_id + expose :source_type + expose :path +end diff --git a/app/serializers/route_serializer.rb b/app/serializers/route_serializer.rb new file mode 100644 index 00000000000..0b187588301 --- /dev/null +++ b/app/serializers/route_serializer.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class RouteSerializer < BaseSerializer + entity RouteEntity +end |