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-12-22 00:07:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-22 00:07:34 +0300
commit909dcab6e1f82095408cf4adfe099b463f094301 (patch)
treed8b4ee0cf1a5313b75c7b039ae52b74d03c6bfd6 /app
parentd2f2219fd58e572c10d77183e2f65de8fcc8df96 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/security/configuration_controller.rb10
-rw-r--r--app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb4
-rw-r--r--app/graphql/mutations/work_items/create.rb10
-rw-r--r--app/graphql/resolvers/concerns/resolves_groups.rb28
-rw-r--r--app/graphql/resolvers/projects/fork_targets_resolver.rb11
-rw-r--r--app/graphql/types/ci/catalog/resources/version_type.rb18
-rw-r--r--app/graphql/types/work_items/widgets/notes_input_type.rb15
-rw-r--r--app/graphql/types/work_items/widgets/notes_type.rb4
-rw-r--r--app/models/ci/catalog/resources/version.rb4
-rw-r--r--app/models/project.rb7
-rw-r--r--app/models/projects/topic.rb9
-rw-r--r--app/models/work_items/widgets/notes.rb10
-rw-r--r--app/services/projects/unlink_fork_service.rb4
-rw-r--r--app/services/spam/spam_verdict_service.rb3
-rw-r--r--app/workers/ci/unlock_pipelines_in_queue_worker.rb3
15 files changed, 103 insertions, 37 deletions
diff --git a/app/controllers/projects/security/configuration_controller.rb b/app/controllers/projects/security/configuration_controller.rb
index ee2e60b5a1a..abf564a00e1 100644
--- a/app/controllers/projects/security/configuration_controller.rb
+++ b/app/controllers/projects/security/configuration_controller.rb
@@ -24,11 +24,7 @@ module Projects
private
def configuration
- if unify_configuration_enabled?
- configuration_presenter
- else
- {}
- end
+ configuration_presenter
end
def configuration_presenter
@@ -38,10 +34,6 @@ module Projects
def presenter_attributes
{}
end
-
- def unify_configuration_enabled?
- Feature.enabled?(:unify_security_configuration, project)
- end
end
end
end
diff --git a/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb b/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb
index 7aa78509bea..a5d9014af17 100644
--- a/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb
+++ b/app/graphql/mutations/concerns/mutations/work_items/update_arguments.rb
@@ -48,6 +48,10 @@ module Mutations
::Types::WorkItems::Widgets::AwardEmojiUpdateInputType,
required: false,
description: 'Input for emoji reactions widget.'
+ argument :notes_widget,
+ ::Types::WorkItems::Widgets::NotesInputType,
+ required: false,
+ description: 'Input for notes widget.'
end
end
end
diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb
index 7ce508e5ef1..754b453ce5d 100644
--- a/app/graphql/mutations/work_items/create.rb
+++ b/app/graphql/mutations/work_items/create.rb
@@ -60,6 +60,7 @@ module Mutations
def resolve(project_path: nil, namespace_path: nil, **attributes)
container_path = project_path || namespace_path
container = authorized_find!(container_path)
+ check_env_feature_available!(container)
check_feature_available!(container)
params = global_id_compatibility_params(attributes).merge(author_id: current_user.id)
@@ -83,6 +84,15 @@ module Mutations
private
+ # This is just a temporary measure while we migrate and backfill epic internal_ids
+ # More info in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139367
+ def check_env_feature_available!(container)
+ return unless container.is_a?(::Group) && Rails.env.production?
+
+ message = 'Group level work items are disabled. Only project paths allowed in `namespacePath`.'
+ raise Gitlab::Graphql::Errors::ArgumentError, message
+ end
+
def check_feature_available!(container)
return unless container.is_a?(::Group) && Feature.disabled?(:namespace_level_work_items, container)
diff --git a/app/graphql/resolvers/concerns/resolves_groups.rb b/app/graphql/resolvers/concerns/resolves_groups.rb
index 86dda5cb1cb..1673b1bd37f 100644
--- a/app/graphql/resolvers/concerns/resolves_groups.rb
+++ b/app/graphql/resolvers/concerns/resolves_groups.rb
@@ -5,6 +5,19 @@ module ResolvesGroups
extend ActiveSupport::Concern
include LooksAhead
+ PRELOADS = {
+ container_repositories_count: [:container_repositories],
+ custom_emoji: [:custom_emoji],
+ full_path: [:route],
+ path: [:route],
+ web_url: [:route],
+ dependency_proxy_blob_count: [:dependency_proxy_blobs],
+ dependency_proxy_blobs: [:dependency_proxy_blobs],
+ dependency_proxy_image_count: [:dependency_proxy_manifests],
+ dependency_proxy_image_ttl_policy: [:dependency_proxy_image_ttl_policy],
+ dependency_proxy_setting: [:dependency_proxy_setting]
+ }.freeze
+
def resolve_with_lookahead(...)
apply_lookahead(resolve_groups(...))
end
@@ -17,17 +30,8 @@ module ResolvesGroups
end
def preloads
- {
- container_repositories_count: [:container_repositories],
- custom_emoji: [:custom_emoji],
- full_path: [:route],
- path: [:route],
- web_url: [:route],
- dependency_proxy_blob_count: [:dependency_proxy_blobs],
- dependency_proxy_blobs: [:dependency_proxy_blobs],
- dependency_proxy_image_count: [:dependency_proxy_manifests],
- dependency_proxy_image_ttl_policy: [:dependency_proxy_image_ttl_policy],
- dependency_proxy_setting: [:dependency_proxy_setting]
- }
+ PRELOADS
end
end
+
+ResolvesGroups.prepend_mod
diff --git a/app/graphql/resolvers/projects/fork_targets_resolver.rb b/app/graphql/resolvers/projects/fork_targets_resolver.rb
index 5e8be325d43..27797b9f0af 100644
--- a/app/graphql/resolvers/projects/fork_targets_resolver.rb
+++ b/app/graphql/resolvers/projects/fork_targets_resolver.rb
@@ -3,7 +3,7 @@
module Resolvers
module Projects
class ForkTargetsResolver < BaseResolver
- include ResolvesGroups
+ include LooksAhead
include Gitlab::Graphql::Authorize::AuthorizeResource
type Types::NamespaceType.connection_type, null: true
@@ -17,10 +17,15 @@ module Resolvers
required: false,
description: 'Search query for path or name.'
+ def resolve_with_lookahead(**args)
+ fork_targets = ForkTargetsFinder.new(project, current_user).execute(args)
+ apply_lookahead(fork_targets)
+ end
+
private
- def resolve_groups(**args)
- ForkTargetsFinder.new(project, current_user).execute(args)
+ def preloads
+ ResolvesGroups::PRELOADS
end
end
end
diff --git a/app/graphql/types/ci/catalog/resources/version_type.rb b/app/graphql/types/ci/catalog/resources/version_type.rb
index 689f649afc5..87876b74f77 100644
--- a/app/graphql/types/ci/catalog/resources/version_type.rb
+++ b/app/graphql/types/ci/catalog/resources/version_type.rb
@@ -21,13 +21,21 @@ module Types
alpha: { milestone: '16.7' }
field :tag_name, GraphQL::Types::String, null: true, method: :name,
- description: 'Name of the tag associated with the version.',
+ description: 'Deprecated in 16.8. Use name.',
alpha: { milestone: '16.7' }
- field :tag_path, GraphQL::Types::String, null: true,
- description: 'Relative web path to the tag associated with the version.',
+ field :name, GraphQL::Types::String, null: true,
+ description: 'Name that uniquely identifies the version within the catalog resource.',
+ alpha: { milestone: '16.8' }
+
+ field :tag_path, GraphQL::Types::String, null: true, method: :path,
+ description: 'Deprecated in 16.8. Use path.',
alpha: { milestone: '16.7' }
+ field :path, GraphQL::Types::String, null: true,
+ description: 'Relative web path to the version.',
+ alpha: { milestone: '16.8' }
+
field :author, Types::UserType, null: true, description: 'User that created the version.',
alpha: { milestone: '16.7' }
@@ -42,10 +50,6 @@ module Types
def author
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
end
-
- def tag_path
- Gitlab::Routing.url_helpers.project_tag_path(object.project, object.name)
- end
end
# rubocop: enable Graphql/AuthorizeTypes
end
diff --git a/app/graphql/types/work_items/widgets/notes_input_type.rb b/app/graphql/types/work_items/widgets/notes_input_type.rb
new file mode 100644
index 00000000000..fc7f4c84658
--- /dev/null
+++ b/app/graphql/types/work_items/widgets/notes_input_type.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module Types
+ module WorkItems
+ module Widgets
+ class NotesInputType < BaseInputObject
+ graphql_name 'WorkItemWidgetNotesInput'
+
+ argument :discussion_locked, GraphQL::Types::Boolean,
+ required: true,
+ description: 'Discussion lock attribute for notes widget of the work item.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/work_items/widgets/notes_type.rb b/app/graphql/types/work_items/widgets/notes_type.rb
index 199001649bb..4f7f1c3b4cc 100644
--- a/app/graphql/types/work_items/widgets/notes_type.rb
+++ b/app/graphql/types/work_items/widgets/notes_type.rb
@@ -12,6 +12,10 @@ module Types
implements Types::WorkItems::WidgetInterface
+ field :discussion_locked, GraphQL::Types::Boolean,
+ null: true,
+ description: 'Discussion lock attribute of the work item.'
+
# This field loads user comments, system notes and resource events as a discussion for an work item,
# raising the complexity considerably. In order to discourage fetching this field as part of fetching
# a list of issues we raise the complexity
diff --git a/app/models/ci/catalog/resources/version.rb b/app/models/ci/catalog/resources/version.rb
index 4273c4515bc..e3d3ac7b513 100644
--- a/app/models/ci/catalog/resources/version.rb
+++ b/app/models/ci/catalog/resources/version.rb
@@ -122,6 +122,10 @@ module Ci
project.commit_by(oid: sha)
end
+ def path
+ Gitlab::Routing.url_helpers.project_tag_path(project, name)
+ end
+
private
def update_catalog_resource
diff --git a/app/models/project.rb b/app/models/project.rb
index 3ebdc0a72fc..35a664f080a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -3237,8 +3237,11 @@ class Project < ApplicationRecord
if @topic_list != self.topic_list
self.topics.delete_all
- self.topics = @topic_list.map do |topic|
- Projects::Topic.where('lower(name) = ?', topic.downcase).order(total_projects_count: :desc).first_or_create(name: topic, title: topic)
+ self.topics = @topic_list.map do |topic_name|
+ Projects::Topic
+ .where('lower(name) = ?', topic_name.downcase)
+ .order(total_projects_count: :desc)
+ .first_or_create(name: topic_name, title: topic_name, slug: Gitlab::Slug::Path.new(topic_name).generate)
end
end
diff --git a/app/models/projects/topic.rb b/app/models/projects/topic.rb
index 347d65841ed..a3622150351 100644
--- a/app/models/projects/topic.rb
+++ b/app/models/projects/topic.rb
@@ -7,9 +7,18 @@ module Projects
include Avatarable
include Gitlab::SQL::Pattern
+ SLUG_ALLOWED_REGEX = %r{\A[a-zA-Z0-9_\-.]+\z}
+
validates :name, presence: true, length: { maximum: 255 }
validates :name, uniqueness: { case_sensitive: false }, if: :name_changed?
validate :validate_name_format, if: :name_changed?
+
+ validates :slug,
+ length: { maximum: 255 },
+ uniqueness: { case_sensitive: false },
+ format: { with: SLUG_ALLOWED_REGEX, message: "can contain only letters, digits, '_', '-', '.'" },
+ if: :slug_changed?
+
validates :title, presence: true, length: { maximum: 255 }, on: :create
validates :description, length: { maximum: 1024 }
diff --git a/app/models/work_items/widgets/notes.rb b/app/models/work_items/widgets/notes.rb
index bde94ea8f43..67ee19f4947 100644
--- a/app/models/work_items/widgets/notes.rb
+++ b/app/models/work_items/widgets/notes.rb
@@ -4,8 +4,18 @@ module WorkItems
module Widgets
class Notes < Base
delegate :notes, to: :work_item
+ delegate :discussion_locked, to: :work_item
+
delegate_missing_to :work_item
+ def self.quick_action_commands
+ [:lock, :unlock]
+ end
+
+ def self.quick_action_params
+ [:discussion_locked]
+ end
+
def declarative_policy_delegate
work_item
end
diff --git a/app/services/projects/unlink_fork_service.rb b/app/services/projects/unlink_fork_service.rb
index cdd1870858e..dbac59dd32b 100644
--- a/app/services/projects/unlink_fork_service.rb
+++ b/app/services/projects/unlink_fork_service.rb
@@ -46,9 +46,7 @@ module Projects
end
# rubocop: enable Cop/InBatches
- if Feature.enabled?(:refresh_statistics_on_unlink_fork, @project.namespace) && refresh_statistics
- ProjectCacheWorker.perform_async(project.id, [], [:repository_size])
- end
+ ProjectCacheWorker.perform_async(project.id, [], [:repository_size]) if refresh_statistics
# When the project getting out of the network is a node with parent
# and children, both the parent and the node needs a cache refresh.
diff --git a/app/services/spam/spam_verdict_service.rb b/app/services/spam/spam_verdict_service.rb
index 2d4bebc8b2b..f69ee255e01 100644
--- a/app/services/spam/spam_verdict_service.rb
+++ b/app/services/spam/spam_verdict_service.rb
@@ -70,7 +70,8 @@ module Spam
result = spamcheck_client.spam?(spammable: target, user: user, context: context, extra_features: extra_features)
if result.evaluated?
- Abuse::TrustScore.create!(user: user, score: result.score, source: :spamcheck)
+ correlation_id = Labkit::Correlation::CorrelationId.current_id || ''
+ Abuse::TrustScoreWorker.perform_async(user.id, :spamcheck, result.score, correlation_id)
end
result.verdict
diff --git a/app/workers/ci/unlock_pipelines_in_queue_worker.rb b/app/workers/ci/unlock_pipelines_in_queue_worker.rb
index de579504711..e06291b9ca8 100644
--- a/app/workers/ci/unlock_pipelines_in_queue_worker.rb
+++ b/app/workers/ci/unlock_pipelines_in_queue_worker.rb
@@ -11,6 +11,7 @@ module Ci
feature_category :build_artifacts
idempotent!
+ MAX_RUNNING_EXTRA_LOW = 10
MAX_RUNNING_LOW = 50
MAX_RUNNING_MEDIUM = 500
MAX_RUNNING_HIGH = 1500
@@ -47,6 +48,8 @@ module Ci
elsif ::Feature.enabled?(:ci_unlock_pipelines, type: :ops)
# This is the default enabled flag
MAX_RUNNING_LOW
+ elsif ::Feature.enabled?(:ci_unlock_pipelines_extra_low, type: :ops)
+ MAX_RUNNING_EXTRA_LOW
else
0
end