Class: Types::ProjectType
Constant Summary
Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
Class Method Summary
collapse
Instance Method Summary
collapse
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
#_additional_removed_items, #_deletion_scheduled_in_hierarchy_chain_message, #_parent_deletion_scheduled_message, #_permanently_delete_group_message, #_project_delete_button_shared_data, #_remove_group_warning, #_self_deletion_in_progress_message, #_self_deletion_scheduled_message, #confirm_remove_group_message, #delete_delayed_namespace_message, #delete_immediately_namespace_scheduled_for_deletion_message, #deletion_in_progress_or_scheduled_in_hierarchy_chain?, #group_confirm_modal_data, #permanent_deletion_date_formatted, #project_delete_delayed_button_data, #project_delete_immediately_button_data, #restore_namespace_path, #restore_namespace_scheduled_for_deletion_message, #restore_namespace_title, #self_or_ancestors_deletion_in_progress_or_scheduled_message
Methods inherited from BaseObject
accepts, assignable?, authorization, authorize, authorized?, #current_user, #id
#present, #unpresented
Class Method Details
.authorization_scopes ⇒ Object
14
15
16
|
# File 'app/graphql/types/project_type.rb', line 14
def self.authorization_scopes
super + [:ai_workflows]
end
|
Instance Method Details
#admin_edit_path ⇒ Object
1183
1184
1185
1186
1187
|
# File 'app/graphql/types/project_type.rb', line 1183
def admin_edit_path
::Gitlab::Routing.url_helpers.edit_admin_namespace_project_path(
{ id: project.to_param, namespace_id: project.namespace.to_param }
)
end
|
#admin_show_path ⇒ Object
1177
1178
1179
1180
1181
|
# File 'app/graphql/types/project_type.rb', line 1177
def admin_show_path
::Gitlab::Routing.url_helpers.admin_namespace_project_path(
{ id: project.to_param, namespace_id: project.namespace.to_param }
)
end
|
#ci_config_variables(ref:, fail_on_cache_miss: false) ⇒ Object
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
|
# File 'app/graphql/types/project_type.rb', line 1072
def ci_config_variables(ref:, fail_on_cache_miss: false)
result = ::Ci::ListConfigVariablesService.new(object, context[:current_user]).execute(ref)
if result.nil? && fail_on_cache_miss
raise_resource_not_available_error! "Failed to retrieve CI/CD variables from cache."
end
return if result.nil?
result.map do |var_key, var_config|
{ key: var_key, **var_config }
end
end
|
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
|
# File 'app/graphql/types/project_type.rb', line 1050
def ci_pipeline_creation_inputs(ref:)
response = ::Ci::PipelineCreation::FindPipelineInputsService.new(
current_user: context[:current_user],
project: object,
ref: ref).execute
raise Gitlab::Graphql::Errors::ArgumentError, response.message if response.error?
response.payload[:inputs].all_inputs.map do |input|
{
name: input.name,
type: input.type,
default: input.default,
description: input.description,
regex: input.regex,
required?: input.required?,
options: input.options,
rules: input.rules
}
end
end
|
#ci_pipeline_creation_request(request_id:) ⇒ Object
932
933
934
|
# File 'app/graphql/types/project_type.rb', line 932
def ci_pipeline_creation_request(request_id:)
::Ci::PipelineCreation::Requests.get_request(object, request_id)
end
|
#container_protection_tag_rules ⇒ Object
969
970
971
972
|
# File 'app/graphql/types/project_type.rb', line 969
def container_protection_tag_rules
object.container_registry_protection_tag_rules.mutable
end
|
#container_repositories_count ⇒ Object
1046
1047
1048
|
# File 'app/graphql/types/project_type.rb', line 1046
def container_repositories_count
project.container_repositories.size
end
|
#edit_path ⇒ Object
1173
1174
1175
|
# File 'app/graphql/types/project_type.rb', line 1173
def edit_path
::Gitlab::Routing.url_helpers.edit_project_path(project)
end
|
#explore_catalog_path ⇒ Object
1032
1033
1034
1035
1036
|
# File 'app/graphql/types/project_type.rb', line 1032
def explore_catalog_path
return unless project.catalog_resource
Gitlab::Routing.url_helpers.explore_catalog_path(project.catalog_resource)
end
|
#forks_count ⇒ Object
1018
1019
1020
|
# File 'app/graphql/types/project_type.rb', line 1018
def forks_count
BatchLoader::GraphQL.wrap(object.forks_count)
end
|
#grafana_integration ⇒ Object
1189
1190
1191
|
# File 'app/graphql/types/project_type.rb', line 1189
def grafana_integration
nil
end
|
#is_catalog_resource ⇒ Object
rubocop:disable Naming/PredicateName
1022
1023
1024
1025
1026
1027
1028
1029
1030
|
# File 'app/graphql/types/project_type.rb', line 1022
def is_catalog_resource lazy_catalog_resource = BatchLoader::GraphQL.for(object.id).batch do |project_ids, loader|
::Ci::Catalog::Resource.for_projects(project_ids).each do |catalog_resource|
loader.call(catalog_resource.project_id, catalog_resource)
end
end
Gitlab::Graphql::Lazy.with_value(lazy_catalog_resource, &:present?)
end
|
#is_published ⇒ Object
rubocop:disable Naming/PredicateName – disabled to match the field name.
1038
1039
1040
|
# File 'app/graphql/types/project_type.rb', line 1038
def is_published project&.catalog_resource&.published?
end
|
#job(id:) ⇒ Object
1086
1087
1088
1089
|
# File 'app/graphql/types/project_type.rb', line 1086
def job(id:)
object.commit_statuses.find(id.model_id)
rescue ActiveRecord::RecordNotFound
end
|
#jobs_enabled ⇒ Object
1004
1005
1006
|
# File 'app/graphql/types/project_type.rb', line 1004
def jobs_enabled
object.feature_available?(:builds, context[:current_user])
end
|
#label(title:) ⇒ Object
960
961
962
963
964
965
966
967
|
# File 'app/graphql/types/project_type.rb', line 960
def label(title:)
BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args|
LabelsFinder
.new(current_user, project: args[:key], title: titles)
.execute
.each { |label| loader.call(label.title, label) }
end
end
|
#marked_for_deletion_on ⇒ Object
1161
1162
1163
|
# File 'app/graphql/types/project_type.rb', line 1161
def marked_for_deletion_on
project.marked_for_deletion_at
end
|
#max_access_level ⇒ Object
1139
1140
1141
1142
1143
1144
1145
1146
1147
|
# File 'app/graphql/types/project_type.rb', line 1139
def max_access_level
return Gitlab::Access::NO_ACCESS if current_user.nil?
BatchLoader::GraphQL.for(object.id).batch do |project_ids, loader|
current_user.max_member_access_for_project_ids(project_ids).each do |project_id, max_access_level|
loader.call(project_id, max_access_level)
end
end
end
|
#open_issues_count ⇒ Object
1008
1009
1010
|
# File 'app/graphql/types/project_type.rb', line 1008
def open_issues_count
BatchLoader::GraphQL.wrap(object.open_issues_count) if object.feature_available?(:issues, context[:current_user])
end
|
#open_merge_requests_count ⇒ Object
1012
1013
1014
1015
1016
|
# File 'app/graphql/types/project_type.rb', line 1012
def open_merge_requests_count
return unless object.feature_available?(:merge_requests, context[:current_user])
BatchLoader::GraphQL.wrap(object.open_merge_requests_count)
end
|
#organization_edit_path ⇒ Object
1149
1150
1151
1152
1153
1154
1155
1156
1157
|
# File 'app/graphql/types/project_type.rb', line 1149
def organization_edit_path
return if project.organization.nil?
::Gitlab::Routing.url_helpers.edit_namespace_projects_organization_path(
project.organization,
id: project.to_param,
namespace_id: project.namespace.to_param
)
end
|
#pages_force_https ⇒ Object
936
937
938
|
# File 'app/graphql/types/project_type.rb', line 936
def pages_force_https
project.pages_https_only?
end
|
#pages_use_unique_domain ⇒ Object
940
941
942
943
944
945
946
947
948
949
950
|
# File 'app/graphql/types/project_type.rb', line 940
def pages_use_unique_domain
lazy_project_settings = BatchLoader::GraphQL.for(object.id).batch do |project_ids, loader|
::ProjectSetting.for_projects(project_ids).each do |project_setting|
loader.call(project_setting.project_id, project_setting)
end
end
Gitlab::Graphql::Lazy.with_value(lazy_project_settings) do |settings|
(settings || object.project_setting).pages_unique_domain_enabled?
end
end
|
#permanent_deletion_date ⇒ Object
1165
1166
1167
|
# File 'app/graphql/types/project_type.rb', line 1165
def permanent_deletion_date
permanent_deletion_date_formatted(project) || permanent_deletion_date_formatted
end
|
#protectable_branches ⇒ Object
#sast_ci_configuration ⇒ Object
#service_desk_address ⇒ Object
1102
1103
1104
1105
1106
|
# File 'app/graphql/types/project_type.rb', line 1102
def service_desk_address
return unless Ability.allowed?(current_user, :admin_issue, project)
::ServiceDesk::Emails.new(object).address
end
|
#service_desk_enabled ⇒ Object
1108
1109
1110
|
# File 'app/graphql/types/project_type.rb', line 1108
def service_desk_enabled
::ServiceDesk.enabled?(project)
end
|
#statistics_details_paths ⇒ Object
#timelog_categories ⇒ Object
956
957
958
|
# File 'app/graphql/types/project_type.rb', line 956
def timelog_categories
object.project_namespace.timelog_categories if Feature.enabled?(:timelog_categories)
end
|
#visible_forks(minimum_access_level: nil) ⇒ Object
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
# File 'app/graphql/types/project_type.rb', line 1116
def visible_forks(minimum_access_level: nil)
if minimum_access_level.nil?
object.forks.public_or_visible_to_user(current_user)
else
return [] if current_user.nil?
object.forks.visible_to_user_and_access_level(current_user, minimum_access_level)
end
end
|
#web_path ⇒ Object
1169
1170
1171
|
# File 'app/graphql/types/project_type.rb', line 1169
def web_path
::Gitlab::Routing.url_helpers.project_path(project)
end
|