Commit ea9b0b87 authored by Emily Ring's avatar Emily Ring

Display cluster type in cluster info page

Displays a badge next to the cluster name indicating the
type of cluster in the cluster info page.
parent 8d6978c9
......@@ -41,6 +41,23 @@ module ClustersHelper
end
end
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_exception(
ArgumentError.new,
cluster_error: { error: 'Cluster Type Missing', cluster_type: cluster_type }
)
_('Cluster')
end
end
def has_rbac_enabled?(cluster)
return cluster.platform_kubernetes_rbac? if cluster.platform_kubernetes
......
......@@ -41,7 +41,12 @@
.js-serverless-survey-banner{ data: { user_name: current_user.name, user_email: current_user.email } }
%h4= @cluster.name
.d-flex.my-3
.badge.badge-light.mr-2.py-2.px-3
= cluster_type_label(@cluster.cluster_type)
%h4.m-0
= @cluster.name
= render 'banner'
- if cluster_created?(@cluster)
......@@ -56,7 +61,3 @@
.tab-content.py-3
.tab-pane.active{ role: 'tabpanel' }
= render_cluster_info_tab_content(params[:tab], expanded_by_default?)
---
title: Display cluster type in cluster info page
merge_request: 27366
author:
type: added
......@@ -4079,6 +4079,9 @@ msgstr ""
msgid "Closes this %{quick_action_target}."
msgstr ""
msgid "Cluster"
msgstr ""
msgid "Cluster Health"
msgstr ""
......
......@@ -14,6 +14,12 @@ describe 'Clusterable > Show page' do
end
shared_examples 'show page' do
it 'displays cluster type label' do
visit cluster_path
expect(page).to have_content(cluster_type_label)
end
it 'allow the user to set domain' do
visit cluster_path
......@@ -125,7 +131,9 @@ describe 'Clusterable > Show page' do
clusterable.add_maintainer(current_user)
end
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Project cluster' }
end
it_behaves_like 'editing a GCP cluster'
......@@ -143,7 +151,9 @@ describe 'Clusterable > Show page' do
clusterable.add_maintainer(current_user)
end
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Group cluster' }
end
it_behaves_like 'editing a GCP cluster'
......@@ -157,7 +167,9 @@ describe 'Clusterable > Show page' do
let(:cluster_path) { admin_cluster_path(cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
it_behaves_like 'show page'
it_behaves_like 'show page' do
let(:cluster_type_label) { 'Instance cluster' }
end
it_behaves_like 'editing a GCP cluster'
......
......@@ -58,4 +58,39 @@ describe ClustersHelper do
it { is_expected.to eq('Create new cluster') }
end
end
describe '#cluster_type_label' do
subject { helper.cluster_type_label(cluster_type) }
context 'project cluster' do
let(:cluster_type) { 'project_type' }
it { is_expected.to eq('Project cluster') }
end
context 'group cluster' do
let(:cluster_type) { 'group_type' }
it { is_expected.to eq('Group cluster') }
end
context 'instance cluster' do
let(:cluster_type) { 'instance_type' }
it { is_expected.to eq('Instance cluster') }
end
context 'other values' do
let(:cluster_type) { 'not_supported' }
it 'Diplays generic cluster and reports error' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(ArgumentError),
cluster_error: { error: 'Cluster Type Missing', cluster_type: 'not_supported' }
)
is_expected.to eq('Cluster')
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