summaryrefslogtreecommitdiff
path: root/app/controllers/groups/shared_projects_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/groups/shared_projects_controller.rb')
-rw-r--r--app/controllers/groups/shared_projects_controller.rb33
1 files changed, 33 insertions, 0 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..7dec1f5f402
--- /dev/null
+++ b/app/controllers/groups/shared_projects_controller.rb
@@ -0,0 +1,33 @@
+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]
+ # Don't show archived projects
+ params[:non_archived] = true
+ params.permit(:sort, :search, :non_archived)
+ end
+ end
+ end
+end