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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-19 15:57:54 +0300
commit419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch)
tree1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /lib/api/entities
parent1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff)
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'lib/api/entities')
-rw-r--r--lib/api/entities/basic_project_details.rb4
-rw-r--r--lib/api/entities/bulk_import.rb1
-rw-r--r--lib/api/entities/bulk_imports/entity.rb1
-rw-r--r--lib/api/entities/diff.rb6
-rw-r--r--lib/api/entities/namespace.rb8
-rw-r--r--lib/api/entities/namespace_basic.rb2
-rw-r--r--lib/api/entities/project.rb4
-rw-r--r--lib/api/entities/user_basic.rb1
-rw-r--r--lib/api/entities/wiki_page.rb2
9 files changed, 20 insertions, 9 deletions
diff --git a/lib/api/entities/basic_project_details.rb b/lib/api/entities/basic_project_details.rb
index f89e5adca6d..fa247370606 100644
--- a/lib/api/entities/basic_project_details.rb
+++ b/lib/api/entities/basic_project_details.rb
@@ -41,6 +41,10 @@ module API
expose :namespace, using: 'API::Entities::NamespaceBasic'
expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
+ expose :repository_storage, documentation: { type: 'string', example: 'default' }, if: ->(project, options) {
+ Ability.allowed?(options[:current_user], :change_repository_storage, project)
+ }
+
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
# Preloading topics, should be done with using only `:topics`,
diff --git a/lib/api/entities/bulk_import.rb b/lib/api/entities/bulk_import.rb
index 75989cb4180..18f71048595 100644
--- a/lib/api/entities/bulk_import.rb
+++ b/lib/api/entities/bulk_import.rb
@@ -10,6 +10,7 @@ module API
expose :source_type, documentation: { type: 'string', example: 'gitlab' }
expose :created_at, documentation: { type: 'dateTime', example: '2012-05-28T04:42:42-07:00' }
expose :updated_at, documentation: { type: 'dateTime', example: '2012-05-28T04:42:42-07:00' }
+ expose :has_failures, documentation: { type: 'boolean', example: false }
end
end
end
diff --git a/lib/api/entities/bulk_imports/entity.rb b/lib/api/entities/bulk_imports/entity.rb
index 176d10b2580..7e9b9973e15 100644
--- a/lib/api/entities/bulk_imports/entity.rb
+++ b/lib/api/entities/bulk_imports/entity.rb
@@ -24,6 +24,7 @@ module API
expose :updated_at, documentation: { type: 'dateTime', example: '2012-05-28T04:42:42-07:00' }
expose :failures, using: EntityFailure, documentation: { is_array: true }
expose :migrate_projects, documentation: { type: 'boolean', example: true }
+ expose :has_failures, documentation: { type: 'boolean', example: false }
end
end
end
diff --git a/lib/api/entities/diff.rb b/lib/api/entities/diff.rb
index b9538893d32..cc53736a5b1 100644
--- a/lib/api/entities/diff.rb
+++ b/lib/api/entities/diff.rb
@@ -3,10 +3,12 @@
module API
module Entities
class Diff < Grape::Entity
- expose :json_safe_diff, as: :diff, documentation: {
+ expose :diff, documentation: {
type: 'string',
example: '@@ -71,6 +71,8 @@\n...'
- }
+ } do |instance, options|
+ options[:enable_unidiff] == true ? instance.unidiff : instance.json_safe_diff
+ end
expose :new_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' }
expose :old_path, documentation: { type: 'string', example: 'doc/update/5.4-to-6.0.md' }
expose :a_mode, documentation: { type: 'string', example: '100755' }
diff --git a/lib/api/entities/namespace.rb b/lib/api/entities/namespace.rb
index 5e0630e0f7f..012dc467a1c 100644
--- a/lib/api/entities/namespace.rb
+++ b/lib/api/entities/namespace.rb
@@ -11,11 +11,15 @@ module API
namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace)
end
- expose :root_repository_size, documentation: { type: 'integer', example: 123 }, if: -> (namespace, opts) { expose_root_repository_size?(namespace, opts) } do |namespace, _|
+ expose :root_repository_size, documentation: { type: 'integer', example: 123 }, if: -> (namespace, opts) { admin_request_for_group?(namespace, opts) } do |namespace, _|
namespace.root_storage_statistics&.repository_size
end
- def expose_root_repository_size?(namespace, opts)
+ expose :projects_count, documentation: { type: 'integer', example: 123 }, if: -> (namespace, opts) { admin_request_for_group?(namespace, opts) } do |namespace, _|
+ namespace.all_projects.count
+ end
+
+ def admin_request_for_group?(namespace, opts)
namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace)
end
end
diff --git a/lib/api/entities/namespace_basic.rb b/lib/api/entities/namespace_basic.rb
index 4264326cdc2..ccc472e7d51 100644
--- a/lib/api/entities/namespace_basic.rb
+++ b/lib/api/entities/namespace_basic.rb
@@ -13,7 +13,7 @@ module API
expose :web_url, documentation: { type: 'string', example: 'https://example.com/group/my_project' } do |namespace|
if namespace.user_namespace?
- Gitlab::Routing.url_helpers.user_url(namespace.owner)
+ Gitlab::Routing.url_helpers.user_url(namespace.owner || namespace.route.path)
else
namespace.web_url
end
diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb
index 0f947c85633..12e022bfb20 100644
--- a/lib/api/entities/project.rb
+++ b/lib/api/entities/project.rb
@@ -84,6 +84,7 @@ module API
expose(:feature_flags_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :feature_flags) }
expose(:infrastructure_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :infrastructure) }
expose(:monitor_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :monitor) }
+ expose(:model_experiments_access_level, documentation: { type: 'string', example: 'enabled' }) { |project, options| project_feature_string_access_level(project, :model_experiments) }
expose(:emails_disabled, documentation: { type: 'boolean' }) { |project, options| project.emails_disabled? }
expose :emails_enabled, documentation: { type: 'boolean' }
@@ -159,9 +160,6 @@ module API
}
expose :autoclose_referenced_issues, documentation: { type: 'boolean' }
- expose :repository_storage, documentation: { type: 'string', example: 'default' }, if: ->(project, options) {
- Ability.allowed?(options[:current_user], :change_repository_storage, project)
- }
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_resource(project)
diff --git a/lib/api/entities/user_basic.rb b/lib/api/entities/user_basic.rb
index 32e066b9f7e..9b1814251fe 100644
--- a/lib/api/entities/user_basic.rb
+++ b/lib/api/entities/user_basic.rb
@@ -4,6 +4,7 @@ module API
module Entities
class UserBasic < UserSafe
expose :state, documentation: { type: 'string', example: 'active' }
+ expose :access_locked?, as: :locked, documentation: { type: 'boolean' }
expose :avatar_url, documentation: { type: 'string', example: 'https://gravatar.com/avatar/1' } do |user, options|
user.avatar_url(only_path: false)
diff --git a/lib/api/entities/wiki_page.rb b/lib/api/entities/wiki_page.rb
index 9d2a031cee8..0f3fdd586a3 100644
--- a/lib/api/entities/wiki_page.rb
+++ b/lib/api/entities/wiki_page.rb
@@ -15,7 +15,7 @@ module API
current_user: options[:current_user]
)
else
- wiki_page.content
+ wiki_page.raw_content
end
end