diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 2252ece68ce..3b7240d8469 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -28,6 +28,24 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def folder + @environments = project.environments + .where(environment_type: params[:id]) + .with_state(params[:scope] || :available) + + respond_to do |format| + format.html + format.json do + render json: { + environments: EnvironmentSerializer + .new(project: @project, user: @current_user) + .with_pagination(request, response) + .represent(@environments), + } + end + end + end + def show @deployments = environment.deployments.order(id: :desc).page(params[:page]) end diff --git a/config/routes/project.rb b/config/routes/project.rb index 2ac98cf3842..84f123ff717 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -156,6 +156,10 @@ constraints(ProjectUrlConstrainer.new) do get :terminal get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil } end + + collection do + get :folder, path: 'folders/:id' + end end resource :cycle_analytics, only: [:show]