diff --git a/ee/app/assets/javascripts/pages/admin/ai/duo_self_hosted/index.js b/ee/app/assets/javascripts/pages/admin/ai/duo_self_hosted/index.js index 164a03571256bd66b4dc26eb60a4f51460fb41e2..452787dec7eced90ffa23ffc71f4a0bdfa6c3e63 100644 --- a/ee/app/assets/javascripts/pages/admin/ai/duo_self_hosted/index.js +++ b/ee/app/assets/javascripts/pages/admin/ai/duo_self_hosted/index.js @@ -16,9 +16,13 @@ function mountSelfHostedModelsApp() { return null; } - const { basePath, modelOptions, betaModelsEnabled, duoConfigurationSettingsPath } = JSON.parse( - el.dataset.viewModel, - ); + const { + basePath, + modelOptions, + betaModelsEnabled, + duoChatSubFeaturesEnabled, + duoConfigurationSettingsPath, + } = JSON.parse(el.dataset.viewModel); const router = createRouter(basePath); @@ -31,6 +35,7 @@ function mountSelfHostedModelsApp() { basePath, modelOptions, betaModelsEnabled, + duoChatSubFeaturesEnabled, duoConfigurationSettingsPath, }, render(createElement) { diff --git a/ee/app/helpers/admin/ai/self_hosted_models_helper.rb b/ee/app/helpers/admin/ai/self_hosted_models_helper.rb index bc6e2ea8dc74527cf5e6bd7929d69b617e5a95af..f6187eeffe9daa296a489858f20c5d660c5a283a 100644 --- a/ee/app/helpers/admin/ai/self_hosted_models_helper.rb +++ b/ee/app/helpers/admin/ai/self_hosted_models_helper.rb @@ -35,6 +35,10 @@ def model_choices_as_options def beta_models_enabled? ::Ai::TestingTermsAcceptance.has_accepted? end + + def duo_chat_sub_features_enabled? + Feature.enabled?(:ai_duo_chat_sub_features_settings) # rubocop:disable Gitlab/FeatureFlagWithoutActor -- global feature flag + end end end end diff --git a/ee/app/views/admin/ai/duo_self_hosted/index.html.haml b/ee/app/views/admin/ai/duo_self_hosted/index.html.haml index 79ada4f8ed1fd3a26827869dc280025a35996232..a39fa9944abfdc1684837a67bb1b02678e9dd7d6 100644 --- a/ee/app/views/admin/ai/duo_self_hosted/index.html.haml +++ b/ee/app/views/admin/ai/duo_self_hosted/index.html.haml @@ -1,2 +1,2 @@ - page_title s_("AdminSelfHostedModels|GitLab Duo Self-Hosted") -#js-duo-self-hosted{ data: { view_model: { basePath: admin_ai_duo_self_hosted_path, modelOptions: model_choices_as_options, betaModelsEnabled: beta_models_enabled?, duoConfigurationSettingsPath: admin_gitlab_duo_configuration_index_url }.to_json } } +#js-duo-self-hosted{ data: { view_model: { basePath: admin_ai_duo_self_hosted_path, modelOptions: model_choices_as_options, betaModelsEnabled: beta_models_enabled?, duoChatSubFeaturesEnabled: duo_chat_sub_features_enabled?, duoConfigurationSettingsPath: admin_gitlab_duo_configuration_index_url }.to_json } } diff --git a/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb b/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb index 38f35cb4fd197859fb76dfbe155f615e78bab64b..10c8d3ac7329069c175a7d50f470f4ed929660ef 100644 --- a/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb +++ b/ee/spec/helpers/admin/ai/self_hosted_models_helper_spec.rb @@ -60,4 +60,18 @@ expect(helper.beta_models_enabled?).to be(false) end end + + describe '#duo_chat_sub_features_enabled?' do + it 'returns true if ai_duo_chat_sub_features_settings is enabled' do + stub_feature_flags(ai_duo_chat_sub_features_settings: true) + + expect(helper.duo_chat_sub_features_enabled?).to be(true) + end + + it 'returns false if ai_duo_chat_sub_features_settings is disabled' do + stub_feature_flags(ai_duo_chat_sub_features_settings: false) + + expect(helper.duo_chat_sub_features_enabled?).to be(false) + end + end end