Commit 67c0d520 authored by Reuben Pereira's avatar Reuben Pereira Committed by Sean McGivern

Remove conditional from clusters/_health partial

- Since the condition is now being checked in the clusters/show view.
parent b59deb2e
......@@ -20,6 +20,11 @@ module ClustersHelper
!cluster.provider.legacy_abac?
end
# EE overrides this
def show_cluster_health_graphs?(cluster)
false
end
end
ClustersHelper.prepend(EE::ClustersHelper)
......@@ -34,7 +34,7 @@
= render 'banner'
= render 'form'
= render_if_exists 'health'
= render_if_exists 'projects/clusters/prometheus_graphs' if show_cluster_health_graphs?(@cluster)
.cluster-applications-table#js-cluster-applications
......
......@@ -8,5 +8,10 @@ module EE
def has_multiple_clusters?
clusterable.feature_available?(:multiple_clusters)
end
override :show_cluster_health_graphs?
def show_cluster_health_graphs?(cluster)
cluster.project_type? && cluster.project.feature_available?(:cluster_health)
end
end
end
- if @cluster.project_type? && @cluster.project.feature_available?(:cluster_health)
%section.settings.no-animate.expanded.cluster-health-graphs#cluster-health
%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) } }
- else
%p.settings-message.text-center= s_("ClusterIntegration|In order to view the health of your cluster, you must first install Prometheus below.")
%section.settings.no-animate.expanded.cluster-health-graphs#cluster-health
%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) } }
- else
%p.settings-message.text-center= s_("ClusterIntegration|In order to view the health of your cluster, you must first install Prometheus below.")
---
title: Correct path to cluster health partial
merge_request: 10638
author:
type: fixed
......@@ -29,4 +29,37 @@ describe ClustersHelper do
it { is_expected.to be_falsey }
end
end
describe '#show_cluster_health_graphs?' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:cluster_presenter) { cluster.present }
before do
stub_licensed_features(cluster_health: true)
end
context 'with project level cluster' do
it 'returns true' do
expect(helper.show_cluster_health_graphs?(cluster_presenter)).to eq(true)
end
end
context 'with group level cluster' do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
it 'returns false' do
expect(helper.show_cluster_health_graphs?(cluster_presenter)).to eq(false)
end
end
context 'without cluster_health license' do
before do
stub_licensed_features(cluster_health: false)
end
it 'returns false' do
expect(helper.show_cluster_health_graphs?(cluster_presenter)).to eq(false)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'clusters/clusters/show' do
let(:user) { create(:user) }
let(:project) { create(:project) }
before do
allow(controller).to receive(:current_user).and_return(user)
end
context 'when the cluster details page is opened' do
before do
assign(:cluster, cluster_presenter)
allow(view).to receive(:clusterable).and_return(clusterable)
end
context 'with project level cluster' do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:clusterable) { ClusterablePresenter.fabricate(project, current_user: user) }
let(:cluster_presenter) { cluster.present(current_user: user) }
before do
stub_licensed_features(cluster_health: true)
end
it 'displays the Cluster health section' do
render
expect(rendered).to have_selector('#cluster-health')
expect(rendered).to have_content('Cluster health')
end
end
context 'with group level cluster' do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:clusterable) { ClusterablePresenter.fabricate(cluster.group, current_user: user) }
let(:cluster_presenter) { cluster.present(current_user: user) }
before do
stub_licensed_features(cluster_health: true)
end
it 'does not display cluster health section' do
render
expect(rendered).not_to have_selector('#cluster-health')
expect(rendered).not_to have_content('Cluster health')
end
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