Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 00:09:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-14 00:09:09 +0300
commit04cc87ee46c1c0b6b4eb7df964b3115dd2578877 (patch)
tree2c64b0e21804fc0981a2142eb83a0b73d85fbcda /app
parent4a064b8dc0bf350b1b3000698042b49113e758d1 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/abuse/event.rb18
-rw-r--r--app/models/abuse_report.rb2
-rw-r--r--app/models/commit_user_mention.rb2
-rw-r--r--app/models/concerns/enums/abuse/category.rb16
-rw-r--r--app/models/design_user_mention.rb2
-rw-r--r--app/models/issue_user_mention.rb2
-rw-r--r--app/models/merge_request_user_mention.rb2
-rw-r--r--app/models/note_diff_file.rb2
-rw-r--r--app/models/snippet_user_mention.rb2
-rw-r--r--app/models/suggestion.rb2
-rw-r--r--app/models/system_note_metadata.rb2
-rw-r--r--app/models/timelog.rb2
-rw-r--r--app/models/todo.rb2
-rw-r--r--app/models/user.rb1
-rw-r--r--app/models/work_item.rb7
-rw-r--r--app/presenters/work_item_presenter.rb4
-rw-r--r--app/services/notes/create_service.rb27
-rw-r--r--app/services/notes/quick_actions_service.rb16
-rw-r--r--app/validators/json_schemas/abuse_event_metadata.json7
-rw-r--r--app/views/devise/passwords/new.html.haml18
20 files changed, 104 insertions, 32 deletions
diff --git a/app/models/abuse/event.rb b/app/models/abuse/event.rb
new file mode 100644
index 00000000000..5700c1c73e6
--- /dev/null
+++ b/app/models/abuse/event.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Abuse
+ class Event < ApplicationRecord
+ self.table_name = 'abuse_events'
+
+ validates :category, presence: true
+ validates :source, presence: true
+ validates :user, presence: true, on: :create
+ validates :metadata, json_schema: { filename: 'abuse_event_metadata' }, allow_blank: true
+
+ belongs_to :user, inverse_of: :abuse_events
+ belongs_to :abuse_report, inverse_of: :abuse_events
+
+ enum category: Enums::Abuse::Category.categories
+ enum source: Enums::Abuse::Source.sources
+ end
+end
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index 236eaf92546..1d2eee82827 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -19,6 +19,8 @@ class AbuseReport < ApplicationRecord
has_many :events, class_name: 'ResourceEvents::AbuseReportEvent', inverse_of: :abuse_report
+ has_many :abuse_events, class_name: 'Abuse::Event', inverse_of: :abuse_report
+
validates :reporter, presence: true, on: :create
validates :user, presence: true, on: :create
validates :message, presence: true
diff --git a/app/models/commit_user_mention.rb b/app/models/commit_user_mention.rb
index 4d464f353ee..9215e15f07d 100644
--- a/app/models/commit_user_mention.rb
+++ b/app/models/commit_user_mention.rb
@@ -3,7 +3,7 @@
class CommitUserMention < UserMention
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :note
end
diff --git a/app/models/concerns/enums/abuse/category.rb b/app/models/concerns/enums/abuse/category.rb
new file mode 100644
index 00000000000..e024ed17e32
--- /dev/null
+++ b/app/models/concerns/enums/abuse/category.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Enums
+ module Abuse
+ module Category
+ def self.categories
+ {
+ spam: 0, # spamcheck
+ virus: 1, # VirusTotal
+ fraud: 2, # Arkos, Telesign
+ ci_cd: 3 # PVS
+ }
+ end
+ end
+ end
+end
diff --git a/app/models/design_user_mention.rb b/app/models/design_user_mention.rb
index 87899f65cb1..7d0cd72e9eb 100644
--- a/app/models/design_user_mention.rb
+++ b/app/models/design_user_mention.rb
@@ -3,7 +3,7 @@
class DesignUserMention < UserMention
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :design, class_name: 'DesignManagement::Design'
belongs_to :note
diff --git a/app/models/issue_user_mention.rb b/app/models/issue_user_mention.rb
index bb13b83d3ba..ad0df0dca78 100644
--- a/app/models/issue_user_mention.rb
+++ b/app/models/issue_user_mention.rb
@@ -5,5 +5,5 @@ class IssueUserMention < UserMention
belongs_to :note
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
end
diff --git a/app/models/merge_request_user_mention.rb b/app/models/merge_request_user_mention.rb
index d946fd14628..3157f1ca2aa 100644
--- a/app/models/merge_request_user_mention.rb
+++ b/app/models/merge_request_user_mention.rb
@@ -3,7 +3,7 @@
class MergeRequestUserMention < UserMention
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :merge_request
belongs_to :note
diff --git a/app/models/note_diff_file.rb b/app/models/note_diff_file.rb
index e4936de7b40..b0f6af0d853 100644
--- a/app/models/note_diff_file.rb
+++ b/app/models/note_diff_file.rb
@@ -4,7 +4,7 @@ class NoteDiffFile < ApplicationRecord
include DiffFile
include IgnorableColumns
- ignore_column :diff_note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :diff_note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
scope :referencing_sha, -> (oids, project_id:) do
joins(:diff_note).where(notes: { project_id: project_id, commit_id: oids })
diff --git a/app/models/snippet_user_mention.rb b/app/models/snippet_user_mention.rb
index 138feb6ab29..8ef2c579a5a 100644
--- a/app/models/snippet_user_mention.rb
+++ b/app/models/snippet_user_mention.rb
@@ -3,7 +3,7 @@
class SnippetUserMention < UserMention
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :snippet
belongs_to :note
diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb
index 267be5fe5c2..58a154b8986 100644
--- a/app/models/suggestion.rb
+++ b/app/models/suggestion.rb
@@ -5,7 +5,7 @@ class Suggestion < ApplicationRecord
include Suggestible
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
belongs_to :note, inverse_of: :suggestions
validates :note, presence: true, unless: :importing?
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb
index 0e0534d45ae..4e71a13a3a1 100644
--- a/app/models/system_note_metadata.rb
+++ b/app/models/system_note_metadata.rb
@@ -4,7 +4,7 @@ class SystemNoteMetadata < ApplicationRecord
include Importable
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
# These notes's action text might contain a reference that is external.
# We should always force a deep validation upon references that are found
diff --git a/app/models/timelog.rb b/app/models/timelog.rb
index 7f9cc2a99df..eb72456b435 100644
--- a/app/models/timelog.rb
+++ b/app/models/timelog.rb
@@ -5,7 +5,7 @@ class Timelog < ApplicationRecord
include IgnorableColumns
include Sortable
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
before_save :set_project
diff --git a/app/models/todo.rb b/app/models/todo.rb
index e1b5076e3d8..724f97c4812 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -6,7 +6,7 @@ class Todo < ApplicationRecord
include EachBatch
include IgnorableColumns
- ignore_column :note_id_convert_to_bigint, remove_with: '16.0', remove_after: '2023-05-22'
+ ignore_column :note_id_convert_to_bigint, remove_with: '16.2', remove_after: '2023-07-22'
# Time to wait for todos being removed when not visible for user anymore.
# Prevents TODOs being removed by mistake, for example, removing access from a user
diff --git a/app/models/user.rb b/app/models/user.rb
index 74c053c336d..8afe4a9c704 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -223,6 +223,7 @@ class User < ApplicationRecord
has_many :reported_abuse_reports, dependent: :nullify, foreign_key: :reporter_id, class_name: "AbuseReport", inverse_of: :reporter # rubocop:disable Cop/ActiveRecordDependent
has_many :assigned_abuse_reports, foreign_key: :assignee_id, class_name: "AbuseReport", inverse_of: :assignee
has_many :resolved_abuse_reports, foreign_key: :resolved_by_id, class_name: "AbuseReport", inverse_of: :resolved_by
+ has_many :abuse_events, foreign_key: :user_id, class_name: 'Abuse::Event', inverse_of: :user
has_many :spam_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :abuse_trust_scores, class_name: 'Abuse::TrustScore', foreign_key: :user_id
has_many :builds, class_name: 'Ci::Build'
diff --git a/app/models/work_item.rb b/app/models/work_item.rb
index 24d1078516e..9f28ffbf7b6 100644
--- a/app/models/work_item.rb
+++ b/app/models/work_item.rb
@@ -4,7 +4,7 @@ class WorkItem < Issue
include Gitlab::Utils::StrongMemoize
COMMON_QUICK_ACTIONS_COMMANDS = [
- :title, :reopen, :close, :cc, :tableflip, :shrug, :type
+ :title, :reopen, :close, :cc, :tableflip, :shrug, :type, :promote_to
].freeze
self.table_name = 'issues'
@@ -168,8 +168,9 @@ class WorkItem < Issue
errors.add(
:work_item_type_id,
format(
- _('cannot be changed to %{new_type} with %{parent_type} as parent type.'),
- new_type: work_item_type.name, parent_type: parent_link.work_item_parent.work_item_type.name
+ _('cannot be changed to %{new_type} when linked to a parent %{parent_type}.'),
+ new_type: work_item_type.name.downcase,
+ parent_type: parent_link.work_item_parent.work_item_type.name.downcase
)
)
end
diff --git a/app/presenters/work_item_presenter.rb b/app/presenters/work_item_presenter.rb
new file mode 100644
index 00000000000..995f2d02156
--- /dev/null
+++ b/app/presenters/work_item_presenter.rb
@@ -0,0 +1,4 @@
+# frozen_string_literal: true
+
+class WorkItemPresenter < IssuePresenter # rubocop:todo Gitlab/NamespacedClass
+end
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index 968d0414392..fdab2a07990 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -107,16 +107,10 @@ module Notes
def do_commands(note, update_params, message, command_names, only_commands)
return if quick_actions_service.commands_executed_count.to_i == 0
- if update_params.present?
- invalid_message = validate_commands(note, update_params)
-
- if invalid_message
- note.errors.add(:validation, invalid_message)
- message = invalid_message
- else
- quick_actions_service.apply_updates(update_params, note)
- note.commands_changes = update_params
- end
+ update_error = quick_actions_update_errors(note, update_params)
+ if update_error
+ note.errors.add(:validation, update_error)
+ message = update_error
end
# We must add the error after we call #save because errors are reset
@@ -129,6 +123,19 @@ module Notes
end
end
+ def quick_actions_update_errors(note, params)
+ return unless params.present?
+
+ invalid_message = validate_commands(note, params)
+ return invalid_message if invalid_message
+
+ service_response = quick_actions_service.apply_updates(params, note)
+ note.commands_changes = params
+ return if service_response.success?
+
+ service_response.message.join(', ')
+ end
+
def quick_action_options
{
merge_request_diff_head_sha: params[:merge_request_diff_head_sha],
diff --git a/app/services/notes/quick_actions_service.rb b/app/services/notes/quick_actions_service.rb
index 38f7a23ce29..cba7398ebc0 100644
--- a/app/services/notes/quick_actions_service.rb
+++ b/app/services/notes/quick_actions_service.rb
@@ -50,7 +50,21 @@ module Notes
update_params[:spend_time][:note_id] = note.id
end
- noteable_update_service(note, update_params).execute(note.noteable)
+ execute_update_service(note, update_params)
+ end
+
+ private
+
+ def execute_update_service(note, params)
+ service_response = noteable_update_service(note, params).execute(note.noteable)
+
+ service_errors = if service_response.respond_to?(:errors)
+ service_response.errors.full_messages
+ elsif service_response.respond_to?(:[]) && service_response[:status] == :error
+ service_response[:message]
+ end
+
+ service_errors.blank? ? ServiceResponse.success : ServiceResponse.error(message: service_errors)
end
def noteable_update_service(note, update_params)
diff --git a/app/validators/json_schemas/abuse_event_metadata.json b/app/validators/json_schemas/abuse_event_metadata.json
new file mode 100644
index 00000000000..b24ec93f877
--- /dev/null
+++ b/app/validators/json_schemas/abuse_event_metadata.json
@@ -0,0 +1,7 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "description": "Metadata to support an abuse event",
+ "type": "object",
+ "properties": {
+ }
+}
diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml
index b8022f8a780..8e55977fe7a 100644
--- a/app/views/devise/passwords/new.html.haml
+++ b/app/views/devise/passwords/new.html.haml
@@ -1,21 +1,23 @@
.login-box
.login-body
- = gitlab_ui_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, class: 'gl-show-field-errors' }) do |f|
+ = gitlab_ui_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post, class: 'gl-p-5 gl-show-field-errors', aria: { live: 'assertive' }}) do |f|
.devise-errors
= render "devise/shared/error_messages", resource: resource
- .form-group.gl-px-5.gl-pt-5
- = f.label :email, class: ("gl-mb-1" if Feature.enabled?(:restyle_login_page))
+ .form-group
+ = f.label :email, _('Email')
= f.email_field :email, class: "form-control gl-form-input", required: true, autocomplete: 'off', value: params[:user_email], autofocus: true, title: _('Please provide a valid email address.')
.form-text.text-muted
= _('Requires a verified GitLab email address.')
- if recaptcha_enabled?
- .gl-px-5
+ .gl-mb-5
= recaptcha_tags nonce: content_security_policy_nonce
- .gl-p-5
- = render Pajamas::ButtonComponent.new(type: :submit, variant: :confirm, block: true) do
- = _('Reset password')
+ = render Pajamas::ButtonComponent.new(type: :submit, variant: :confirm, block: true) do
+ = _('Reset password')
-.clearfix.prepend-top-20
+- if Feature.enabled?(:restyle_login_page, @project)
= render 'devise/shared/sign_in_link'
+- else
+ .gl-mt-3
+ = render 'devise/shared/sign_in_link'