summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/README.md4
-rw-r--r--app/serializers/build_details_entity.rb4
-rw-r--r--app/serializers/ci/trigger_entity.rb42
-rw-r--r--app/serializers/ci/trigger_serializer.rb7
-rw-r--r--app/serializers/cluster_entity.rb2
-rw-r--r--app/serializers/cluster_serializer.rb1
-rw-r--r--app/serializers/container_repository_entity.rb1
-rw-r--r--app/serializers/deployment_entity.rb1
-rw-r--r--app/serializers/diff_file_base_entity.rb14
-rw-r--r--app/serializers/diffs_entity.rb4
-rw-r--r--app/serializers/discussion_entity.rb5
-rw-r--r--app/serializers/feature_flag_entity.rb48
-rw-r--r--app/serializers/feature_flag_scope_entity.rb12
-rw-r--r--app/serializers/feature_flag_serializer.rb10
-rw-r--r--app/serializers/feature_flag_summary_entity.rb19
-rw-r--r--app/serializers/feature_flag_summary_serializer.rb5
-rw-r--r--app/serializers/feature_flags/scope_entity.rb8
-rw-r--r--app/serializers/feature_flags/strategy_entity.rb11
-rw-r--r--app/serializers/feature_flags/user_list_entity.rb10
-rw-r--r--app/serializers/feature_flags_client_entity.rb7
-rw-r--r--app/serializers/feature_flags_client_serializer.rb9
-rw-r--r--app/serializers/group_group_link_entity.rb24
-rw-r--r--app/serializers/import/bulk_import_entity.rb15
-rw-r--r--app/serializers/label_entity.rb2
-rw-r--r--app/serializers/label_serializer.rb2
-rw-r--r--app/serializers/merge_request_basic_entity.rb1
-rw-r--r--app/serializers/merge_request_poll_cached_widget_entity.rb12
-rw-r--r--app/serializers/merge_request_poll_widget_entity.rb16
-rw-r--r--app/serializers/merge_request_widget_entity.rb26
-rw-r--r--app/serializers/paginated_diff_entity.rb2
-rw-r--r--app/serializers/pipeline_entity.rb4
-rw-r--r--app/serializers/pipeline_serializer.rb10
-rw-r--r--app/serializers/test_case_entity.rb1
33 files changed, 303 insertions, 36 deletions
diff --git a/app/serializers/README.md b/app/serializers/README.md
index 2cbe6f9d263..89721f572e0 100644
--- a/app/serializers/README.md
+++ b/app/serializers/README.md
@@ -47,11 +47,11 @@ representation. It rarely happens that a serialization entity exists without
a corresponding domain model class. As an example, we have an `Issue` class and
a corresponding `IssueSerializer`.
-Serialization entites are designed to reuse other serialization entities, which
+Serialization entities are designed to reuse other serialization entities, which
is a convenient way to create a multi-level JSON representation of a piece of
a domain model you want to serialize.
-See [documentation for Grape Entites][grape-entity-readme] for more details.
+See [documentation for Grape Entities][grape-entity-readme] for more details.
## How to implement a serializer?
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 2b8522539b4..109213ab729 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -35,7 +35,7 @@ class BuildDetailsEntity < JobEntity
browse_project_job_artifacts_path(project, build)
end
- expose :keep_path, if: -> (*) { (build.locked_artifacts? || build.has_expiring_archive_artifacts?) && can?(current_user, :update_build, build) } do |build|
+ expose :keep_path, if: -> (*) { (build.has_expired_locked_archive_artifacts? || build.has_expiring_archive_artifacts?) && can?(current_user, :update_build, build) } do |build|
keep_project_job_artifacts_path(project, build)
end
@@ -133,7 +133,7 @@ class BuildDetailsEntity < JobEntity
def callout_message
return super unless build.failure_reason.to_sym == :missing_dependency_failure
- docs_url = "https://docs.gitlab.com/ce/ci/yaml/README.html#dependencies"
+ docs_url = "https://docs.gitlab.com/ee/ci/yaml/README.html#dependencies"
[
failure_message.html_safe,
diff --git a/app/serializers/ci/trigger_entity.rb b/app/serializers/ci/trigger_entity.rb
new file mode 100644
index 00000000000..005a9b752ed
--- /dev/null
+++ b/app/serializers/ci/trigger_entity.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+module Ci
+ class TriggerEntity < Grape::Entity
+ include Gitlab::Routing
+ include Gitlab::Allowable
+
+ expose :description
+ expose :owner, using: UserEntity
+ expose :last_used
+
+ expose :token do |trigger|
+ can_admin_trigger?(trigger) ? trigger.token : trigger.short_token
+ end
+
+ expose :has_token_exposed do |trigger|
+ can_admin_trigger?(trigger)
+ end
+
+ expose :can_access_project do |trigger|
+ trigger.can_access_project?
+ end
+
+ expose :project_trigger_path, if: -> (trigger) { can_manage_trigger?(trigger) } do |trigger|
+ project_trigger_path(options[:project], trigger)
+ end
+
+ expose :edit_project_trigger_path, if: -> (trigger) { can_admin_trigger?(trigger) } do |trigger|
+ edit_project_trigger_path(options[:project], trigger)
+ end
+
+ private
+
+ def can_manage_trigger?(trigger)
+ can?(options[:current_user], :manage_trigger, trigger)
+ end
+
+ def can_admin_trigger?(trigger)
+ can?(options[:current_user], :admin_trigger, trigger)
+ end
+ end
+end
diff --git a/app/serializers/ci/trigger_serializer.rb b/app/serializers/ci/trigger_serializer.rb
new file mode 100644
index 00000000000..8e42ec12c3f
--- /dev/null
+++ b/app/serializers/ci/trigger_serializer.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module Ci
+ class TriggerSerializer < BaseSerializer
+ entity ::Ci::TriggerEntity
+ end
+end
diff --git a/app/serializers/cluster_entity.rb b/app/serializers/cluster_entity.rb
index eea0acdc11b..b904666971e 100644
--- a/app/serializers/cluster_entity.rb
+++ b/app/serializers/cluster_entity.rb
@@ -6,6 +6,8 @@ class ClusterEntity < Grape::Entity
expose :cluster_type
expose :enabled
expose :environment_scope
+ expose :id
+ expose :namespace_per_environment
expose :name
expose :nodes
expose :provider_type
diff --git a/app/serializers/cluster_serializer.rb b/app/serializers/cluster_serializer.rb
index 700a46040e3..f71591612a6 100644
--- a/app/serializers/cluster_serializer.rb
+++ b/app/serializers/cluster_serializer.rb
@@ -12,6 +12,7 @@ class ClusterSerializer < BaseSerializer
:environment_scope,
:gitlab_managed_apps_logs_path,
:enable_advanced_logs_querying,
+ :id,
:kubernetes_errors,
:name,
:nodes,
diff --git a/app/serializers/container_repository_entity.rb b/app/serializers/container_repository_entity.rb
index 4c87d1438b0..9a002971bef 100644
--- a/app/serializers/container_repository_entity.rb
+++ b/app/serializers/container_repository_entity.rb
@@ -4,6 +4,7 @@ class ContainerRepositoryEntity < Grape::Entity
include RequestAwareEntity
expose :id, :name, :path, :location, :created_at, :status, :tags_count
+ expose :expiration_policy_started_at, as: :cleanup_policy_started_at
expose :tags_path do |repository|
project_registry_repository_tags_path(project, repository, format: :json)
diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb
index dc7c4654208..a37011d0100 100644
--- a/app/serializers/deployment_entity.rb
+++ b/app/serializers/deployment_entity.rb
@@ -17,6 +17,7 @@ class DeploymentEntity < Grape::Entity
end
end
+ expose :status
expose :created_at
expose :deployed_at
expose :tag
diff --git a/app/serializers/diff_file_base_entity.rb b/app/serializers/diff_file_base_entity.rb
index 9f27191c3c8..596f5d686da 100644
--- a/app/serializers/diff_file_base_entity.rb
+++ b/app/serializers/diff_file_base_entity.rb
@@ -34,7 +34,7 @@ class DiffFileBaseEntity < Grape::Entity
expose :edit_path, if: -> (_, options) { options[:merge_request] } do |diff_file|
merge_request = options[:merge_request]
- next unless merge_request.merged? || merge_request.source_branch_exists?
+ next unless has_edit_path?(merge_request)
target_project, target_branch = edit_project_branch_options(merge_request)
@@ -43,6 +43,14 @@ class DiffFileBaseEntity < Grape::Entity
project_edit_blob_path(target_project, tree_join(target_branch, diff_file.new_path), options)
end
+ expose :ide_edit_path, if: -> (_, options) { options[:merge_request] } do |diff_file|
+ merge_request = options[:merge_request]
+
+ next unless has_edit_path?(merge_request)
+
+ gitlab_ide_merge_request_path(merge_request)
+ end
+
expose :old_path_html do |diff_file|
old_path, _ = mark_inline_diffs(diff_file.old_path, diff_file.new_path)
old_path
@@ -125,4 +133,8 @@ class DiffFileBaseEntity < Grape::Entity
[merge_request.target_project, merge_request.target_branch]
end
end
+
+ def has_edit_path?(merge_request)
+ merge_request.merged? || merge_request.source_branch_exists?
+ end
end
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index 6ef524b5bec..0b4f21c55f4 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -78,7 +78,7 @@ class DiffsEntity < Grape::Entity
options[:merge_request_diffs]
end
- expose :definition_path_prefix, if: -> (diff_file) { Feature.enabled?(:code_navigation, merge_request.project, default_enabled: true) } do |diffs|
+ expose :definition_path_prefix do |diffs|
project_blob_path(merge_request.project, diffs.diff_refs&.head_sha)
end
@@ -89,8 +89,6 @@ class DiffsEntity < Grape::Entity
private
def code_navigation_path(diffs)
- return unless Feature.enabled?(:code_navigation, merge_request.project, default_enabled: true)
-
Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs&.head_sha)
end
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb
index 2957205a81c..497471699b2 100644
--- a/app/serializers/discussion_entity.rb
+++ b/app/serializers/discussion_entity.rb
@@ -69,9 +69,6 @@ class DiscussionEntity < Grape::Entity
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, default_enabled: true)
+ discussion.diff_discussion? && !discussion.legacy_diff_discussion?
end
end
diff --git a/app/serializers/feature_flag_entity.rb b/app/serializers/feature_flag_entity.rb
new file mode 100644
index 00000000000..80cf869a389
--- /dev/null
+++ b/app/serializers/feature_flag_entity.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+class FeatureFlagEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :id
+ expose :iid
+ expose :active
+ expose :created_at
+ expose :updated_at
+ expose :name
+ expose :description
+ expose :version
+
+ expose :edit_path, if: -> (feature_flag, _) { can_update?(feature_flag) } do |feature_flag|
+ edit_project_feature_flag_path(feature_flag.project, feature_flag)
+ end
+
+ expose :update_path, if: -> (feature_flag, _) { can_update?(feature_flag) } do |feature_flag|
+ project_feature_flag_path(feature_flag.project, feature_flag)
+ end
+
+ expose :destroy_path, if: -> (feature_flag, _) { can_destroy?(feature_flag) } do |feature_flag|
+ project_feature_flag_path(feature_flag.project, feature_flag)
+ end
+
+ expose :scopes, with: FeatureFlagScopeEntity do |feature_flag|
+ feature_flag.scopes.sort_by(&:id)
+ end
+
+ expose :strategies, with: FeatureFlags::StrategyEntity do |feature_flag|
+ feature_flag.strategies.sort_by(&:id)
+ end
+
+ private
+
+ def can_update?(feature_flag)
+ can?(current_user, :update_feature_flag, feature_flag)
+ end
+
+ def can_destroy?(feature_flag)
+ can?(current_user, :destroy_feature_flag, feature_flag)
+ end
+
+ def current_user
+ request.current_user
+ end
+end
diff --git a/app/serializers/feature_flag_scope_entity.rb b/app/serializers/feature_flag_scope_entity.rb
new file mode 100644
index 00000000000..0450797a545
--- /dev/null
+++ b/app/serializers/feature_flag_scope_entity.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class FeatureFlagScopeEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :id
+ expose :active
+ expose :environment_scope
+ expose :created_at
+ expose :updated_at
+ expose :strategies
+end
diff --git a/app/serializers/feature_flag_serializer.rb b/app/serializers/feature_flag_serializer.rb
new file mode 100644
index 00000000000..e0ff33cc61a
--- /dev/null
+++ b/app/serializers/feature_flag_serializer.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class FeatureFlagSerializer < BaseSerializer
+ include WithPagination
+ entity FeatureFlagEntity
+
+ def represent(resource, opts = {})
+ super(resource, opts)
+ end
+end
diff --git a/app/serializers/feature_flag_summary_entity.rb b/app/serializers/feature_flag_summary_entity.rb
new file mode 100644
index 00000000000..be4f02dabca
--- /dev/null
+++ b/app/serializers/feature_flag_summary_entity.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class FeatureFlagSummaryEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :count do
+ expose :all do |project|
+ project.operations_feature_flags.count
+ end
+
+ expose :enabled do |project|
+ project.operations_feature_flags.enabled.count
+ end
+
+ expose :disabled do |project|
+ project.operations_feature_flags.disabled.count
+ end
+ end
+end
diff --git a/app/serializers/feature_flag_summary_serializer.rb b/app/serializers/feature_flag_summary_serializer.rb
new file mode 100644
index 00000000000..46f70666e40
--- /dev/null
+++ b/app/serializers/feature_flag_summary_serializer.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class FeatureFlagSummarySerializer < BaseSerializer
+ entity FeatureFlagSummaryEntity
+end
diff --git a/app/serializers/feature_flags/scope_entity.rb b/app/serializers/feature_flags/scope_entity.rb
new file mode 100644
index 00000000000..1c9dd491652
--- /dev/null
+++ b/app/serializers/feature_flags/scope_entity.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+module FeatureFlags
+ class ScopeEntity < Grape::Entity
+ expose :id
+ expose :environment_scope
+ end
+end
diff --git a/app/serializers/feature_flags/strategy_entity.rb b/app/serializers/feature_flags/strategy_entity.rb
new file mode 100644
index 00000000000..73450476869
--- /dev/null
+++ b/app/serializers/feature_flags/strategy_entity.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module FeatureFlags
+ class StrategyEntity < Grape::Entity
+ expose :id
+ expose :name
+ expose :parameters
+ expose :scopes, with: FeatureFlags::ScopeEntity
+ expose :user_list, with: FeatureFlags::UserListEntity, expose_nil: false
+ end
+end
diff --git a/app/serializers/feature_flags/user_list_entity.rb b/app/serializers/feature_flags/user_list_entity.rb
new file mode 100644
index 00000000000..d3fddb4fa7a
--- /dev/null
+++ b/app/serializers/feature_flags/user_list_entity.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+module FeatureFlags
+ class UserListEntity < Grape::Entity
+ expose :id
+ expose :iid
+ expose :name
+ expose :user_xids
+ end
+end
diff --git a/app/serializers/feature_flags_client_entity.rb b/app/serializers/feature_flags_client_entity.rb
new file mode 100644
index 00000000000..4a195c7d759
--- /dev/null
+++ b/app/serializers/feature_flags_client_entity.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class FeatureFlagsClientEntity < Grape::Entity
+ include RequestAwareEntity
+
+ expose :token
+end
diff --git a/app/serializers/feature_flags_client_serializer.rb b/app/serializers/feature_flags_client_serializer.rb
new file mode 100644
index 00000000000..104729b6668
--- /dev/null
+++ b/app/serializers/feature_flags_client_serializer.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class FeatureFlagsClientSerializer < BaseSerializer
+ entity FeatureFlagsClientEntity
+
+ def represent_token(resource, opts = {})
+ represent(resource, only: [:token])
+ end
+end
diff --git a/app/serializers/group_group_link_entity.rb b/app/serializers/group_group_link_entity.rb
index 7a51e1a9316..1e736214f54 100644
--- a/app/serializers/group_group_link_entity.rb
+++ b/app/serializers/group_group_link_entity.rb
@@ -1,17 +1,31 @@
# frozen_string_literal: true
class GroupGroupLinkEntity < Grape::Entity
+ include RequestAwareEntity
+
expose :id
expose :created_at
expose :expires_at do |group_link|
group_link.expires_at&.to_time
end
+ expose :can_update do |group_link|
+ can_manage?(group_link)
+ end
+
+ expose :can_remove do |group_link|
+ can_manage?(group_link)
+ end
+
expose :access_level do
expose :human_access, as: :string_value
expose :group_access, as: :integer_value
end
+ expose :valid_roles do |group_link|
+ group_link.class.access_options
+ end
+
expose :shared_with_group do
expose :avatar_url do |group_link|
group_link.shared_with_group.avatar_url(only_path: false)
@@ -23,4 +37,14 @@ class GroupGroupLinkEntity < Grape::Entity
expose :shared_with_group, merge: true, using: GroupBasicEntity
end
+
+ private
+
+ def current_user
+ options[:current_user]
+ end
+
+ def can_manage?(group_link)
+ can?(current_user, :admin_group_member, group_link.shared_group)
+ end
end
diff --git a/app/serializers/import/bulk_import_entity.rb b/app/serializers/import/bulk_import_entity.rb
new file mode 100644
index 00000000000..8f0a9dd4428
--- /dev/null
+++ b/app/serializers/import/bulk_import_entity.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class Import::BulkImportEntity < Grape::Entity
+ expose :id do |entity|
+ entity['id']
+ end
+
+ expose :full_name do |entity|
+ entity['full_name']
+ end
+
+ expose :full_path do |entity|
+ entity['full_path']
+ end
+end
diff --git a/app/serializers/label_entity.rb b/app/serializers/label_entity.rb
index 5082245dda9..e586d7f8407 100644
--- a/app/serializers/label_entity.rb
+++ b/app/serializers/label_entity.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class LabelEntity < Grape::Entity
- expose :id, if: ->(label, _) { !label.is_a?(GlobalLabel) }
+ expose :id
expose :title
expose :color
diff --git a/app/serializers/label_serializer.rb b/app/serializers/label_serializer.rb
index 25b9f7de243..b09592da67f 100644
--- a/app/serializers/label_serializer.rb
+++ b/app/serializers/label_serializer.rb
@@ -4,6 +4,6 @@ class LabelSerializer < BaseSerializer
entity LabelEntity
def represent_appearance(resource)
- represent(resource, { only: [:id, :title, :color, :text_color] })
+ represent(resource, { only: [:id, :title, :color, :text_color, :project_id] })
end
end
diff --git a/app/serializers/merge_request_basic_entity.rb b/app/serializers/merge_request_basic_entity.rb
index ef1177e9967..9e2bce53c8a 100644
--- a/app/serializers/merge_request_basic_entity.rb
+++ b/app/serializers/merge_request_basic_entity.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
class MergeRequestBasicEntity < Grape::Entity
+ expose :title
expose :public_merge_status, as: :merge_status
expose :merge_error
expose :state
diff --git a/app/serializers/merge_request_poll_cached_widget_entity.rb b/app/serializers/merge_request_poll_cached_widget_entity.rb
index 002be8be729..080b6554de1 100644
--- a/app/serializers/merge_request_poll_cached_widget_entity.rb
+++ b/app/serializers/merge_request_poll_cached_widget_entity.rb
@@ -15,7 +15,7 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
expose :target_project_id
expose :squash
expose :rebase_in_progress?, as: :rebase_in_progress
- expose :default_squash_commit_message, if: -> (merge_request, _) { merge_request.mergeable? }
+ expose :default_squash_commit_message
expose :commits_count
expose :merge_ongoing?, as: :merge_ongoing
expose :work_in_progress?, as: :work_in_progress
@@ -25,10 +25,10 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
expose :source_branch_exists?, as: :source_branch_exists
expose :branch_missing?, as: :branch_missing
- expose :commits_without_merge_commits, using: MergeRequestWidgetCommitEntity,
- if: -> (merge_request, _) { merge_request.mergeable? } do |merge_request|
+ expose :commits_without_merge_commits, using: MergeRequestWidgetCommitEntity do |merge_request|
merge_request.recent_commits.without_merge_commits
end
+
expose :diff_head_sha do |merge_request|
merge_request.diff_head_sha.presence
end
@@ -46,6 +46,12 @@ class MergeRequestPollCachedWidgetEntity < IssuableEntity
end
end
+ expose :actual_head_pipeline, as: :pipeline, if: -> (mr, _) {
+ Feature.enabled?(:merge_request_cached_pipeline_serializer, mr.project) && presenter(mr).can_read_pipeline?
+ } do |merge_request, options|
+ MergeRequests::PipelineEntity.represent(merge_request.actual_head_pipeline, options)
+ end
+
# Paths
#
expose :target_branch_commits_path do |merge_request|
diff --git a/app/serializers/merge_request_poll_widget_entity.rb b/app/serializers/merge_request_poll_widget_entity.rb
index 41ab5005091..9609a894e6d 100644
--- a/app/serializers/merge_request_poll_widget_entity.rb
+++ b/app/serializers/merge_request_poll_widget_entity.rb
@@ -19,20 +19,14 @@ class MergeRequestPollWidgetEntity < Grape::Entity
# User entities
expose :merge_user, using: UserEntity
- expose :actual_head_pipeline, as: :pipeline, if: -> (mr, _) { presenter(mr).can_read_pipeline? } do |merge_request, options|
- if Feature.enabled?(:merge_request_short_pipeline_serializer, merge_request.project, default_enabled: true)
- MergeRequests::PipelineEntity.represent(merge_request.actual_head_pipeline, options)
- else
- PipelineDetailsEntity.represent(merge_request.actual_head_pipeline, options)
- end
+ expose :actual_head_pipeline, as: :pipeline, if: -> (mr, _) {
+ Feature.disabled?(:merge_request_cached_pipeline_serializer, mr.project) && presenter(mr).can_read_pipeline?
+ } 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|
- if Feature.enabled?(:merge_request_short_pipeline_serializer, merge_request.project, default_enabled: true)
- MergeRequests::PipelineEntity.represent(merge_request.merge_pipeline, options)
- else
- PipelineDetailsEntity.represent(merge_request.merge_pipeline, options)
- end
+ MergeRequests::PipelineEntity.represent(merge_request.merge_pipeline, options)
end
expose :default_merge_commit_message
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index 494192c8dbb..44cbcfc5044 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -67,15 +67,15 @@ class MergeRequestWidgetEntity < Grape::Entity
)
end
- expose :user_callouts_path, if: -> (*) { Feature.enabled?(:suggest_pipeline) } do |merge_request|
+ expose :user_callouts_path, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
user_callouts_path
end
- expose :suggest_pipeline_feature_id, if: -> (*) { Feature.enabled?(:suggest_pipeline) } do |merge_request|
+ expose :suggest_pipeline_feature_id, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
SUGGEST_PIPELINE
end
- expose :is_dismissed_suggest_pipeline, if: -> (*) { Feature.enabled?(:suggest_pipeline) } do |merge_request|
+ expose :is_dismissed_suggest_pipeline, if: -> (_, opts) { opts[:experiment_enabled] == :suggest_pipeline } do |_merge_request|
current_user && current_user.dismissed_callout?(feature_name: SUGGEST_PIPELINE)
end
@@ -120,10 +120,18 @@ class MergeRequestWidgetEntity < Grape::Entity
end
expose :base_path do |merge_request|
- base_pipeline_downloadable_path_for_report_type(:codequality)
+ if use_merge_base_with_merged_results?
+ merge_base_pipeline_downloadable_path_for_report_type(:codequality)
+ else
+ base_pipeline_downloadable_path_for_report_type(:codequality)
+ end
end
end
+ expose :security_reports_docs_path do |merge_request|
+ help_page_path('user/application_security/sast/index.md', anchor: 'reports-json-format')
+ end
+
private
delegate :current_user, to: :request
@@ -152,6 +160,16 @@ class MergeRequestWidgetEntity < Grape::Entity
object.base_pipeline&.present(current_user: current_user)
&.downloadable_path_for_report_type(file_type)
end
+
+ def use_merge_base_with_merged_results?
+ Feature.enabled?(:merge_base_pipelines, object.target_project) &&
+ object.actual_head_pipeline&.merge_request_event_type == :merged_result
+ end
+
+ def merge_base_pipeline_downloadable_path_for_report_type(file_type)
+ object.merge_base_pipeline&.present(current_user: current_user)
+ &.downloadable_path_for_report_type(file_type)
+ end
end
MergeRequestWidgetEntity.prepend_if_ee('EE::MergeRequestWidgetEntity')
diff --git a/app/serializers/paginated_diff_entity.rb b/app/serializers/paginated_diff_entity.rb
index 37c48338e55..f24571f7d7d 100644
--- a/app/serializers/paginated_diff_entity.rb
+++ b/app/serializers/paginated_diff_entity.rb
@@ -37,8 +37,6 @@ class PaginatedDiffEntity < Grape::Entity
private
def code_navigation_path(diffs)
- return unless Feature.enabled?(:code_navigation, merge_request.project, default_enabled: true)
-
Gitlab::CodeNavigationPath.new(merge_request.project, diffs.diff_refs&.head_sha)
end
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 64958b06f1d..2d278f0e30d 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -82,7 +82,9 @@ class PipelineEntity < Grape::Entity
end
expose :failed_builds, if: -> (*) { can_retry? }, using: JobEntity do |pipeline|
- pipeline.failed_builds
+ pipeline.failed_builds.each do |build|
+ build.project = pipeline.project
+ end
end
private
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index 45c5a1d3e1c..a45214670fa 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -47,6 +47,7 @@ class PipelineSerializer < BaseSerializer
:retryable_builds,
:scheduled_actions,
:stages,
+ :latest_statuses,
:trigger_requests,
:user,
{
@@ -62,7 +63,14 @@ class PipelineSerializer < BaseSerializer
pending_builds: :project,
project: [:route, { namespace: :route }],
triggered_by_pipeline: [{ project: [:route, { namespace: :route }] }, :user],
- triggered_pipelines: [{ project: [:route, { namespace: :route }] }, :user, :source_job]
+ triggered_pipelines: [
+ {
+ project: [:route, { namespace: :route }]
+ },
+ :source_job,
+ :latest_statuses,
+ :user
+ ]
}
]
end
diff --git a/app/serializers/test_case_entity.rb b/app/serializers/test_case_entity.rb
index d2e08590ef0..b44aa62ad73 100644
--- a/app/serializers/test_case_entity.rb
+++ b/app/serializers/test_case_entity.rb
@@ -6,6 +6,7 @@ class TestCaseEntity < Grape::Entity
expose :status
expose :name
expose :classname
+ expose :file
expose :execution_time
expose :system_output
expose :stack_trace