diff options
Diffstat (limited to 'app/controllers/projects/clusters_controller.rb')
-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( |