diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-10-06 02:45:15 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-10-06 02:45:15 +0900 |
commit | 6712762b9d6e0391b1a38ca17cc3d982a336bbf9 (patch) | |
tree | bbb3b008409a18aca0bbd86480ac4b52eb33668e /app | |
parent | d27b113b49c90ba7d184f0d7965b63e32d260ebf (diff) | |
download | gitlab-ce-6712762b9d6e0391b1a38ca17cc3d982a336bbf9.tar.gz |
Add ClusterPresenter. Fix Static Analysys.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/clusters_controller.rb | 2 | ||||
-rw-r--r-- | app/models/gcp/cluster.rb | 1 | ||||
-rw-r--r-- | app/presenters/gcp/cluster_presenter.rb | 9 | ||||
-rw-r--r-- | app/views/projects/clusters/show.html.haml | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index bd286b87a29..77644602b72 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -81,7 +81,7 @@ class Projects::ClustersController < Projects::ApplicationController private def cluster - @cluster ||= project.cluster + @cluster ||= project.cluster.present(current_user: current_user) end def create_params diff --git a/app/models/gcp/cluster.rb b/app/models/gcp/cluster.rb index 0e8b920741d..18bd6a6dcb4 100644 --- a/app/models/gcp/cluster.rb +++ b/app/models/gcp/cluster.rb @@ -1,6 +1,7 @@ module Gcp class Cluster < ActiveRecord::Base extend Gitlab::Gcp::Model + include Presentable belongs_to :project, inverse_of: :cluster belongs_to :user diff --git a/app/presenters/gcp/cluster_presenter.rb b/app/presenters/gcp/cluster_presenter.rb new file mode 100644 index 00000000000..f7908f92a37 --- /dev/null +++ b/app/presenters/gcp/cluster_presenter.rb @@ -0,0 +1,9 @@ +module Gcp + class ClusterPresenter < Gitlab::View::Presenter::Delegated + presents :cluster + + def gke_cluster_url + "https://console.cloud.google.com/kubernetes/clusters/details/#{gcp_cluster_zone}/#{gcp_cluster_name}" + end + end +end diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml index 48d9835d588..b7b4c3c389c 100644 --- a/app/views/projects/clusters/show.html.haml +++ b/app/views/projects/clusters/show.html.haml @@ -37,7 +37,7 @@ %label = s_('ClusterIntegration|Google container engine') %p - - link_gke = link_to(s_('ClusterIntegration|Google Container Engine'), '', target: '_blank', rel: 'noopener noreferrer') + - link_gke = link_to(s_('ClusterIntegration|Google Container Engine'), @cluster.gke_cluster_url, target: '_blank', rel: 'noopener noreferrer') = s_('ClusterIntegration|Manage your cluster by visiting %{link_gke}').html_safe % { link_gke: link_gke } .hidden.js-cluster-error.alert.alert-danger{ role: 'alert' } |