diff options
author | Matija Čupić <matteeyah@gmail.com> | 2017-12-05 17:09:04 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2017-12-05 17:09:04 +0100 |
commit | 83648f243d6a1798b89eb7959c179d9fbd159c85 (patch) | |
tree | 8db502a5f1d4873758db6fc3d953c5d329aac614 /app | |
parent | 2eb41b5a420d3c755566f23a5839c1b9f2014ba8 (diff) | |
download | gitlab-ce-83648f243d6a1798b89eb7959c179d9fbd159c85.tar.gz |
Move can_toggle_cluster? from helper to presenter
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/clusters_helper.rb | 5 | ||||
-rw-r--r-- | app/presenters/clusters/cluster_presenter.rb | 4 | ||||
-rw-r--r-- | app/views/projects/clusters/_cluster.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/clusters/index.html.haml | 2 |
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 4dd956971ae..104e39b0e06 100644 --- a/app/views/projects/clusters/index.html.haml +++ b/app/views/projects/clusters/index.html.haml @@ -14,7 +14,7 @@ = 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" - elsif @scope == 'all' = render "empty_state" |