diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 45911484281f5f7bb009cc6ec28044bb37d78299..14eb0fa95dc730c0fecc1bd02e6e5c410c0c7003 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -277,12 +277,14 @@ def unfoldered_environment_names end def issues - return if redirect_if_epic_params - return super unless html_request? set_sort_order + return redirect_issues_to_work_items if group&.work_items_consolidated_list_enabled?(current_user) + + return if redirect_if_epic_params + respond_to do |format| format.html end @@ -402,6 +404,16 @@ def destroy_immediately # Overridden in EE def redirect_if_epic_params; end + + def redirect_issues_to_work_items + params = work_items_redirect_params.except("type", "type[]").merge('type[]' => 'issue') + + redirect_to group_work_items_path(group, params: params) + end + + def work_items_redirect_params + request.query_parameters + end end GroupsController.prepend_mod diff --git a/ee/app/controllers/ee/groups_controller.rb b/ee/app/controllers/ee/groups_controller.rb index 95a4c386adb09f9025e0b571c44cee4c5b59a260..407973815464586b47c10364d0b58c8f8c491698 100644 --- a/ee/app/controllers/ee/groups_controller.rb +++ b/ee/app/controllers/ee/groups_controller.rb @@ -99,5 +99,14 @@ def redirect_if_epic_params true end + + override :work_items_redirect_params + def work_items_redirect_params + if has_epic_filter? + convert_epic_params + else + super + end + end end end diff --git a/ee/app/controllers/groups/epics_controller.rb b/ee/app/controllers/groups/epics_controller.rb index 8bea091d54dbde4bf3230d2a8dcdc4ab5cea1212..a4947be8c83f7195d4b0a6d113bc708bea1cbaca 100644 --- a/ee/app/controllers/groups/epics_controller.rb +++ b/ee/app/controllers/groups/epics_controller.rb @@ -49,6 +49,8 @@ def new end def index + return redirect_epics_to_work_items if group&.work_items_consolidated_list_enabled?(current_user) + render 'work_items_index' end @@ -141,4 +143,9 @@ def enforce_work_item_epics_feature_flags def set_summarize_notes_feature_flag push_force_frontend_feature_flag(:summarize_comments, can?(current_user, :summarize_comments, epic)) end + + def redirect_epics_to_work_items + params = request.query_parameters.except("type", "type[]").merge('type[]' => 'epic') + redirect_to group_work_items_path(group, params: params) + end end diff --git a/ee/spec/controllers/ee/groups_controller_spec.rb b/ee/spec/controllers/ee/groups_controller_spec.rb index f8f152255f9b4d9b63a449f7bce31390bb93dd57..1e009ba7805981757654f6b297cfd1e2e012d944 100644 --- a/ee/spec/controllers/ee/groups_controller_spec.rb +++ b/ee/spec/controllers/ee/groups_controller_spec.rb @@ -627,22 +627,67 @@ def request(visibility_level) group.add_developer(user) end - it 'rewrites the epic_id param' do - get :issues, params: { id: group.to_param, epic_id: epic.id } - expect(response).to redirect_to issues_group_path(group, params: { parent_id: epic.work_item.id }) + shared_examples 'epic parameter redirect' do |redirect_path| + it 'redirects with epic_wildcard_id converted to parent_wildcard_id' do + get :issues, params: { id: group.to_param, epic_wildcard_id: 'ANY' } - get :issues, params: { id: group.to_param, epic_id: 'NONE' } - expect(response).to redirect_to issues_group_path(group, params: { parent_id: 'NONE' }) + expected_params = { parent_wildcard_id: 'ANY' } + expected_params['type[]'] = 'issue' if redirect_path == :group_work_items_path + + expect(response).to redirect_to send(redirect_path, group, params: expected_params) + end + + it 'redirects with epic_id converted to parent_id' do + get :issues, params: { id: group.to_param, epic_id: epic.id } + + expected_params = { parent_id: epic.work_item.id } + expected_params['type[]'] = 'issue' if redirect_path == :group_work_items_path + + expect(response).to redirect_to send(redirect_path, group, params: expected_params) + end + + it 'redirects with epic_id NONE converted to parent_id NONE' do + get :issues, params: { id: group.to_param, epic_id: 'NONE' } + + expected_params = { parent_id: 'NONE' } + expected_params['type[]'] = 'issue' if redirect_path == :group_work_items_path + + expect(response).to redirect_to send(redirect_path, group, params: expected_params) + end + + it 'redirects with not epic_id converted to not parent_id' do + get :issues, params: { id: group.to_param, not: { epic_id: epic.id } } + + expected_params = { not: { parent_id: epic.work_item.id } } + expected_params['type[]'] = 'issue' if redirect_path == :group_work_items_path + + expect(response).to redirect_to send(redirect_path, group, params: expected_params) + end + + it 'preserves other query parameters when redirecting with epic params' do + get :issues, params: { id: group.to_param, epic_wildcard_id: 'ANY', search: 'bug', sort: 'created_desc' } + + expected_params = { + parent_wildcard_id: 'ANY', + search: 'bug', + sort: 'created_desc' + } + expected_params['type[]'] = 'issue' if redirect_path == :group_work_items_path + + expect(response).to redirect_to send(redirect_path, group, params: expected_params) + end end - it 'rewrites the not epic_id param' do - get :issues, params: { id: group.to_param, not: { epic_id: epic.id } } - expect(response).to redirect_to issues_group_path(group, params: { not: { parent_id: epic.work_item.id } }) + context 'when work_item_planning_view feature flag is disabled' do + before do + stub_feature_flags(work_item_planning_view: false) + end + + it_behaves_like 'epic parameter redirect', :issues_group_path end - it 'rewrites the epic_wildcard_id param' do - get :issues, params: { id: group.to_param, epic_wildcard_id: 'ANY' } - expect(response).to redirect_to issues_group_path(group, params: { parent_wildcard_id: 'ANY' }) + context 'when work_item_planning_view feature flag is enabled' do + it_behaves_like 'epic parameter redirect', :group_work_items_path end end end diff --git a/ee/spec/controllers/groups/epics_controller_spec.rb b/ee/spec/controllers/groups/epics_controller_spec.rb index 88b74bf7d7c53104b771c5baac1ec6e7ff02bbd9..fcf14a494a26b817ee7c98406765bef5f2019040 100644 --- a/ee/spec/controllers/groups/epics_controller_spec.rb +++ b/ee/spec/controllers/groups/epics_controller_spec.rb @@ -61,10 +61,40 @@ group.add_developer(user) end - it "returns index" do - get :index, params: { group_id: group } + shared_examples 'epics index redirect' do |redirect_path, should_redirect| + if should_redirect + it 'redirects to work items path with epic type filter' do + get :index, params: { group_id: group } - expect(response).to have_gitlab_http_status(:ok) + expect(response).to redirect_to send(redirect_path, group, params: { 'type[]' => 'epic' }) + end + + it 'preserves query parameters except type when redirecting' do + get :index, params: { group_id: group, search: 'feature', sort: 'created_desc', type: 'old_type' } + + expect(response).to redirect_to send(redirect_path, group, + params: { search: 'feature', sort: 'created_desc', 'type[]' => 'epic' }) + end + else + it "renders the epics index page" do + get :index, params: { group_id: group } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template 'work_items_index' + end + end + end + + context 'when work_item_planning_view feature flag is enabled' do + it_behaves_like 'epics index redirect', :group_work_items_path, true + end + + context 'when work_item_planning_view feature flag is disabled' do + before do + stub_feature_flags(work_item_planning_view: false) + end + + it_behaves_like 'epics index redirect', :group_epics_path, false end end diff --git a/ee/spec/features/work_items/epics/epic_work_item_sync_spec.rb b/ee/spec/features/work_items/epics/epic_work_item_sync_spec.rb index 0abbc1b6d21d334d346c895d2457593939374c86..d0875c89158bad08d9ddc5c135db1689d666540f 100644 --- a/ee/spec/features/work_items/epics/epic_work_item_sync_spec.rb +++ b/ee/spec/features/work_items/epics/epic_work_item_sync_spec.rb @@ -31,6 +31,7 @@ describe 'from work item to epic' do before do + stub_feature_flags(work_item_planning_view: false) # TODO: remove threshold after epic-work item sync # issue: https://gitlab.com/gitlab-org/gitlab/-/issues/438295 allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(130) diff --git a/ee/spec/features/work_items/list/user_bulk_edits_work_items_spec.rb b/ee/spec/features/work_items/list/user_bulk_edits_work_items_spec.rb index d66837ccc6dc0d1b9c9f8606f15d950b79de7014..6ed671ce904c9b7a570ddadc9617b9123e317586 100644 --- a/ee/spec/features/work_items/list/user_bulk_edits_work_items_spec.rb +++ b/ee/spec/features/work_items/list/user_bulk_edits_work_items_spec.rb @@ -93,6 +93,7 @@ context 'when bulk editing parent on group issue list' do before do + stub_feature_flags(work_item_planning_view: false) allow(Gitlab::QueryLimiting).to receive(:threshold).and_return(132) visit issues_group_path(group) @@ -201,6 +202,7 @@ let_it_be(:child_epic_2) { create(:work_item, :epic, namespace: group, title: "Child epic 2") } before do + stub_feature_flags(work_item_planning_view: false) visit group_epics_path(group) click_bulk_edit end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 598a845ed59b3bce8aca18e3208d205840ee03c5..d89aff2af9c0809d2c30afb0c9927142ae23f8b6 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -529,6 +529,33 @@ expect(user.reload.user_preference.issues_sort).to eq('priority') end + + context 'when work_item_planning_view feature flag is enabled' do + it 'redirects to work items path with issue type filter' do + get :issues, params: { id: group.to_param } + + expect(response).to redirect_to(group_work_items_path(group, params: { 'type[]' => 'issue' })) + end + + it 'preserves query parameters except type when redirecting' do + get :issues, params: { id: group.to_param, search: 'bug', sort: 'created_desc', type: 'old_type' } + + expect(response).to redirect_to(group_work_items_path(group, params: { search: 'bug', sort: 'created_desc', 'type[]' => 'issue' })) + end + end + + context 'when work_item_planning_view feature flag is disabled' do + before do + stub_feature_flags(work_item_planning_view: false) + end + + it 'renders the issues page' do + get :issues, params: { id: group.to_param } + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template 'groups/issues' + end + end end describe 'GET #merge_requests', :sidekiq_might_not_need_inline do @@ -1568,6 +1595,10 @@ def get_activity end describe 'GET #issues' do + before do + stub_feature_flags(work_item_planning_view: false) + end + subject { get :issues, params: { id: group.to_param } } it_behaves_like 'disabled when using an external authorization service' diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb index 1647078118fd4408a4a9829ea1aab4bd582ee296..59955e0b391bca81d91315b96201ae7a60fc331b 100644 --- a/spec/features/groups/issues_spec.rb +++ b/spec/features/groups/issues_spec.rb @@ -15,6 +15,10 @@ context 'with shared examples', :js do let(:issuable) { create(:issue, project: project, title: "this is my created issuable") } + before do + stub_feature_flags(work_item_planning_view: false) + end + include_examples 'project features apply to issuables', Issue context 'rss feed' do @@ -92,6 +96,7 @@ let!(:subgroup_issue) { create(:issue, project: subgroup_project) } before do + stub_feature_flags(work_item_planning_view: false) visit issues_group_path(group_with_no_issues) end @@ -105,6 +110,7 @@ let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user } before do + stub_feature_flags(work_item_planning_view: false) [project, project_with_issues_disabled].each { |project| project.add_maintainer(user_in_group) } sign_in(user_in_group) visit issues_group_path(group) diff --git a/spec/features/work_items/new/user_creates_work_item_spec.rb b/spec/features/work_items/new/user_creates_work_item_spec.rb index a468a807d0fad1172287482d278b554a86e5790a..498e4a811ea862cf81ac27f3b56811fc7ed7abc7 100644 --- a/spec/features/work_items/new/user_creates_work_item_spec.rb +++ b/spec/features/work_items/new/user_creates_work_item_spec.rb @@ -91,6 +91,7 @@ let_it_be(:project_with_issues_disabled) { create(:project, :issues_disabled, group: group) } before do + stub_feature_flags(work_item_planning_view: false) [project, project_with_issues_disabled].each { |project| project.add_maintainer(user_in_group) } sign_in(user_in_group) visit issues_group_path(group)