Commit 2ccecfa2 authored by Thong Kuah's avatar Thong Kuah

Show cluster environments tab when license permits

Use presence of cluster_environments_path to show or not show the
Environments tab on the cluster show page. Only in Silver and up, will
cluster_environments_path show.

Added some feature tests
parent a58fd705
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
- breadcrumb_title @cluster.name - breadcrumb_title @cluster.name
- page_title _('Kubernetes Cluster') - page_title _('Kubernetes Cluster')
- manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project - manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project
- cluster_environments_path = clusterable.environments_cluster_path(@cluster)
- expanded = expanded_by_default? - expanded = expanded_by_default?
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
install_jupyter_path: clusterable.install_applications_cluster_path(@cluster, :jupyter), install_jupyter_path: clusterable.install_applications_cluster_path(@cluster, :jupyter),
install_knative_path: clusterable.install_applications_cluster_path(@cluster, :knative), install_knative_path: clusterable.install_applications_cluster_path(@cluster, :knative),
update_knative_path: clusterable.update_applications_cluster_path(@cluster, :knative), update_knative_path: clusterable.update_applications_cluster_path(@cluster, :knative),
cluster_environments_path: clusterable.environments_cluster_path(@cluster), cluster_environments_path: cluster_environments_path,
toggle_status: @cluster.enabled? ? 'true': 'false', toggle_status: @cluster.enabled? ? 'true': 'false',
has_rbac: has_rbac_enabled?(@cluster) ? 'true': 'false', has_rbac: has_rbac_enabled?(@cluster) ? 'true': 'false',
cluster_type: @cluster.cluster_type, cluster_type: @cluster.cluster_type,
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
%h4= @cluster.name %h4= @cluster.name
= render 'banner' = render 'banner'
= render_if_exists 'clusters/clusters/group_cluster_environments', expanded: expanded - if cluster_environments_path.present?
= render_if_exists 'clusters/clusters/group_cluster_environments', expanded: expanded
- unless Gitlab.ee? - else
= render 'configure', expanded: expanded = render 'configure', expanded: expanded
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%span= _('Configuration') %span= _('Configuration')
%li.nav-item{ role: 'presentation' } %li.nav-item{ role: 'presentation' }
%a.nav-link{ class: active_when(!is_configure_active), href: clusterable.cluster_path(@cluster.id, params: {tab: 'environments'}), id: 'group-cluster-environments-tab' } %a.nav-link{ class: active_when(!is_configure_active), href: clusterable.cluster_path(@cluster.id, params: {tab: 'environments'}), id: 'group-cluster-environments-tab' }
%span= _('Environments') %span.js-cluster-nav-environments= _('Environments')
.tab-content .tab-content
- if is_configure_active - if is_configure_active
......
# frozen_string_literal: true
require 'spec_helper'
describe 'Clusterable > Show page' do
include KubernetesHelpers
let(:current_user) { create(:user) }
let(:cluster_ingress_help_text_selector) { '.js-ingress-domain-help-text' }
let(:hide_modifier_selector) { '.hide' }
before do
stub_licensed_features(cluster_deployments: true)
sign_in(current_user)
end
context 'when clusterable is a project' do
let(:clusterable) { create(:project) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
before do
clusterable.add_maintainer(current_user)
end
it 'does not show the environments tab' do
visit cluster_path
expect(page).not_to have_selector('.js-cluster-nav-environments', text: 'Environments')
end
end
context 'when clusterable is a group' do
let(:clusterable) { create(:group) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
before do
clusterable.add_maintainer(current_user)
end
it 'shows the environments tab' do
visit cluster_path
expect(page).to have_selector('.js-cluster-nav-environments', text: 'Environments')
end
end
end
...@@ -13,7 +13,7 @@ describe 'Clusterable > Show page' do ...@@ -13,7 +13,7 @@ describe 'Clusterable > Show page' do
sign_in(current_user) sign_in(current_user)
end end
shared_examples 'editing domain' do shared_examples 'show page' do
before do before do
clusterable.add_maintainer(current_user) clusterable.add_maintainer(current_user)
end end
...@@ -53,6 +53,12 @@ describe 'Clusterable > Show page' do ...@@ -53,6 +53,12 @@ describe 'Clusterable > Show page' do
end end
end end
end end
it 'does not show the environments tab' do
visit cluster_path
expect(page).not_to have_selector('.js-cluster-nav-environments', text: 'Environments')
end
end end
shared_examples 'editing a GCP cluster' do shared_examples 'editing a GCP cluster' do
...@@ -117,7 +123,7 @@ describe 'Clusterable > Show page' do ...@@ -117,7 +123,7 @@ describe 'Clusterable > Show page' do
let(:cluster_path) { project_cluster_path(clusterable, cluster) } let(:cluster_path) { project_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) } let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
it_behaves_like 'editing domain' it_behaves_like 'show page'
it_behaves_like 'editing a GCP cluster' it_behaves_like 'editing a GCP cluster'
...@@ -131,7 +137,7 @@ describe 'Clusterable > Show page' do ...@@ -131,7 +137,7 @@ describe 'Clusterable > Show page' do
let(:cluster_path) { group_cluster_path(clusterable, cluster) } let(:cluster_path) { group_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) } let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
it_behaves_like 'editing domain' it_behaves_like 'show page'
it_behaves_like 'editing a GCP cluster' it_behaves_like 'editing a GCP cluster'
......
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