diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 20:02:30 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-18 20:02:30 +0000 |
commit | 41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch) | |
tree | 9c8d89a8624828992f06d892cd2f43818ff5dcc8 /app/serializers | |
parent | 0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff) | |
download | gitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz |
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/analytics/cycle_analytics/stage_entity.rb | 3 | ||||
-rw-r--r-- | app/serializers/cluster_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/cluster_error_entity.rb | 7 | ||||
-rw-r--r-- | app/serializers/clusters/kubernetes_error_entity.rb | 9 | ||||
-rw-r--r-- | app/serializers/deployment_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/diffs_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/environment_entity.rb | 1 | ||||
-rw-r--r-- | app/serializers/environment_serializer.rb | 2 | ||||
-rw-r--r-- | app/serializers/fork_namespace_entity.rb | 8 | ||||
-rw-r--r-- | app/serializers/issue_sidebar_basic_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/label_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/member_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/merge_request_widget_entity.rb | 6 | ||||
-rw-r--r-- | app/serializers/pipeline_details_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/service_event_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/service_field_entity.rb | 2 |
16 files changed, 34 insertions, 30 deletions
diff --git a/app/serializers/analytics/cycle_analytics/stage_entity.rb b/app/serializers/analytics/cycle_analytics/stage_entity.rb index cfbf6f60e38..c1d415dfb40 100644 --- a/app/serializers/analytics/cycle_analytics/stage_entity.rb +++ b/app/serializers/analytics/cycle_analytics/stage_entity.rb @@ -57,7 +57,8 @@ module Analytics def html_description(event) options = {} if event.label_based? - options[:label_html] = render_label(event.label, link: '', small: true, tooltip: true) + label = event.label.present(issuable_subject: event.label.subject) + options[:label_html] = render_label(label, link: '', small: true, tooltip: true) end content_tag(:p) { event.html_description(options).html_safe } diff --git a/app/serializers/cluster_entity.rb b/app/serializers/cluster_entity.rb index ba42e14be22..e2d24e74b29 100644 --- a/app/serializers/cluster_entity.rb +++ b/app/serializers/cluster_entity.rb @@ -24,7 +24,7 @@ class ClusterEntity < Grape::Entity end expose :kubernetes_errors do |cluster| - ClusterErrorEntity.new(cluster) + Clusters::KubernetesErrorEntity.new(cluster) end expose :enable_advanced_logs_querying do |cluster| diff --git a/app/serializers/cluster_error_entity.rb b/app/serializers/cluster_error_entity.rb deleted file mode 100644 index c749537cb94..00000000000 --- a/app/serializers/cluster_error_entity.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class ClusterErrorEntity < Grape::Entity - expose :connection_error - expose :metrics_connection_error - expose :node_connection_error -end diff --git a/app/serializers/clusters/kubernetes_error_entity.rb b/app/serializers/clusters/kubernetes_error_entity.rb new file mode 100644 index 00000000000..ceab10f232e --- /dev/null +++ b/app/serializers/clusters/kubernetes_error_entity.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Clusters + class KubernetesErrorEntity < Grape::Entity + expose :connection_error + expose :metrics_connection_error + expose :node_connection_error + end +end diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index 7a2fba73f3a..020c66af777 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -73,3 +73,5 @@ class DeploymentEntity < Grape::Entity request.try(:project) || options[:project] end end + +DeploymentEntity.prepend_mod diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb index e0565a1e506..c818fcd6215 100644 --- a/app/serializers/diffs_entity.rb +++ b/app/serializers/diffs_entity.rb @@ -23,7 +23,7 @@ class DiffsEntity < Grape::Entity CommitEntity.represent(options[:commit], commit_options(options)) end - expose :context_commits, using: API::Entities::Commit, if: -> (diffs, options) { merge_request&.project&.context_commits_enabled? } do |diffs| + expose :context_commits, using: API::Entities::Commit do |diffs| options[:context_commits] end @@ -89,7 +89,7 @@ class DiffsEntity < Grape::Entity project_blob_path(merge_request.project, merge_request.diff_head_sha) end - expose :context_commits_diff, if: -> (_) { merge_request&.project&.context_commits_enabled? } do |diffs, options| + expose :context_commits_diff do |diffs, options| next unless merge_request.context_commits_diff.commits_count > 0 ContextCommitsDiffEntity.represent( diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index 6105b52fbda..d484f60ed8f 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -20,6 +20,7 @@ class EnvironmentEntity < Grape::Entity expose :last_deployment, using: DeploymentEntity expose :stop_action_available?, as: :has_stop_action expose :rollout_status, if: -> (*) { can_read_deploy_board? }, using: RolloutStatusEntity + expose :tier expose :upcoming_deployment, if: -> (environment) { environment.upcoming_deployment } do |environment, ops| DeploymentEntity.represent(environment.upcoming_deployment, diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index 8d9b73b2290..a8645c8670d 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -60,7 +60,7 @@ class EnvironmentSerializer < BaseSerializer Preloaders::Environments::DeploymentPreloader.new(resource) .execute_with_union(:upcoming_deployment, deployment_associations) - resource.all.to_a.tap do |environments| + resource.to_a.tap do |environments| environments.each do |environment| # Batch loading the commits of the deployments environment.last_deployment&.commit&.try(:lazy_author) diff --git a/app/serializers/fork_namespace_entity.rb b/app/serializers/fork_namespace_entity.rb index 2be37d23a05..997abb0f148 100644 --- a/app/serializers/fork_namespace_entity.rb +++ b/app/serializers/fork_namespace_entity.rb @@ -30,14 +30,6 @@ class ForkNamespaceEntity < Grape::Entity markdown_description(namespace) end - expose :can_create_project do |namespace, options| - if Feature.enabled?(:fork_project_form, options[:project], default_enabled: :yaml) - true - else - options[:current_user].can?(:create_projects, namespace) - end - end - private # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/serializers/issue_sidebar_basic_entity.rb b/app/serializers/issue_sidebar_basic_entity.rb index 9c6601afd5e..7222b5df425 100644 --- a/app/serializers/issue_sidebar_basic_entity.rb +++ b/app/serializers/issue_sidebar_basic_entity.rb @@ -10,6 +10,11 @@ class IssueSidebarBasicEntity < IssuableSidebarBasicEntity can?(current_user, :update_escalation_status, issue.project) end end + + expose :show_crm_contacts do |issuable| + current_user&.can?(:read_crm_contact, issuable.project.root_ancestor) && + CustomerRelations::Contact.exists_for_group?(issuable.project.root_ancestor) + end end IssueSidebarBasicEntity.prepend_mod_with('IssueSidebarBasicEntity') diff --git a/app/serializers/label_entity.rb b/app/serializers/label_entity.rb index e586d7f8407..5785715390f 100644 --- a/app/serializers/label_entity.rb +++ b/app/serializers/label_entity.rb @@ -4,7 +4,9 @@ class LabelEntity < Grape::Entity expose :id expose :title - expose :color + expose :color do |label| + label.color.to_s + end expose :description expose :group_id expose :project_id diff --git a/app/serializers/member_entity.rb b/app/serializers/member_entity.rb index f2f97f560e0..bfb5b3eeae6 100644 --- a/app/serializers/member_entity.rb +++ b/app/serializers/member_entity.rb @@ -41,7 +41,7 @@ class MemberEntity < Grape::Entity expose :valid_level_roles, as: :valid_roles expose :user, if: -> (member) { member.user.present? } do |member, options| - MemberUserEntity.represent(member.user, source: options[:source]) + MemberUserEntity.represent(member.user, options) end expose :state diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb index b9c71e6d97b..21ab20747d0 100644 --- a/app/serializers/merge_request_widget_entity.rb +++ b/app/serializers/merge_request_widget_entity.rb @@ -104,7 +104,11 @@ class MergeRequestWidgetEntity < Grape::Entity # include them if they are explicitly requested on first load. expose :issues_links, if: -> (_, opts) { opts[:issues_links] } do expose :assign_to_closing do |merge_request| - presenter(merge_request).assign_to_closing_issues_link + presenter(merge_request).assign_to_closing_issues_path + end + + expose :assign_to_closing_count do |merge_request| + presenter(merge_request).assign_to_closing_issues_count end expose :closing do |merge_request| diff --git a/app/serializers/pipeline_details_entity.rb b/app/serializers/pipeline_details_entity.rb index f459e700c03..76797a773b5 100644 --- a/app/serializers/pipeline_details_entity.rb +++ b/app/serializers/pipeline_details_entity.rb @@ -10,11 +10,6 @@ class PipelineDetailsEntity < Ci::PipelineEntity expose :details do expose :manual_actions, using: BuildActionEntity expose :scheduled_actions, using: BuildActionEntity - expose :code_quality_build_path, if: -> (_, options) { options[:code_quality_walkthrough] } do |pipeline| - next unless code_quality_build = pipeline.builds.finished.find_by_name('code_quality') - - project_job_path(pipeline.project, code_quality_build, code_quality_walkthrough: true) - end end expose :triggered_by_pipeline, as: :triggered_by, with: TriggeredPipelineEntity diff --git a/app/serializers/service_event_entity.rb b/app/serializers/service_event_entity.rb index a1fbfa1d4c4..49a4944b2b0 100644 --- a/app/serializers/service_event_entity.rb +++ b/app/serializers/service_event_entity.rb @@ -4,7 +4,7 @@ class ServiceEventEntity < Grape::Entity include RequestAwareEntity expose :title do |event| - event + IntegrationsHelper.integration_event_title(event) end expose :event_field_name, as: :name diff --git a/app/serializers/service_field_entity.rb b/app/serializers/service_field_entity.rb index aad9db5ffea..b13f2c0e217 100644 --- a/app/serializers/service_field_entity.rb +++ b/app/serializers/service_field_entity.rb @@ -4,7 +4,7 @@ class ServiceFieldEntity < Grape::Entity include RequestAwareEntity include Gitlab::Utils::StrongMemoize - expose :type, :name, :placeholder, :required, :choices, :checkbox_label + expose :section, :type, :name, :placeholder, :required, :choices, :checkbox_label expose :title do |field| non_empty_password?(field) ? field[:non_empty_password_title] : field[:title] |