diff options
Diffstat (limited to 'app/serializers/merge_request_poll_widget_entity.rb')
-rw-r--r-- | app/serializers/merge_request_poll_widget_entity.rb | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/app/serializers/merge_request_poll_widget_entity.rb b/app/serializers/merge_request_poll_widget_entity.rb index 4c34da3fc88..97a81d8170f 100644 --- a/app/serializers/merge_request_poll_widget_entity.rb +++ b/app/serializers/merge_request_poll_widget_entity.rb @@ -19,19 +19,22 @@ class MergeRequestPollWidgetEntity < Grape::Entity # User entities expose :merge_user, using: UserEntity - expose :actual_head_pipeline, as: :pipeline, if: -> (mr, _) { - Feature.disabled?(:merge_request_cached_pipeline_serializer, mr.project) && presenter(mr).can_read_pipeline? + expose :merge_pipeline, if: ->(mr, _) { + Feature.disabled?(:merge_request_cached_merge_pipeline_serializer, mr.project, default_enabled: :yaml) && + mr.merged? && + can?(request.current_user, :read_pipeline, mr.target_project) } do |merge_request, options| - MergeRequests::PipelineEntity.represent(merge_request.actual_head_pipeline, options) - end - - expose :merge_pipeline, if: ->(mr, _) { mr.merged? && can?(request.current_user, :read_pipeline, mr.target_project)} do |merge_request, options| MergeRequests::PipelineEntity.represent(merge_request.merge_pipeline, options) end expose :default_merge_commit_message - expose :mergeable?, as: :mergeable + expose :mergeable do |merge_request, options| + next merge_request.mergeable? if Feature.disabled?(:check_mergeability_async_in_widget, merge_request.project, default_enabled: :yaml) + next false if options[:async_mergeability_check].present? && merge_request.checking? + + merge_request.mergeable? + end expose :default_merge_commit_message_with_description do |merge_request| merge_request.default_merge_commit_message(include_description: true) @@ -73,36 +76,6 @@ class MergeRequestPollWidgetEntity < Grape::Entity presenter(merge_request).cancel_auto_merge_path end - expose :test_reports_path do |merge_request| - if merge_request.has_test_reports? - test_reports_project_merge_request_path(merge_request.project, merge_request, format: :json) - end - end - - expose :accessibility_report_path do |merge_request| - if merge_request.has_accessibility_reports? - accessibility_reports_project_merge_request_path(merge_request.project, merge_request, format: :json) - end - end - - expose :codequality_reports_path do |merge_request| - if merge_request.has_codequality_reports? - codequality_reports_project_merge_request_path(merge_request.project, merge_request, format: :json) - end - end - - expose :terraform_reports_path do |merge_request| - if merge_request.has_terraform_reports? - terraform_reports_project_merge_request_path(merge_request.project, merge_request, format: :json) - end - end - - expose :exposed_artifacts_path do |merge_request| - if merge_request.has_exposed_artifacts? - exposed_artifacts_project_merge_request_path(merge_request.project, merge_request, format: :json) - end - end - expose :create_issue_to_resolve_discussions_path do |merge_request| presenter(merge_request).create_issue_to_resolve_discussions_path end |