diff --git a/ee/app/controllers/ee/admin/application_settings_controller.rb b/ee/app/controllers/ee/admin/application_settings_controller.rb index d6798b1aa39159bf898202b8193b0ca4be776d66..356feb6167d792e342dd8967063792db0c2d073e 100644 --- a/ee/app/controllers/ee/admin/application_settings_controller.rb +++ b/ee/app/controllers/ee/admin/application_settings_controller.rb @@ -21,6 +21,7 @@ module ApplicationSettingsController before_action :indexing_status, only: [:search] before_action :search_error_if_version_incompatible, only: [:search], if: -> { es_helper.ping? } before_action :search_outdated_code_analyzer_detected, only: [:search], if: -> { es_helper.ping? } + before_action :check_feature_availability, only: [:work_item] before_action :new_license, only: [:general] before_action :scim_token, only: [:general] @@ -91,6 +92,10 @@ def search_outdated_code_analyzer_detected log_exception(e) end + def check_feature_availability + render_404 unless ::Feature.enabled?(:work_item_configurable_types, :instance) + end + def scim_token scim_token = ScimOauthAccessToken.find_for_instance diff --git a/ee/app/views/admin/application_settings/work_item.html.haml b/ee/app/views/admin/application_settings/work_item.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..2ff57bff952954998e8a10cc0b8cdcee21196a93 --- /dev/null +++ b/ee/app/views/admin/application_settings/work_item.html.haml @@ -0,0 +1,6 @@ +- breadcrumb_title s_('WorkItem|Work item settings') +- page_title s_('WorkItem|Work item settings') +- add_page_specific_style 'page_bundles/settings' +- @force_desktop_expanded_sidebar = true + +%h2.gl-heading-2.gl-mt-2= _('Work item settings') diff --git a/ee/config/routes/admin.rb b/ee/config/routes/admin.rb index 570dc510c86692945174dad6d784c9f39919e6c8..0f17b56e772dad6373efe07754e4e9f912399afb 100644 --- a/ee/config/routes/admin.rb +++ b/ee/config/routes/admin.rb @@ -83,7 +83,7 @@ # using `only: []` to keep duplicate routes from being created resource :application_settings, only: [] do get :seat_link_payload - match :templates, :search, :security_and_compliance, :namespace_storage, :analytics, via: [:get, :patch] + match :templates, :search, :security_and_compliance, :namespace_storage, :analytics, :work_item, via: [:get, :patch] get :advanced_search, to: redirect('admin/application_settings/search') get :geo, to: "geo/settings#show" put :update_microsoft_application diff --git a/ee/lib/ee/sidebars/admin/menus/admin_settings_menu.rb b/ee/lib/ee/sidebars/admin/menus/admin_settings_menu.rb index 70d161956479a5e847a80ecdf7094c18671f2741..a54c3954cd0619228536a0ea27caf96c517b46c9 100644 --- a/ee/lib/ee/sidebars/admin/menus/admin_settings_menu.rb +++ b/ee/lib/ee/sidebars/admin/menus/admin_settings_menu.rb @@ -19,11 +19,24 @@ def configure_menu_items insert_item_after(:security_and_compliance_menu_item, analytics_menu_item) insert_item_after(:admin_preferences, usage_quotas_menu_item) + if ::Feature.enabled?(:work_item_configurable_types, :instance) + insert_item_after(:admin_security_and_compliance, work_item_settings_menu_item) + end + true end private + def work_item_settings_menu_item + ::Sidebars::MenuItem.new( + title: _('Work items'), + link: work_item_admin_application_settings_path, + active_routes: { path: 'admin/work_items' }, + container_html_options: { 'data-testid': 'admin-work-item-settings' } + ) + end + def roles_and_permissions_menu_item return ::Sidebars::NilMenuItem.new(item_id: :roles_and_permissions) unless roles_and_permissions_available? diff --git a/ee/spec/controllers/admin/application_settings_controller_spec.rb b/ee/spec/controllers/admin/application_settings_controller_spec.rb index 0c211703383fcf58613b89a145ad1e7d126f6ab7..5c511d3f742b210c25f8e0d573c8dac5ca359823 100644 --- a/ee/spec/controllers/admin/application_settings_controller_spec.rb +++ b/ee/spec/controllers/admin/application_settings_controller_spec.rb @@ -915,6 +915,37 @@ end end + describe 'GET #work_item', feature_category: :team_planning do + before do + sign_in(admin) + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(work_item_configurable_types: false) + end + + it 'returns 404' do + get :work_item + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when feature flag is enabled' do + before do + stub_feature_flags(work_item_configurable_types: true) + end + + it 'renders the work_item template' do + get :work_item + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('admin/application_settings/work_item') + end + end + end + def set_maintenance_mode(message) ApplicationSetting.current.update!( maintenance_mode: true, diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 485ef93bf8f2e2c17769bca6ee831fb5e1ede4a9..492c136e9ce84a091cc85bd2d6f1141c1c8ff20b 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -76565,6 +76565,9 @@ msgstr "" msgid "Work item not supported" msgstr "" +msgid "Work item settings" +msgstr "" + msgid "Work item type %{work_item_type_name} can only have a maximum of %{limit} active custom fields." msgstr "" @@ -77941,6 +77944,9 @@ msgstr "" msgid "WorkItem|Work item not found" msgstr "" +msgid "WorkItem|Work item settings" +msgstr "" + msgid "WorkItem|Work item types" msgstr "" diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index 10ac65e3b7d0413ad3dfa3e5eebc9cb88ad6e4d1..fdf6a1830da550db0383912aac66f0cfab6e8cb7 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -654,4 +654,34 @@ expect(response).to have_gitlab_http_status(:ok) end end + + describe 'GET #work_item', feature_category: :team_planning do + before do + sign_in(admin) + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(work_item_configurable_types: false) + end + + it 'returns 404' do + get :work_item + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when feature flag is enabled' do + before do + stub_feature_flags(work_item_configurable_types: true) + end + + it 'returns 404 on CE' do + get :work_item + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end end