Class: Clusters::ClusterPresenter
Constant Summary
Constants included
from IconsHelper
IconsHelper::DEFAULT_ICON_SIZE
Instance Attribute Summary
#subject
Instance Method Summary
collapse
#audit_icon, #boolean_to_icon, #custom_icon, #external_snippet_icon, #file_type_icon_class, #icon, #loading_icon, #spinner, #sprite_file_icons_path, #sprite_icon, #sprite_icon_path, #visibility_level_icon
#clear_memoization, #strong_memoize, #strong_memoized?
#initialize
#can?, #declarative_policy_delegate, #is_a?, #present, #url_builder, #web_path, #web_url
#can?
add_helpers, includes_helpers, redirect_legacy_paths, url_helpers
Instance Method Details
#can_read_cluster? ⇒ Boolean
38
39
40
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 38
def can_read_cluster?
can?(current_user, :read_cluster, cluster)
end
|
#cluster_type_description ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 42
def cluster_type_description
if cluster.project_type?
s_("ClusterIntegration|Project cluster")
elsif cluster.group_type?
s_("ClusterIntegration|Group cluster")
elsif cluster.instance_type?
s_("ClusterIntegration|Instance cluster")
end
end
|
#gitlab_managed_apps_logs_path ⇒ Object
64
65
66
67
68
69
70
71
72
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 64
def gitlab_managed_apps_logs_path
return unless logs_project && can_read_cluster?
if cluster.application_elastic_stack&.available?
elasticsearch_project_logs_path(logs_project, cluster_id: cluster.id, format: :json)
else
k8s_project_logs_path(logs_project, cluster_id: cluster.id, format: :json)
end
end
|
#health_data(clusterable) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 78
def health_data(clusterable)
{
'clusters-path': clusterable.index_path,
'dashboard-endpoint': clusterable.metrics_dashboard_path(cluster),
'documentation-path': help_page_path('user/project/clusters/index', anchor: 'monitoring-your-kubernetes-cluster'),
'add-dashboard-documentation-path': help_page_path('operations/metrics/dashboards/index.md', anchor: 'add-a-new-dashboard-to-your-project'),
'empty-getting-started-svg-path': image_path('illustrations/monitoring/getting_started.svg'),
'empty-loading-svg-path': image_path('illustrations/monitoring/loading.svg'),
'empty-no-data-svg-path': image_path('illustrations/monitoring/no_data.svg'),
'empty-no-data-small-svg-path': image_path('illustrations/chart-empty-state-small.svg'),
'empty-unable-to-connect-svg-path': image_path('illustrations/monitoring/unable_to_connect.svg'),
'settings-path': '',
'project-path': '',
'tags-path': ''
}
end
|
#item_link(clusterable_presenter, *html_options) ⇒ Object
We do not want to show the group path for clusters belonging to the clusterable, only for the ancestor clusters.
14
15
16
17
18
19
20
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 14
def item_link(clusterable_presenter, *html_options)
if cluster.group_type? && clusterable != clusterable_presenter.subject
contracted_group_name(cluster.group) + ' / ' + link_to_cluster
else
link_to_cluster(*html_options)
end
end
|
#provider_label ⇒ Object
22
23
24
25
26
27
28
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 22
def provider_label
if aws?
s_('ClusterIntegration|Elastic Kubernetes Service')
elsif gcp?
s_('ClusterIntegration|Google Kubernetes Engine')
end
end
|
#provider_management_url ⇒ Object
30
31
32
33
34
35
36
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 30
def provider_management_url
if aws?
"https://console.aws.amazon.com/eks/home?region=#{provider.region}\#/clusters/#{name}"
elsif gcp?
"https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}"
end
end
|
74
75
76
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 74
def read_only_kubernetes_platform_fields?
!cluster.provided_by_user?
end
|
#show_path ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/presenters/clusters/cluster_presenter.rb', line 52
def show_path
if cluster.project_type?
project_cluster_path(project, cluster)
elsif cluster.group_type?
group_cluster_path(group, cluster)
elsif cluster.instance_type?
admin_cluster_path(cluster)
else
raise NotImplementedError
end
end
|