diff --git a/ee/app/controllers/ee/groups_controller.rb b/ee/app/controllers/ee/groups_controller.rb index 9f05b546429ccdbb7155aa1804476804a4f1ec03..6471f492ff3a69cbc8e32b2ba5862ce8fc0a0b0a 100644 --- a/ee/app/controllers/ee/groups_controller.rb +++ b/ee/app/controllers/ee/groups_controller.rb @@ -101,8 +101,11 @@ def group_params_ee params_ee << :enforce_ssh_certificates if current_group&.ssh_certificates_available? params_ee << :code_suggestions if ai_assist_ui_enabled? params_ee << { value_stream_dashboard_aggregation_attributes: [:enabled] } if can?(current_user, :modify_value_stream_dashboard_settings, current_group) - params_ee << :product_analytics_enabled - params_ee << :experiment_features_enabled if experiment_settings_allowed? + + if experiment_settings_allowed? + params_ee << :product_analytics_enabled + params_ee << :experiment_features_enabled + end end end diff --git a/ee/app/views/groups/settings/_product_analytics_settings.html.haml b/ee/app/views/groups/settings/_product_analytics_settings.html.haml index a99373a19cc57d58d938a940e502df8e1f88d266..60292fe382c0424b03146551427aa16d7c172a4b 100644 --- a/ee/app/views/groups/settings/_product_analytics_settings.html.haml +++ b/ee/app/views/groups/settings/_product_analytics_settings.html.haml @@ -1,3 +1,5 @@ +- return unless group.experiment_settings_allowed? + - learn_more = help_page_path('user/product_analytics/index') %h5 = s_('ProductAnalytics|Product Analytics') diff --git a/ee/spec/views/groups/settings/_permissions.html.haml_spec.rb b/ee/spec/views/groups/settings/_permissions.html.haml_spec.rb index 7b70503d5548080137d46cd2a54e951ad9c0e062..157f95b6951b70cc94da9a8a65dbb1869e528fd2 100644 --- a/ee/spec/views/groups/settings/_permissions.html.haml_spec.rb +++ b/ee/spec/views/groups/settings/_permissions.html.haml_spec.rb @@ -61,4 +61,35 @@ end end end + + context 'for product analytics settings' do + before do + allow(view).to receive(:ai_assist_ui_enabled?).and_return(true) + allow(group).to receive(:licensed_feature_available?).and_call_original + allow(group).to receive(:licensed_feature_available?).with(:experimental_features).and_return(true) + allow(Gitlab::CurrentSettings).to receive(:should_check_namespace_plan?).and_return(true) + end + + context 'as a sub-group' do + it 'renders nothing' do + allow(group).to receive(:root?).and_return(false) + + render + + expect(rendered).to render_template('groups/settings/_product_analytics_settings') + expect(rendered).not_to have_content(_('Product Analytics')) + end + end + + context 'as a root group' do + it 'renders the product analytics settings' do + allow(group).to receive(:root?).and_return(true) + + render + + expect(rendered).to render_template('groups/settings/_product_analytics_settings') + expect(rendered).to have_content(_('Product Analytics')) + end + end + end end