From 9f46488805e86b1bc341ea1620b866016c2ce5ed Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 20 May 2020 14:34:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-0-stable-ee --- lib/api/groups.rb | 61 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 14 deletions(-) (limited to 'lib/api/groups.rb') diff --git a/lib/api/groups.rb b/lib/api/groups.rb index d375c35e8c0..353c8b4b242 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -60,18 +60,14 @@ module API .execute end - def find_group_projects(params) + def find_group_projects(params, finder_options) group = find_group!(params[:id]) - options = { - only_owned: !params[:with_shared], - include_subgroups: params[:include_subgroups] - } projects = GroupProjectsFinder.new( group: group, current_user: current_user, params: project_finder_params, - options: options + options: finder_options ).execute projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled] projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled] @@ -80,11 +76,22 @@ module API paginate(projects) end + def present_projects(params, projects) + options = { + with: params[:simple] ? Entities::BasicProjectDetails : Entities::Project, + current_user: current_user + } + + projects, options = with_custom_attributes(projects, options) + + present options[:with].prepare_relation(projects), options + end + def present_groups(params, groups) options = { with: Entities::Group, current_user: current_user, - statistics: params[:statistics] && current_user.admin? + statistics: params[:statistics] && current_user&.admin? } groups = groups.with_statistics if options[:statistics] @@ -226,16 +233,42 @@ module API use :optional_projects_params end get ":id/projects" do - projects = find_group_projects(params) - - options = { - with: params[:simple] ? Entities::BasicProjectDetails : Entities::Project, - current_user: current_user + finder_options = { + only_owned: !params[:with_shared], + include_subgroups: params[:include_subgroups] } - projects, options = with_custom_attributes(projects, options) + projects = find_group_projects(params, finder_options) - present options[:with].prepare_relation(projects), options + present_projects(params, projects) + end + + desc 'Get a list of shared projects in this group' do + success Entities::Project + end + params do + optional :archived, type: Boolean, default: false, desc: 'Limit by archived status' + optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, + desc: 'Limit by visibility' + optional :search, type: String, desc: 'Return list of authorized projects matching the search criteria' + optional :order_by, type: String, values: %w[id name path created_at updated_at last_activity_at], + default: 'created_at', desc: 'Return projects ordered by field' + optional :sort, type: String, values: %w[asc desc], default: 'desc', + desc: 'Return projects sorted in ascending and descending order' + optional :simple, type: Boolean, default: false, + desc: 'Return only the ID, URL, name, and path of each project' + optional :starred, type: Boolean, default: false, desc: 'Limit by starred status' + optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature' + optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature' + optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'Limit by minimum access level of authenticated user on projects' + + use :pagination + use :with_custom_attributes + end + get ":id/projects/shared" do + projects = find_group_projects(params, { only_shared: true }) + + present_projects(params, projects) end desc 'Get a list of subgroups in this group.' do -- cgit v1.2.3