Module: ClustersHelper
- Defined in:
- app/helpers/clusters_helper.rb
Instance Method Summary collapse
- #can_admin_cluster?(user, cluster) ⇒ Boolean
- #cluster_created?(cluster) ⇒ Boolean
- #cluster_type_label(cluster_type) ⇒ Object
- #create_new_cluster_label(provider: nil) ⇒ Object
- #has_rbac_enabled?(cluster) ⇒ Boolean
- #js_cluster_form_data(cluster, can_edit) ⇒ Object
- #js_cluster_new ⇒ Object
- #js_clusters_list_data(path = nil) ⇒ Object
- #project_cluster?(cluster) ⇒ Boolean
-
#provider_icon(provider = nil) ⇒ Object
This method is depreciated and will be removed when associated HAML files are moved to JavaScript.
- #render_cluster_info_tab_content(tab, expanded) ⇒ Object
- #render_gcp_signup_offer ⇒ Object
Instance Method Details
#can_admin_cluster?(user, cluster) ⇒ Boolean
108 109 110 |
# File 'app/helpers/clusters_helper.rb', line 108 def can_admin_cluster?(user, cluster) can?(user, :admin_cluster, cluster) end |
#cluster_created?(cluster) ⇒ Boolean
104 105 106 |
# File 'app/helpers/clusters_helper.rb', line 104 def cluster_created?(cluster) !cluster.status_name.in?(%i/scheduled creating/) end |
#cluster_type_label(cluster_type) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/clusters_helper.rb', line 77 def cluster_type_label(cluster_type) case cluster_type when 'project_type' s_('ClusterIntegration|Project cluster') when 'group_type' s_('ClusterIntegration|Group cluster') when 'instance_type' s_('ClusterIntegration|Instance cluster') else Gitlab::ErrorTracking.track_and_raise_for_dev_exception( ArgumentError.new('Cluster Type Missing'), cluster_error: { error: 'Cluster Type Missing', cluster_type: cluster_type } ) _('Cluster') end end |
#create_new_cluster_label(provider: nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/helpers/clusters_helper.rb', line 4 def create_new_cluster_label(provider: nil) case provider when 'aws' s_('ClusterIntegration|Create new cluster on EKS') when 'gcp' s_('ClusterIntegration|Create new cluster on GKE') else s_('ClusterIntegration|Create new cluster') end end |
#has_rbac_enabled?(cluster) ⇒ Boolean
94 95 96 97 98 |
# File 'app/helpers/clusters_helper.rb', line 94 def has_rbac_enabled?(cluster) return cluster.platform_kubernetes_rbac? if cluster.platform_kubernetes cluster.provider.has_rbac_enabled? end |
#js_cluster_form_data(cluster, can_edit) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/clusters_helper.rb', line 27 def js_cluster_form_data(cluster, can_edit) { enabled: cluster.enabled?.to_s, editable: can_edit.to_s, environment_scope: cluster.environment_scope, base_domain: cluster.base_domain, application_ingress_external_ip: cluster.application_ingress_external_ip, auto_devops_help_path: help_page_path('topics/autodevops/index'), external_endpoint_help_path: help_page_path('user/clusters/applications.md', anchor: 'pointing-your-dns-at-the-external-endpoint') } end |
#js_cluster_new ⇒ Object
39 40 41 42 43 |
# File 'app/helpers/clusters_helper.rb', line 39 def js_cluster_new { cluster_connect_help_path: help_page_path('user/project/clusters/add_remove_clusters', anchor: 'add-existing-cluster') } end |
#js_clusters_list_data(path = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/clusters_helper.rb', line 15 def js_clusters_list_data(path = nil) { ancestor_help_path: help_page_path('user/group/clusters/index', anchor: 'cluster-precedence'), endpoint: path, img_tags: { aws: { path: image_path('illustrations/logos/amazon_eks.svg'), text: s_('ClusterIntegration|Amazon EKS') }, default: { path: image_path('illustrations/logos/kubernetes.svg'), text: _('Kubernetes Cluster') }, gcp: { path: image_path('illustrations/logos/google_gke.svg'), text: s_('ClusterIntegration|Google GKE') } } } end |
#project_cluster?(cluster) ⇒ Boolean
100 101 102 |
# File 'app/helpers/clusters_helper.rb', line 100 def project_cluster?(cluster) cluster.cluster_type.in?('project_type') end |
#provider_icon(provider = nil) ⇒ Object
This method is depreciated and will be removed when associated HAML files are moved to JavaScript
46 47 48 49 50 51 |
# File 'app/helpers/clusters_helper.rb', line 46 def provider_icon(provider = nil) img_data = js_clusters_list_data.dig(:img_tags, provider&.to_sym) || js_clusters_list_data.dig(:img_tags, :default) image_tag img_data[:path], alt: img_data[:text], class: 'gl-h-full' end |
#render_cluster_info_tab_content(tab, expanded) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/helpers/clusters_helper.rb', line 62 def render_cluster_info_tab_content(tab, ) case tab when 'environments' render_if_exists 'clusters/clusters/environments' when 'health' render_if_exists 'clusters/clusters/health' when 'apps' render 'applications' when 'settings' render 'advanced_settings_container' else render('details', expanded: ) end end |
#render_gcp_signup_offer ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/helpers/clusters_helper.rb', line 53 def render_gcp_signup_offer return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return unless show_gcp_signup_offer? content_tag :section, class: 'no-animate expanded' do render 'clusters/clusters/gcp_signup_offer_banner' end end |