diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-12-06 09:07:52 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-12-06 09:07:52 +0000 |
commit | 29c243b08d91194d46203a085f6857fe966bcdff (patch) | |
tree | ee2f443ce026ce271fc579a6933d0f572a64ac87 /app/controllers | |
parent | 67a94b2ff3b0d714549c7d30b3c6212f3046a3c2 (diff) | |
parent | 0ef16b272002013bbdb44517e62f0a1d15046cf5 (diff) | |
download | gitlab-ce-29c243b08d91194d46203a085f6857fe966bcdff.tar.gz |
Merge branch 'list-multiple-clusters' into 'master'
List multiple clusters
See merge request gitlab-org/gitlab-ce!15403
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index d18b6d4b78c..0907daacbc3 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -8,11 +8,11 @@ class Projects::ClustersController < Projects::ApplicationController STATUS_POLLING_INTERVAL = 10_000 def index - if project.cluster - redirect_to project_cluster_path(project, project.cluster) - else - redirect_to new_project_cluster_path(project) - end + @scope = params[:scope] || 'all' + @clusters = ClustersFinder.new(project, current_user, @scope).execute.page(params[:page]) + @active_count = ClustersFinder.new(project, current_user, :active).execute.count + @inactive_count = ClustersFinder.new(project, current_user, :inactive).execute.count + @all_count = @active_count + @inactive_count end def new @@ -39,10 +39,20 @@ class Projects::ClustersController < Projects::ApplicationController .execute(cluster) if cluster.valid? - flash[:notice] = "Cluster was successfully updated." - redirect_to project_cluster_path(project, project.cluster) + respond_to do |format| + format.json do + head :no_content + end + format.html do + flash[:notice] = "Cluster was successfully updated." + redirect_to project_cluster_path(project, cluster) + end + end else - render :show + respond_to do |format| + format.json { head :bad_request } + format.html { render :show } + end end end @@ -63,6 +73,19 @@ class Projects::ClustersController < Projects::ApplicationController .present(current_user: current_user) end + def create_params + params.require(:cluster).permit( + :enabled, + :name, + :provider_type, + provider_gcp_attributes: [ + :gcp_project_id, + :zone, + :num_nodes, + :machine_type + ]) + end + def update_params if cluster.managed? params.require(:cluster).permit( |