diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 35111be2b1b51ff086c0652221ad813955312b11..3f47c6ee83354455e921c5423dd39e79e70f2f26 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -707,6 +707,13 @@ def self.kroki_formats_attributes validates :sign_in_restrictions, json_schema: { filename: 'application_setting_sign_in_restrictions' } + jsonb_accessor :search, + global_search_merge_requests_enabled: [:boolean, { default: true }], + global_search_work_items_enabled: [:boolean, { default: true }], + global_search_users_enabled: [:boolean, { default: true }] + + validates :search, json_schema: { filename: 'application_setting_search' } + jsonb_accessor :transactional_emails, resource_access_token_notify_inherited: [:boolean, { default: false }], lock_resource_access_token_notify_inherited: [:boolean, { default: false }] diff --git a/app/validators/json_schemas/application_setting_search.json b/app/validators/json_schemas/application_setting_search.json new file mode 100644 index 0000000000000000000000000000000000000000..6f8ee71ab8692793855fca62e4848943cbb65c6a --- /dev/null +++ b/app/validators/json_schemas/application_setting_search.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Application Settings for search", + "type": "object", + "additionalProperties": true, + "properties": { + "global_search_work_items_enabled": { + "type": "boolean", + "description": "Enable global search for work items" + }, + "global_search_merge_requests_enabled": { + "type": "boolean", + "description": "Enable global search for merge requests" + }, + "global_search_users_enabled": { + "type": "boolean", + "description": "Enable global search for users" + } + } +} diff --git a/config/application_setting_columns/search.yml b/config/application_setting_columns/search.yml new file mode 100644 index 0000000000000000000000000000000000000000..136c26bdfe964670cbaff9b9c7237da834ba0180 --- /dev/null +++ b/config/application_setting_columns/search.yml @@ -0,0 +1,12 @@ +--- +api_type: +attr: search +clusterwide: false +column: search +db_type: jsonb +default: "'{}'::jsonb" +description: +encrypted: false +gitlab_com_different_than_default: true +jihu: false +not_null: true diff --git a/db/migrate/20250108114357_add_global_search_settings_to_application_settings.rb b/db/migrate/20250108114357_add_global_search_settings_to_application_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..7dc52cd77f1bdf979cabf9a76d75b810eae4a17b --- /dev/null +++ b/db/migrate/20250108114357_add_global_search_settings_to_application_settings.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddGlobalSearchSettingsToApplicationSettings < Gitlab::Database::Migration[2.2] + milestone '17.9' + + def change + add_column :application_settings, :search, :jsonb, default: {}, null: false + end +end diff --git a/db/schema_migrations/20250108114357 b/db/schema_migrations/20250108114357 new file mode 100644 index 0000000000000000000000000000000000000000..dd9d049d7a0d592b62ab9fd77f7167d2bbcaed9f --- /dev/null +++ b/db/schema_migrations/20250108114357 @@ -0,0 +1 @@ +73b7e842e1d64c04554d34fa3e90e1cab9942f758e62321f77beb68da53909a3 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 4642dc53cd7cbed44c38bc7b9833c4d179eb4e75..74ec9db95e8856a207dace039d5ac33e65dcfe0e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -7912,6 +7912,7 @@ CREATE TABLE application_settings ( elasticsearch_indexed_file_size_limit_kb integer DEFAULT 1024 NOT NULL, elasticsearch_max_code_indexing_concurrency integer DEFAULT 30 NOT NULL, observability_settings jsonb DEFAULT '{}'::jsonb NOT NULL, + search jsonb DEFAULT '{}'::jsonb NOT NULL, CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)), diff --git a/ee/app/models/ee/application_setting.rb b/ee/app/models/ee/application_setting.rb index a74deac5039ecdb1ed7c5e201f789d129ebfe844..d9a332f2b855b3435f3f0dfdec1cc159ee969540 100644 --- a/ee/app/models/ee/application_setting.rb +++ b/ee/app/models/ee/application_setting.rb @@ -23,6 +23,12 @@ module ApplicationSetting jsonb_accessor :clickhouse, use_clickhouse_for_analytics: [:boolean, { default: false }] + jsonb_accessor :search, + global_search_code_enabled: [:boolean, { default: true }], + global_search_commits_enabled: [:boolean, { default: true }], + global_search_wiki_enabled: [:boolean, { default: true }], + global_search_snippet_titles_enabled: [:boolean, { default: true }] + jsonb_accessor :zoekt_settings, zoekt_auto_delete_lost_nodes: [:boolean, { default: true }], zoekt_indexing_enabled: [:boolean, { default: false }], @@ -276,6 +282,7 @@ module ApplicationSetting allow_nil: false, inclusion: { in: [true, false], message: N_('must be a boolean value') } + validates :search, json_schema: { filename: 'application_setting_search' } validates :zoekt_settings, json_schema: { filename: 'application_setting_zoekt_settings' } validates :zoekt_cpu_to_tasks_ratio, numericality: { greater_than: 0.0 } diff --git a/ee/app/validators/json_schemas/application_setting_search.json b/ee/app/validators/json_schemas/application_setting_search.json new file mode 100644 index 0000000000000000000000000000000000000000..dee8fc265ff5acc1b6a7ccec4f03e8114182193c --- /dev/null +++ b/ee/app/validators/json_schemas/application_setting_search.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Application Settings for search", + "type": "object", + "additionalProperties": false, + "properties": { + "global_search_code_enabled": { + "type": "boolean", + "description": "Enable global search for code" + }, + "global_search_commits_enabled": { + "type": "boolean", + "description": "Enable global search for commits" + }, + "global_search_merge_requests_enabled": { + "type": "boolean", + "description": "Enable global search for merge requests" + }, + "global_search_work_items_enabled": { + "type": "boolean", + "description": "Enable global search for work items" + }, + "global_search_wiki_enabled": { + "type": "boolean", + "description": "Enable global search for wikis" + }, + "global_search_users_enabled": { + "type": "boolean", + "description": "Enable global search for users" + }, + "global_search_snippet_titles_enabled": { + "type": "boolean", + "description": "Enable global search for snippets" + } + } +} diff --git a/ee/spec/models/application_setting_spec.rb b/ee/spec/models/application_setting_spec.rb index 512c0560a44026b2d42b9638769fccdde367963f..39aa912bc337949b3eca253023db1a152c1a4fbd 100644 --- a/ee/spec/models/application_setting_spec.rb +++ b/ee/spec/models/application_setting_spec.rb @@ -46,6 +46,13 @@ it { expect(setting.hard_phone_verification_transactions_daily_limit).to eq(20000) } it { expect(setting.telesign_intelligence_enabled).to eq(true) } it { expect(setting.fetch_observability_alerts_from_cloud).to eq(true) } + it { expect(setting.global_search_code_enabled).to be(true) } + it { expect(setting.global_search_commits_enabled).to be(true) } + it { expect(setting.global_search_merge_requests_enabled).to be(true) } + it { expect(setting.global_search_work_items_enabled).to be(true) } + it { expect(setting.global_search_wiki_enabled).to be(true) } + it { expect(setting.global_search_users_enabled).to be(true) } + it { expect(setting.global_search_snippet_titles_enabled).to be(true) } end describe 'validations' do @@ -688,6 +695,10 @@ it { is_expected.not_to allow_value(nil).for(:instance_level_ai_beta_features_enabled) } end + describe 'search settings', feature_category: :global_search do + it { expect(described_class).to validate_jsonb_schema(['application_setting_search']) } + end + describe 'zoekt settings', feature_category: :global_search do it { expect(described_class).to validate_jsonb_schema(['application_setting_zoekt_settings']) } end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index d498c4bb3b82ada2dbf29c0815063dcec26c99d7..cde19ba6a9f79f9d17bd3b48b286495f59c813fb 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -53,6 +53,9 @@ it { expect(setting.resource_access_token_notify_inherited).to be(false) } it { expect(setting.lock_resource_access_token_notify_inherited).to be(false) } it { expect(setting.ropc_without_client_credentials).to be(true) } + it { expect(setting.global_search_merge_requests_enabled).to be(true) } + it { expect(setting.global_search_work_items_enabled).to be(true) } + it { expect(setting.global_search_users_enabled).to be(true) } end describe 'USERS_UNCONFIRMED_SECONDARY_EMAILS_DELETE_AFTER_DAYS' do @@ -95,6 +98,7 @@ } end + it { expect(described_class).to validate_jsonb_schema(['application_setting_search']) } it { expect(described_class).to validate_jsonb_schema(['resource_usage_limits']) } it { expect(described_class).to validate_jsonb_schema(['application_setting_rate_limits']) } it { expect(described_class).to validate_jsonb_schema(['application_setting_package_registry']) }