diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /app/serializers | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/admin/abuse_report_details_entity.rb | 8 | ||||
-rw-r--r-- | app/serializers/admin/abuse_report_entity.rb | 7 | ||||
-rw-r--r-- | app/serializers/base_discussion_entity.rb | 14 | ||||
-rw-r--r-- | app/serializers/deployment_entity.rb | 4 | ||||
-rw-r--r-- | app/serializers/discussion_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/environment_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/environment_serializer.rb | 2 | ||||
-rw-r--r-- | app/serializers/environment_status_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/integrations/event_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/integrations/field_entity.rb | 10 | ||||
-rw-r--r-- | app/serializers/merge_request_serializer.rb | 2 | ||||
-rw-r--r-- | app/serializers/note_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/profile/event_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/project_note_entity.rb | 8 |
14 files changed, 46 insertions, 30 deletions
diff --git a/app/serializers/admin/abuse_report_details_entity.rb b/app/serializers/admin/abuse_report_details_entity.rb index f0e84fc44d2..3efb8508e5e 100644 --- a/app/serializers/admin/abuse_report_details_entity.rb +++ b/app/serializers/admin/abuse_report_details_entity.rb @@ -79,9 +79,17 @@ module Admin expose :reported_content, as: :content expose :reported_from_url, as: :url expose :screenshot_path, as: :screenshot + + # Kept for backwards compatibility. + # TODO: See https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/167?work_item_iid=443 + # In 16.4 remove or re-use this field after frontend has migrated to using moderate_user_path expose :update_path do |report| admin_abuse_report_path(report) end + + expose :moderate_user_path do |report| + moderate_user_admin_abuse_report_path(report) + end end end end diff --git a/app/serializers/admin/abuse_report_entity.rb b/app/serializers/admin/abuse_report_entity.rb index 58637445e81..22395a2fe91 100644 --- a/app/serializers/admin/abuse_report_entity.rb +++ b/app/serializers/admin/abuse_report_entity.rb @@ -7,6 +7,7 @@ module Admin expose :category expose :created_at expose :updated_at + expose :count expose :reported_user do |report| UserEntity.represent(report.user, only: [:name]) @@ -19,5 +20,11 @@ module Admin expose :report_path do |report| admin_abuse_report_path(report) end + + private + + def count + object.has_attribute?(:count) ? object.count : 1 + end end end diff --git a/app/serializers/base_discussion_entity.rb b/app/serializers/base_discussion_entity.rb index 7d3b9651b8b..0b006078343 100644 --- a/app/serializers/base_discussion_entity.rb +++ b/app/serializers/base_discussion_entity.rb @@ -15,7 +15,6 @@ class BaseDiscussionEntity < Grape::Entity expose :for_commit?, as: :for_commit expose :individual_note?, as: :individual_note expose :resolvable?, as: :resolvable - expose :resolved_by_push?, as: :resolved_by_push expose :truncated_diff_lines, using: DiffLineEntity, if: -> (d, _) { d.diff_discussion? && d.on_text? && (d.expanded? || render_truncated_diff_lines?) } @@ -34,18 +33,23 @@ class BaseDiscussionEntity < Grape::Entity discussion_path(discussion) end - with_options if: -> (d, _) { d.resolvable? } do + with_options if: -> (d, _) { d.noteable.supports_resolvable_notes? } do + expose :resolved?, as: :resolved + expose :resolved_by_push?, as: :resolved_by_push + expose :resolved_by, using: NoteUserEntity + expose :resolved_at + expose :resolve_path do |discussion| - resolve_project_merge_request_discussion_path(discussion.project, discussion.noteable, discussion.id) + resolve_project_discussion_path(discussion.project, discussion.noteable_collection_name, discussion.noteable, discussion.id) end - expose :resolve_with_issue_path do |discussion| + expose :resolve_with_issue_path, if: -> (d, _) { d.noteable.is_a?(MergeRequest) } do |discussion| 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 expose :truncated_diff_lines_path, if: -> (d, _) { !d.expanded? && !render_truncated_diff_lines? } do |discussion| - project_merge_request_discussion_path(discussion.project, discussion.noteable, discussion) + project_discussion_path(discussion.project, discussion.noteable_collection_name, discussion.noteable, discussion) end private diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index f63a1bf094a..7cd913d057e 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -41,8 +41,8 @@ class DeploymentEntity < Grape::Entity expose :commit, using: CommitEntity, if: -> (*) { include_details? } expose :manual_actions, using: Ci::JobEntity, if: -> (*) { include_details? && can_create_deployment? } expose :scheduled_actions, using: Ci::JobEntity, if: -> (*) { include_details? && can_create_deployment? } - expose :playable_build, if: -> (deployment) { include_details? && can_create_deployment? && deployment.playable_build } do |deployment, options| - Ci::JobEntity.represent(deployment.playable_build, options.merge(only: [:play_path, :retry_path])) + expose :playable_job, as: :playable_build, if: -> (deployment) { include_details? && can_create_deployment? && deployment.playable_job } do |deployment, options| + Ci::JobEntity.represent(deployment.playable_job, options.merge(only: [:play_path, :retry_path])) end expose :cluster do |deployment, options| diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb index 0dbfe0f0772..9ee2e145cd5 100644 --- a/app/serializers/discussion_entity.rb +++ b/app/serializers/discussion_entity.rb @@ -19,11 +19,6 @@ class DiscussionEntity < BaseDiscussionEntity discussion.diff_note_positions.map(&:line_code) end - expose :resolved?, as: :resolved - expose :resolved_by_push?, as: :resolved_by_push - expose :resolved_by, using: NoteUserEntity - expose :resolved_at - private def current_user diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb index 0a3bf4c2a7b..b1f731cdd4d 100644 --- a/app/serializers/environment_entity.rb +++ b/app/serializers/environment_entity.rb @@ -4,7 +4,7 @@ class EnvironmentEntity < Grape::Entity include RequestAwareEntity UNNECESSARY_ENTRIES_FOR_UPCOMING_DEPLOYMENT = - %i[manual_actions scheduled_actions playable_build cluster].freeze + %i[manual_actions scheduled_actions playable_job cluster].freeze expose :id diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb index d7820dff6ef..8f3aeea2eed 100644 --- a/app/serializers/environment_serializer.rb +++ b/app/serializers/environment_serializer.rb @@ -94,7 +94,7 @@ class EnvironmentSerializer < BaseSerializer pipeline: { manual_actions: [:metadata, :deployment], scheduled_actions: [:metadata], - latest_successful_builds: [] + latest_successful_jobs: [] }, project: project_associations } diff --git a/app/serializers/environment_status_entity.rb b/app/serializers/environment_status_entity.rb index 8865c030d94..62dc323616e 100644 --- a/app/serializers/environment_status_entity.rb +++ b/app/serializers/environment_status_entity.rb @@ -38,7 +38,7 @@ class EnvironmentStatusEntity < Grape::Entity end expose :deployment, as: :details do |es, options| - DeploymentEntity.represent(es.deployment, options.merge(project: es.project, only: [:playable_build])) + DeploymentEntity.represent(es.deployment, options.merge(project: es.project, only: [:playable_job])) end expose :environment_available do |es| diff --git a/app/serializers/integrations/event_entity.rb b/app/serializers/integrations/event_entity.rb index 1cbd6114581..f7cac23f30c 100644 --- a/app/serializers/integrations/event_entity.rb +++ b/app/serializers/integrations/event_entity.rb @@ -23,7 +23,10 @@ module Integrations integration.event_channel_name(event) end expose :value do |event| - integration.event_channel_value(event) + value = integration.event_channel_value(event) + next BaseChatNotification::SECRET_MASK if value.present? && integration.mask_configurable_channels? + + value end expose :placeholder do |_event| integration.default_channel_placeholder diff --git a/app/serializers/integrations/field_entity.rb b/app/serializers/integrations/field_entity.rb index 1c548cfab78..dc2ec55d073 100644 --- a/app/serializers/integrations/field_entity.rb +++ b/app/serializers/integrations/field_entity.rb @@ -5,12 +5,16 @@ module Integrations include RequestAwareEntity include Gitlab::Utils::StrongMemoize - expose :section, :type, :name, :placeholder, :required, :choices, :checkbox_label + expose :section, :name, :placeholder, :required, :choices, :checkbox_label expose :title do |field| non_empty_password?(field) ? field[:non_empty_password_title] : field[:title] end + expose :type do |field| + field[:type].to_s + end + expose :help do |field| non_empty_password?(field) ? field[:non_empty_password_help] : field[:help] end @@ -20,7 +24,7 @@ module Integrations if non_empty_password?(field) 'true' - elsif field[:type] == 'checkbox' + elsif field[:type] == :checkbox ActiveRecord::Type::Boolean.new.deserialize(value).to_s elsif field[:name] == 'webhook' && integration.chat? BaseChatNotification::SECRET_MASK if value.present? @@ -44,7 +48,7 @@ module Integrations def non_empty_password?(field) strong_memoize(:non_empty_password) do - field[:type] == 'password' && value_for(field).present? + field[:type] == :password && value_for(field).present? end end end diff --git a/app/serializers/merge_request_serializer.rb b/app/serializers/merge_request_serializer.rb index 9fd50c8c51d..6f83978841d 100644 --- a/app/serializers/merge_request_serializer.rb +++ b/app/serializers/merge_request_serializer.rb @@ -27,3 +27,5 @@ class MergeRequestSerializer < BaseSerializer super(merge_request, opts, entity) end end + +MergeRequestSerializer.prepend_mod diff --git a/app/serializers/note_entity.rb b/app/serializers/note_entity.rb index 26dc748ad51..a50d893d244 100644 --- a/app/serializers/note_entity.rb +++ b/app/serializers/note_entity.rb @@ -48,6 +48,7 @@ class NoteEntity < API::Entities::Note expose :resolvable?, as: :resolvable expose :resolved_by, using: NoteUserEntity + expose :resolved_by_push?, as: :resolved_by_push expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note| SystemNoteHelper.system_note_icon_name(note) @@ -77,10 +78,10 @@ class NoteEntity < API::Entities::Note end expose :resolve_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note| - resolve_project_merge_request_discussion_path(note.project, note.noteable, note.discussion_id) + resolve_project_discussion_path(discussion.project, discussion.noteable_collection_name, discussion.noteable, discussion.id) end - expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note| + expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? && note.noteable.is_a?(MergeRequest) } do |note| new_project_issue_path(note.project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id) end diff --git a/app/serializers/profile/event_entity.rb b/app/serializers/profile/event_entity.rb index b769a80ef58..f3c1a927084 100644 --- a/app/serializers/profile/event_entity.rb +++ b/app/serializers/profile/event_entity.rb @@ -51,7 +51,7 @@ module Profile expose(:id) { |event| event.target.id } expose(:target_type, as: :type) expose(:target_title, as: :title) - expose(:issue_type, if: ->(event) { event.work_item? }) do |event| + expose(:issue_type, if: ->(event) { event.work_item? || event.issue? }) do |event| event.target.issue_type end diff --git a/app/serializers/project_note_entity.rb b/app/serializers/project_note_entity.rb index 3cd34f6af0d..3e004fb5d32 100644 --- a/app/serializers/project_note_entity.rb +++ b/app/serializers/project_note_entity.rb @@ -21,14 +21,6 @@ class ProjectNoteEntity < NoteEntity project_note_path(note.project, note) end - expose :resolve_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note| - resolve_project_merge_request_discussion_path(note.project, note.noteable, note.discussion_id) - end - - expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note| - new_project_issue_path(note.project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id) - end - expose :delete_attachment_path, if: -> (note, _) { note.attachment? } do |note| delete_attachment_project_note_path(note.project, note) end |