diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-05-30 15:31:15 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-05-30 15:31:15 +0300 |
commit | 37613eaa060b39a8862d27b10fbbe7ed6fd9025b (patch) | |
tree | d699dd7c413b067ef6200f355006a509b091d262 /app | |
parent | b703e907c9802e92b1cdeff5a0e5f138de950264 (diff) | |
parent | df98eeabe481228d8befaf137deca5def64fd3bc (diff) |
Merge branch 'bvl-group-shared-projects-private-api' into 'master'
Add `shared_projects` endpoint
Closes #46800
See merge request gitlab-org/gitlab-ce!19141
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/groups/shared_projects_controller.rb | 31 | ||||
-rw-r--r-- | app/serializers/group_child_entity.rb | 2 |
2 files changed, 32 insertions, 1 deletions
diff --git a/app/controllers/groups/shared_projects_controller.rb b/app/controllers/groups/shared_projects_controller.rb new file mode 100644 index 00000000000..f2f835767e0 --- /dev/null +++ b/app/controllers/groups/shared_projects_controller.rb @@ -0,0 +1,31 @@ +module Groups + class SharedProjectsController < Groups::ApplicationController + respond_to :json + before_action :group + skip_cross_project_access_check :index + + def index + shared_projects = GroupProjectsFinder.new( + group: group, + current_user: current_user, + params: finder_params, + options: { only_shared: true } + ).execute + serializer = GroupChildSerializer.new(current_user: current_user) + .with_pagination(request, response) + + render json: serializer.represent(shared_projects) + end + + private + + def finder_params + @finder_params ||= begin + # Make the `search` param consistent for the frontend, + # which will be using `filter`. + params[:search] ||= params[:filter] if params[:filter] + params.permit(:sort, :search) + end + end + end +end diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb index 15ec0f89bb2..ee150eefd9e 100644 --- a/app/serializers/group_child_entity.rb +++ b/app/serializers/group_child_entity.rb @@ -31,7 +31,7 @@ class GroupChildEntity < Grape::Entity end # Project only attributes - expose :star_count, + expose :star_count, :archived, if: lambda { |_instance, _options| project? } # Group only attributes |