Commit 3de1ba6c authored by Matija Čupić's avatar Matija Čupić

Move cluster sourcing from before_action to #index

parent 899a8095
class Projects::ClustersController < Projects::ApplicationController class Projects::ClustersController < Projects::ApplicationController
before_action :cluster, except: [:login, :index, :new, :new_gcp, :create] before_action :cluster, except: [:login, :index, :new, :new_gcp, :create]
before_action :clusters, only: [:index]
before_action :authorize_read_cluster! before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:new, :new_gcp, :create] before_action :authorize_create_cluster!, only: [:new, :new_gcp, :create]
before_action :authorize_google_api, only: [:new_gcp, :create] before_action :authorize_google_api, only: [:new_gcp, :create]
...@@ -8,8 +7,9 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -8,8 +7,9 @@ class Projects::ClustersController < Projects::ApplicationController
before_action :authorize_admin_cluster!, only: [:destroy] before_action :authorize_admin_cluster!, only: [:destroy]
def index def index
@clusters = Kaminari.paginate_array(@clusters).page(params[:page]).per(20)
@scope = params[:scope] @scope = params[:scope]
clusters = ClustersFinder.new(project, current_user, @scope).execute
@clusters = clusters.page(params[:page]).per(20)
@active_count = project.clusters.enabled.count @active_count = project.clusters.enabled.count
@inactive_count = project.clusters.disabled.count @inactive_count = project.clusters.disabled.count
@all_count = @active_count + @inactive_count @all_count = @active_count + @inactive_count
...@@ -102,12 +102,6 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -102,12 +102,6 @@ class Projects::ClustersController < Projects::ApplicationController
@cluster ||= project.clusters.find_by(id: params[:id])&.present(current_user: current_user) || render_404 @cluster ||= project.clusters.find_by(id: params[:id])&.present(current_user: current_user) || render_404
end end
def clusters
@scope = params[:scope] || 'all'
scope = @scope&.to_sym
@clusters = ClustersFinder.new(project, current_user, scope).execute
end
def create_params def create_params
params.require(:cluster).permit( params.require(:cluster).permit(
:enabled, :enabled,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment