Class: Types::ProjectType
Instance Method Summary
collapse
Methods inherited from BaseObject
accepts, assignable?, authorization, authorization_scopes, authorize, authorized?, #current_user, #id
#present, #unpresented
Instance Method Details
#avatar_url ⇒ Object
816
817
818
|
# File 'app/graphql/types/project_type.rb', line 816
def avatar_url
object.avatar_url(only_path: false)
end
|
#ci_config_variables(ref:) ⇒ Object
862
863
864
865
866
867
868
869
870
|
# File 'app/graphql/types/project_type.rb', line 862
def ci_config_variables(ref:)
result = ::Ci::ListConfigVariablesService.new(object, context[:current_user]).execute(ref)
return if result.nil?
result.map do |var_key, var_config|
{ key: var_key, **var_config }
end
end
|
#container_repositories_count ⇒ Object
858
859
860
|
# File 'app/graphql/types/project_type.rb', line 858
def container_repositories_count
project.container_repositories.size
end
|
#explore_catalog_path ⇒ Object
848
849
850
851
852
|
# File 'app/graphql/types/project_type.rb', line 848
def explore_catalog_path
return unless project.catalog_resource
Gitlab::Routing.url_helpers.explore_catalog_path(project.catalog_resource)
end
|
#forks_count ⇒ Object
834
835
836
|
# File 'app/graphql/types/project_type.rb', line 834
def forks_count
BatchLoader::GraphQL.wrap(object.forks_count)
end
|
#is_catalog_resource ⇒ Object
rubocop:disable Naming/PredicateName
838
839
840
841
842
843
844
845
846
|
# File 'app/graphql/types/project_type.rb', line 838
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
|
#job(id:) ⇒ Object
872
873
874
875
|
# File 'app/graphql/types/project_type.rb', line 872
def job(id:)
object.commit_statuses.find(id.model_id)
rescue ActiveRecord::RecordNotFound
end
|
#jobs_enabled ⇒ Object
820
821
822
|
# File 'app/graphql/types/project_type.rb', line 820
def jobs_enabled
object.feature_available?(:builds, context[:current_user])
end
|
#label(title:) ⇒ Object
777
778
779
780
781
782
783
784
|
# File 'app/graphql/types/project_type.rb', line 777
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
|
#max_access_level ⇒ Object
921
922
923
924
925
926
927
928
929
|
# File 'app/graphql/types/project_type.rb', line 921
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
824
825
826
|
# File 'app/graphql/types/project_type.rb', line 824
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
828
829
830
831
832
|
# File 'app/graphql/types/project_type.rb', line 828
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
931
932
933
934
935
936
937
938
939
|
# File 'app/graphql/types/project_type.rb', line 931
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
|
#protectable_branches ⇒ Object
#sast_ci_configuration ⇒ Object
#service_desk_address ⇒ Object
888
889
890
891
892
|
# File 'app/graphql/types/project_type.rb', line 888
def service_desk_address
return unless Ability.allowed?(current_user, :admin_issue, project)
object.service_desk_address
end
|
#statistics_details_paths ⇒ Object
#timelog_categories ⇒ Object
773
774
775
|
# File 'app/graphql/types/project_type.rb', line 773
def timelog_categories
object.project_namespace.timelog_categories if Feature.enabled?(:timelog_categories)
end
|
#visible_forks(minimum_access_level: nil) ⇒ Object
898
899
900
901
902
903
904
905
906
|
# File 'app/graphql/types/project_type.rb', line 898
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
|