Commit c2f79d0c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '32293-fix-cluster-environments-tab' into 'master'

Show cluster environments tab when license permits

Closes #32293

See merge request gitlab-org/gitlab!17198
parents fdaba99e 2ccecfa2
......@@ -3,6 +3,7 @@
- breadcrumb_title @cluster.name
- page_title _('Kubernetes Cluster')
- manage_prometheus_path = edit_project_service_path(@cluster.project, 'prometheus') if @project
- cluster_environments_path = clusterable.environments_cluster_path(@cluster)
- expanded = expanded_by_default?
......@@ -16,7 +17,7 @@
install_jupyter_path: clusterable.install_applications_cluster_path(@cluster, :jupyter),
install_knative_path: clusterable.install_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',
has_rbac: has_rbac_enabled?(@cluster) ? 'true': 'false',
cluster_type: @cluster.cluster_type,
......@@ -37,7 +38,7 @@
%h4= @cluster.name
= render 'banner'
= render_if_exists 'clusters/clusters/group_cluster_environments', expanded: expanded
- unless Gitlab.ee?
- if cluster_environments_path.present?
= render_if_exists 'clusters/clusters/group_cluster_environments', expanded: expanded
- else
= render 'configure', expanded: expanded
......@@ -10,7 +10,7 @@
%span= _('Configuration')
%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' }
%span= _('Environments')
%span.js-cluster-nav-environments= _('Environments')
.tab-content
- 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
sign_in(current_user)
end
shared_examples 'editing domain' do
shared_examples 'show page' do
before do
clusterable.add_maintainer(current_user)
end
......@@ -53,6 +53,12 @@ describe 'Clusterable > Show page' do
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
shared_examples 'editing a GCP cluster' do
......@@ -113,42 +119,30 @@ describe 'Clusterable > Show page' do
end
context 'when clusterable is a project' do
it_behaves_like 'editing domain' do
let(:clusterable) { create(:project) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
end
let(:clusterable) { create(:project) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
it_behaves_like 'editing a GCP cluster' do
let(:clusterable) { create(:project) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
end
it_behaves_like 'show page'
it_behaves_like 'editing a GCP cluster'
it_behaves_like 'editing a user-provided cluster' do
let(:clusterable) { create(:project) }
let(:cluster) { create(:cluster, :provided_by_user, :project, projects: [clusterable]) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
end
end
context 'when clusterable is a group' do
it_behaves_like 'editing domain' do
let(:clusterable) { create(:group) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
end
let(:clusterable) { create(:group) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
it_behaves_like 'editing a GCP cluster' do
let(:clusterable) { create(:group) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
end
it_behaves_like 'show page'
it_behaves_like 'editing a GCP cluster'
it_behaves_like 'editing a user-provided cluster' do
let(:clusterable) { create(:group) }
let(:cluster) { create(:cluster, :provided_by_user, :group, groups: [clusterable]) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
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