diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/presenters/clusters/cluster_presenter.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/presenters/clusters/cluster_presenter.rb')
-rw-r--r-- | app/presenters/clusters/cluster_presenter.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb index c4e3393cac9..c0da5310ca4 100644 --- a/app/presenters/clusters/cluster_presenter.rb +++ b/app/presenters/clusters/cluster_presenter.rb @@ -2,6 +2,7 @@ module Clusters class ClusterPresenter < Gitlab::View::Presenter::Delegated + include ::Gitlab::Utils::StrongMemoize include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::UrlHelper include IconsHelper @@ -60,12 +61,53 @@ module Clusters end end + 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 + def read_only_kubernetes_platform_fields? !cluster.provided_by_user? end + 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-ultimate'), + 'add-dashboard-documentation-path': help_page_path('user/project/integrations/prometheus.md', anchor: 'adding-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 + private + def image_path(path) + ActionController::Base.helpers.image_path(path) + end + + # currently log explorer is only available in the scope of the project + # for group and instance level cluster selected project does not affects + # fetching logs from gitlab managed apps namespace, therefore any project + # available to user will be sufficient. + def logs_project + strong_memoize(:logs_project) do + cluster.all_projects.first + end + end + def clusterable if cluster.group_type? cluster.group |