summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /app/serializers
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/analytics/cycle_analytics/stage_entity.rb15
-rw-r--r--app/serializers/merge_request_widget_entity.rb2
-rw-r--r--app/serializers/paginated_diff_entity.rb27
-rw-r--r--app/serializers/service_event_entity.rb12
4 files changed, 24 insertions, 32 deletions
diff --git a/app/serializers/analytics/cycle_analytics/stage_entity.rb b/app/serializers/analytics/cycle_analytics/stage_entity.rb
index b24148802d0..c5cc8c89fb7 100644
--- a/app/serializers/analytics/cycle_analytics/stage_entity.rb
+++ b/app/serializers/analytics/cycle_analytics/stage_entity.rb
@@ -9,6 +9,21 @@ module Analytics
expose :description
expose :id
expose :custom
+
+ # new API
+ expose :start_event do
+ expose :start_event_identifier, as: :identifier, if: -> (s) { s.custom? }
+ expose :start_event_label, as: :label, using: LabelEntity, if: -> (s) { s.start_event_label_based? }
+ expose :start_event_html_description, as: :html_description
+ end
+
+ expose :end_event do
+ expose :end_event_identifier, as: :identifier, if: -> (s) { s.custom? }
+ expose :end_event_label, as: :label, using: LabelEntity, if: -> (s) { s.end_event_label_based? }
+ expose :end_event_html_description, as: :html_description
+ end
+
+ # old API
expose :start_event_identifier, if: -> (s) { s.custom? }
expose :end_event_identifier, if: -> (s) { s.custom? }
expose :start_event_label, using: LabelEntity, if: -> (s) { s.start_event_label_based? }
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index 0616d94a1ed..c3e8b66fe12 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -56,7 +56,7 @@ class MergeRequestWidgetEntity < Grape::Entity
end
expose :merge_request_pipelines_docs_path do |merge_request|
- help_page_path('ci/merge_request_pipelines/index.md')
+ help_page_path('ci/pipelines/merge_request_pipelines.md')
end
expose :ci_environments_status_path do |merge_request|
diff --git a/app/serializers/paginated_diff_entity.rb b/app/serializers/paginated_diff_entity.rb
index 1118b1aa4fe..a2a9e7375a0 100644
--- a/app/serializers/paginated_diff_entity.rb
+++ b/app/serializers/paginated_diff_entity.rb
@@ -23,36 +23,13 @@ class PaginatedDiffEntity < Grape::Entity
end
expose :pagination do
- expose :current_page
- expose :next_page
- expose :total_pages
- expose :next_page_href do |diffs|
- next unless next_page
-
- project = merge_request.target_project
-
- diffs_batch_namespace_project_json_merge_request_path(
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- id: merge_request.iid,
- page: next_page,
- format: :json
- )
+ expose :total_pages do |diffs, options|
+ options.dig(:pagination_data, :total_pages)
end
end
private
- %i[current_page next_page total_pages].each do |method|
- define_method method do
- pagination_data[method]
- end
- end
-
- def pagination_data
- options.fetch(:pagination_data, {})
- end
-
def merge_request
options[:merge_request]
end
diff --git a/app/serializers/service_event_entity.rb b/app/serializers/service_event_entity.rb
index eb4f9c665f2..a1fbfa1d4c4 100644
--- a/app/serializers/service_event_entity.rb
+++ b/app/serializers/service_event_entity.rb
@@ -10,11 +10,11 @@ class ServiceEventEntity < Grape::Entity
expose :event_field_name, as: :name
expose :value do |event|
- service[event_field_name]
+ integration[event_field_name]
end
expose :description do |event|
- ServicesHelper.service_event_description(event)
+ IntegrationsHelper.integration_event_description(integration, event)
end
expose :field, if: -> (_, _) { event_field } do
@@ -22,7 +22,7 @@ class ServiceEventEntity < Grape::Entity
event_field[:name]
end
expose :value do |event|
- service.public_send(event_field[:name]) # rubocop:disable GitlabSecurity/PublicSend
+ integration.public_send(event_field[:name]) # rubocop:disable GitlabSecurity/PublicSend
end
end
@@ -31,14 +31,14 @@ class ServiceEventEntity < Grape::Entity
alias_method :event, :object
def event_field_name
- ServicesHelper.service_event_field_name(event)
+ IntegrationsHelper.integration_event_field_name(event)
end
def event_field
- @event_field ||= service.event_field(event)
+ @event_field ||= integration.event_field(event)
end
- def service
+ def integration
request.service
end
end