summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/serializers
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/base_discussion_entity.rb2
-rw-r--r--app/serializers/build_details_entity.rb2
-rw-r--r--app/serializers/ci/pipeline_entity.rb6
-rw-r--r--app/serializers/current_board_entity.rb2
-rw-r--r--app/serializers/merge_request_user_entity.rb12
-rw-r--r--app/serializers/merge_request_widget_entity.rb2
-rw-r--r--app/serializers/merge_requests/pipeline_entity.rb2
-rw-r--r--app/serializers/pipeline_serializer.rb5
-rw-r--r--app/serializers/test_suite_comparer_entity.rb12
-rw-r--r--app/serializers/test_suite_summary_entity.rb2
10 files changed, 36 insertions, 11 deletions
diff --git a/app/serializers/base_discussion_entity.rb b/app/serializers/base_discussion_entity.rb
index 8d4c3906847..7d3b9651b8b 100644
--- a/app/serializers/base_discussion_entity.rb
+++ b/app/serializers/base_discussion_entity.rb
@@ -40,7 +40,7 @@ class BaseDiscussionEntity < Grape::Entity
end
expose :resolve_with_issue_path do |discussion|
- new_project_issue_path(discussion.project, merge_request_to_resolve_discussions_of: discussion.noteable.iid, discussion_to_resolve: discussion.id)
+ new_project_issue_path(discussion.project, merge_request_to_resolve_discussions_of: discussion.noteable.iid, discussion_to_resolve: discussion.id) if discussion&.project&.issues_enabled?
end
end
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index ea72b2b89e7..01a8a4ebea9 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -99,7 +99,7 @@ class BuildDetailsEntity < JobEntity
end
expose :available do |build|
- project.any_runners?
+ project.any_active_runners?
end
expose :settings_path, if: -> (*) { can_admin_build? } do |build|
diff --git a/app/serializers/ci/pipeline_entity.rb b/app/serializers/ci/pipeline_entity.rb
index 86f93929a5d..743643a978f 100644
--- a/app/serializers/ci/pipeline_entity.rb
+++ b/app/serializers/ci/pipeline_entity.rb
@@ -31,7 +31,7 @@ class Ci::PipelineEntity < Grape::Entity
expose :can_cancel?, as: :cancelable
expose :failure_reason?, as: :failure_reason
expose :detached_merge_request_pipeline?, as: :detached_merge_request_pipeline
- expose :merge_request_pipeline?, as: :merge_request_pipeline
+ expose :merged_result_pipeline?, as: :merge_request_pipeline
end
expose :details do
@@ -64,8 +64,8 @@ class Ci::PipelineEntity < Grape::Entity
expose :commit, using: CommitEntity
expose :merge_request_event_type, if: -> (pipeline, _) { pipeline.merge_request? }
- expose :source_sha, if: -> (pipeline, _) { pipeline.merge_request_pipeline? }
- expose :target_sha, if: -> (pipeline, _) { pipeline.merge_request_pipeline? }
+ expose :source_sha, if: -> (pipeline, _) { pipeline.merged_result_pipeline? }
+ expose :target_sha, if: -> (pipeline, _) { pipeline.merged_result_pipeline? }
expose :yaml_errors, if: -> (pipeline, _) { pipeline.has_yaml_errors? }
expose :failure_reason, if: -> (pipeline, _) { pipeline.failure_reason? }
diff --git a/app/serializers/current_board_entity.rb b/app/serializers/current_board_entity.rb
index f9d6691dc84..08f31bc698f 100644
--- a/app/serializers/current_board_entity.rb
+++ b/app/serializers/current_board_entity.rb
@@ -3,6 +3,8 @@
class CurrentBoardEntity < Grape::Entity
expose :id
expose :name
+ expose :hide_backlog_list
+ expose :hide_closed_list
end
CurrentBoardEntity.prepend_if_ee('EE::CurrentBoardEntity')
diff --git a/app/serializers/merge_request_user_entity.rb b/app/serializers/merge_request_user_entity.rb
index edb7e10bac5..a36c4da3e83 100644
--- a/app/serializers/merge_request_user_entity.rb
+++ b/app/serializers/merge_request_user_entity.rb
@@ -4,6 +4,10 @@ class MergeRequestUserEntity < ::API::Entities::UserBasic
include UserStatusTooltip
include RequestAwareEntity
+ def self.satisfies(*methods)
+ ->(_, options) { methods.all? { |m| options[:merge_request].try(m) } }
+ end
+
expose :can_merge do |reviewer, options|
options[:merge_request]&.can_be_merged_by?(reviewer)
end
@@ -12,11 +16,17 @@ class MergeRequestUserEntity < ::API::Entities::UserBasic
request.current_user&.can?(:update_merge_request, options[:merge_request])
end
- expose :reviewed, if: -> (_, options) { options[:merge_request] && options[:merge_request].allows_reviewers? } do |reviewer, options|
+ expose :reviewed, if: satisfies(:present?, :allows_reviewers?) do |reviewer, options|
reviewer = options[:merge_request].find_reviewer(reviewer)
reviewer&.reviewed?
end
+
+ expose :approved, if: satisfies(:present?) do |user, options|
+ # This approach is preferred over MergeRequest#approved_by? since this
+ # makes one query per merge request, whereas #approved_by? makes one per user
+ options[:merge_request].approvals.any? { |app| app.user_id == user.id }
+ end
end
MergeRequestUserEntity.prepend_if_ee('EE::MergeRequestUserEntity')
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index 560dd2ea08b..3ed7d9d8914 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -157,7 +157,7 @@ class MergeRequestWidgetEntity < Grape::Entity
end
def use_merge_base_with_merged_results?
- object.actual_head_pipeline&.merge_request_event_type == :merged_result
+ object.actual_head_pipeline&.merged_result_pipeline?
end
def head_pipeline_downloadable_path_for_report_type(file_type)
diff --git a/app/serializers/merge_requests/pipeline_entity.rb b/app/serializers/merge_requests/pipeline_entity.rb
index 8b684d4641b..c7caad0e62b 100644
--- a/app/serializers/merge_requests/pipeline_entity.rb
+++ b/app/serializers/merge_requests/pipeline_entity.rb
@@ -11,7 +11,7 @@ class MergeRequests::PipelineEntity < Grape::Entity
end
expose :flags do
- expose :merge_request_pipeline?, as: :merge_request_pipeline
+ expose :merged_result_pipeline?, as: :merge_request_pipeline
end
expose :commit, using: CommitEntity
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index ab2c6dfeace..85887e64a8b 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -42,15 +42,14 @@ class PipelineSerializer < BaseSerializer
[
:cancelable_statuses,
:latest_statuses_ordered_by_stage,
- :latest_builds_report_results,
- :manual_actions,
:retryable_builds,
- :scheduled_actions,
:stages,
:latest_statuses,
:trigger_requests,
:user,
{
+ manual_actions: :metadata,
+ scheduled_actions: :metadata,
downloadable_artifacts: {
project: [:route, { namespace: :route }],
job: []
diff --git a/app/serializers/test_suite_comparer_entity.rb b/app/serializers/test_suite_comparer_entity.rb
index aab805f9598..cfa728c01be 100644
--- a/app/serializers/test_suite_comparer_entity.rb
+++ b/app/serializers/test_suite_comparer_entity.rb
@@ -34,4 +34,16 @@ class TestSuiteComparerEntity < Grape::Entity
expose :resolved_errors, using: TestCaseEntity do |suite|
suite.limited_tests.resolved_errors
end
+
+ expose :suite_errors do |suite|
+ head_suite_error = suite.head_suite.suite_error
+ base_suite_error = suite.base_suite.suite_error
+
+ next unless head_suite_error.present? || base_suite_error.present?
+
+ {
+ head: head_suite_error,
+ base: base_suite_error
+ }
+ end
end
diff --git a/app/serializers/test_suite_summary_entity.rb b/app/serializers/test_suite_summary_entity.rb
index 6718b31a7f5..228c6e499fe 100644
--- a/app/serializers/test_suite_summary_entity.rb
+++ b/app/serializers/test_suite_summary_entity.rb
@@ -4,4 +4,6 @@ class TestSuiteSummaryEntity < TestSuiteEntity
expose :build_ids do |summary|
summary.build_ids
end
+
+ expose :suite_error
end