Commit 6513028e authored by James Lopez's avatar James Lopez

Merge branch 'pl-extract-cluster-health-data' into 'master'

Extract health data configuration into a helper

See merge request gitlab-org/gitlab-ee!11715
parents 311ec363 683270d5
......@@ -13,5 +13,22 @@ module EE
def show_cluster_health_graphs?(cluster)
cluster.project_type? && cluster.project.feature_available?(:cluster_health)
end
def cluster_health_data(cluster)
project = cluster.project
{
'metrics-endpoint': metrics_project_cluster_path(project, cluster, format: :json),
'clusters-path': project_clusters_path(project),
'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'),
'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-unable-to-connect-svg-path': image_path('illustrations/monitoring/unable_to_connect.svg'),
'settings-path': '',
'project-path': '',
'tags-path': ''
}
end
end
end
......@@ -2,16 +2,7 @@
%h4= s_('ClusterIntegration|Cluster health')
- if @cluster&.application_prometheus_available?
#prometheus-graphs{ data: { "settings-path": edit_project_service_path(@project, 'prometheus'),
"clusters-path": project_clusters_path(@project),
"documentation-path": help_page_path('administration/monitoring/prometheus/index.md'),
"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-unable-to-connect-svg-path": image_path('illustrations/monitoring/unable_to_connect.svg'),
"metrics-endpoint": metrics_namespace_project_cluster_path( format: :json ),
"project-path": project_path(@project),
"tags-path": project_tags_path(@project) } }
#prometheus-graphs{ data: cluster_health_data(@cluster) }
- else
%p.settings-message.text-center= s_("ClusterIntegration|In order to view the health of your cluster, you must first install Prometheus below.")
......@@ -62,4 +62,25 @@ describe ClustersHelper do
end
end
end
describe '#cluster_health_data' do
let(:project) { cluster.project }
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:cluster_presenter) { cluster.present }
it 'returns graph configuration' do
expect(cluster_health_data(cluster_presenter)).to eq(
'clusters-path': project_clusters_path(project),
'documentation-path': help_page_path('administration/monitoring/prometheus/index.md'),
'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-unable-to-connect-svg-path': image_path('illustrations/monitoring/unable_to_connect.svg'),
'metrics-endpoint': metrics_project_cluster_path(project, cluster, format: :json),
'settings-path': '',
'project-path': '',
'tags-path': ''
)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment