summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/clusters_helper.rb5
-rw-r--r--app/presenters/clusters/cluster_presenter.rb4
-rw-r--r--app/views/projects/clusters/_cluster.html.haml4
-rw-r--r--app/views/projects/clusters/index.html.haml2
4 files changed, 7 insertions, 8 deletions
diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb
deleted file mode 100644
index f8281c893fa..00000000000
--- a/app/helpers/clusters_helper.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-module ClustersHelper
- def can_toggle_cluster?(cluster)
- can?(current_user, :update_cluster, cluster) && cluster.created?
- end
-end
diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb
index 01cb59d0d44..a424da5ab24 100644
--- a/app/presenters/clusters/cluster_presenter.rb
+++ b/app/presenters/clusters/cluster_presenter.rb
@@ -5,5 +5,9 @@ module Clusters
def gke_cluster_url
"https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}" if gcp?
end
+
+ def can_toggle_cluster?
+ can?(current_user, :update_cluster, cluster) && created?
+ end
end
end
diff --git a/app/views/projects/clusters/_cluster.html.haml b/app/views/projects/clusters/_cluster.html.haml
index d292d68386c..18ca01d2d49 100644
--- a/app/views/projects/clusters/_cluster.html.haml
+++ b/app/views/projects/clusters/_cluster.html.haml
@@ -13,9 +13,9 @@
.table-mobile-header{ role: "rowheader" }
.table-mobile-content
%button{ type: "button",
- class: "js-toggle-cluster-list project-feature-toggle #{'is-checked' if cluster.enabled?} #{'is-disabled' if !can_toggle_cluster?(cluster)}",
+ class: "js-toggle-cluster-list project-feature-toggle #{'is-checked' if cluster.enabled?} #{'is-disabled' if !cluster.can_toggle_cluster?}",
"aria-label": s_("ClusterIntegration|Toggle Cluster"),
- disabled: !can_toggle_cluster?(cluster),
+ disabled: !cluster.can_toggle_cluster?,
data: { "enabled-text": s_("ClusterIntegration|Active"),
"disabled-text": s_("ClusterIntegration|Inactive"),
endpoint: namespace_project_cluster_path(@project.namespace, @project, cluster, format: :json) } }
diff --git a/app/views/projects/clusters/index.html.haml b/app/views/projects/clusters/index.html.haml
index c991a8db331..f14ec0594dd 100644
--- a/app/views/projects/clusters/index.html.haml
+++ b/app/views/projects/clusters/index.html.haml
@@ -20,5 +20,5 @@
= s_("ClusterIntegration|Project namespace")
.table-section.section-10{ role: "rowheader" }
- @clusters.each do |cluster|
- = render "cluster", cluster: cluster
+ = render "cluster", cluster: cluster.present(current_user: current_user)
= paginate @clusters, theme: "gitlab"