From 17b00c81c8430e419091757422e97ac0f77ee202 Mon Sep 17 00:00:00 2001 From: Matt D'Angelo Date: Thu, 23 Oct 2025 14:41:27 +1030 Subject: [PATCH 1/3] Accept type filter in finder_options --- app/controllers/concerns/work_items_collections.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/concerns/work_items_collections.rb b/app/controllers/concerns/work_items_collections.rb index 59283fb1b5bffd..ddc06779c773b5 100644 --- a/app/controllers/concerns/work_items_collections.rb +++ b/app/controllers/concerns/work_items_collections.rb @@ -36,6 +36,9 @@ def work_items_for_calendar def finder_options work_items_collection_params[:state] = (params.permit([:state])[:state].presence || default_state) + types = params.permit(type: [])[:type] + work_items_collection_params[:issue_types] = types if types + options = { scope: params.permit([:scope])[:scope], state: work_items_collection_params[:state], -- GitLab From e97e2ae03ddd870aa7a70563d8e183e06321210a Mon Sep 17 00:00:00 2001 From: Matt D'Angelo Date: Thu, 23 Oct 2025 15:38:52 +1030 Subject: [PATCH 2/3] Add spec for filter --- spec/controllers/concerns/work_items_collections_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/controllers/concerns/work_items_collections_spec.rb b/spec/controllers/concerns/work_items_collections_spec.rb index a10b242f6e32a0..2f2641ec93dc43 100644 --- a/spec/controllers/concerns/work_items_collections_spec.rb +++ b/spec/controllers/concerns/work_items_collections_spec.rb @@ -116,5 +116,13 @@ def finder_type }) end end + + context 'with type filtering' do + let(:params) { { type: %w[task incident] } } + + it 'mutates the search into a filter by type' do + is_expected.to include({ issue_types: %w[task incident] }) + end + end end end -- GitLab From 7d568210822bee7b1e624a1bbd14792c59aa1e33 Mon Sep 17 00:00:00 2001 From: Matt D'Angelo Date: Thu, 23 Oct 2025 16:33:00 +1030 Subject: [PATCH 3/3] Handle negated types --- app/controllers/concerns/work_items_collections.rb | 5 +++++ spec/controllers/concerns/work_items_collections_spec.rb | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/app/controllers/concerns/work_items_collections.rb b/app/controllers/concerns/work_items_collections.rb index ddc06779c773b5..2df2734969f6e2 100644 --- a/app/controllers/concerns/work_items_collections.rb +++ b/app/controllers/concerns/work_items_collections.rb @@ -36,9 +36,14 @@ def work_items_for_calendar def finder_options work_items_collection_params[:state] = (params.permit([:state])[:state].presence || default_state) + # Handle the translation of the type param, since the finder expects :issue_types types = params.permit(type: [])[:type] work_items_collection_params[:issue_types] = types if types + if work_items_collection_params.dig(:not, :type) + work_items_collection_params[:not][:issue_types] = work_items_collection_params[:not].delete(:type) + end + options = { scope: params.permit([:scope])[:scope], state: work_items_collection_params[:state], diff --git a/spec/controllers/concerns/work_items_collections_spec.rb b/spec/controllers/concerns/work_items_collections_spec.rb index 2f2641ec93dc43..be823035e7451b 100644 --- a/spec/controllers/concerns/work_items_collections_spec.rb +++ b/spec/controllers/concerns/work_items_collections_spec.rb @@ -124,5 +124,13 @@ def finder_type is_expected.to include({ issue_types: %w[task incident] }) end end + + context 'with negated type filtering' do + let(:params) { { not: { type: %w[task incident] } } } + + it 'mutates the search into a filter by type' do + is_expected.to include({ not: { issue_types: %w[task incident] } }) + end + end end end -- GitLab