diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /lib/api/groups.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'lib/api/groups.rb')
-rw-r--r-- | lib/api/groups.rb | 61 |
1 files changed, 47 insertions, 14 deletions
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 |