OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fix[#55504] Changing page size/page after removing a project from an project attribute leads to "page not found"
Kabiru Mwenjacb26afae1bc9
diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb b/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rbindex 6d2da1e4397..1128a73f46f 100644--- a/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/table_component.rb@@ -39,6 +39,23 @@ module Settingsdef sortable?falseend++ # @override optional_pagination_options are passed to the pagination_options+ # which are passed to #pagination_links_full in pagination_helper.rb+ #+ # In Turbo streamable components, we need to be able to specify the url_for(action:) so that links are+ # generated in the context of the component index action, instead of any turbo stream actions performing+ # partial updates on the page.+ #+ # params[:url_for_action] is passed to the pagination_options making it's way down to any pagination links+ # that are generated via link_to which calls url_for which uses the params[:url_for_action] to specify+ # the controller action that link_to should use.+ #+ def optional_pagination_options+ return super unless params[:url_for_action]++ super.merge(params: { action: params[:url_for_action] })+ endendendenddiff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rbindex ffcb43b7d77..bae6e93baf7 100644--- a/app/controllers/admin/settings/project_custom_fields_controller.rb+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb@@ -79,7 +79,7 @@ module Admin::Settingsinclude_sub_projects: include_sub_projects?).call- create_service.on_success { render_project_list }+ create_service.on_success { render_project_list(url_for_action: :project_mappings) }create_service.on_failure doupdate_flash_message_via_turbo_stream(@@ -96,7 +96,7 @@ module Admin::Settings.new(user: current_user, model: @project_custom_field_mapping).call- delete_service.on_success { render_project_list }+ delete_service.on_success { render_project_list(url_for_action: :project_mappings) }delete_service.on_failure doupdate_flash_message_via_turbo_stream(@@ -147,7 +147,7 @@ module Admin::Settingsprivate- def render_project_list+ def render_project_list(url_for_action: action_name)update_via_turbo_stream(component: Settings::ProjectCustomFields::ProjectCustomFieldMapping::NewProjectMappingComponent.new(project_mapping: ProjectCustomFieldProjectMapping.new(project_custom_field: @custom_field),@@ -157,7 +157,7 @@ module Admin::Settingsupdate_via_turbo_stream(component: Settings::ProjectCustomFields::ProjectCustomFieldMapping::TableComponent.new(query: project_custom_field_mappings_query,- params: { custom_field: @custom_field }+ params: { custom_field: @custom_field, url_for_action: }))enddiff --git a/spec/features/admin/project_custom_fields/project_mappings_spec.rb b/spec/features/admin/project_custom_fields/project_mappings_spec.rbindex a1e32cae731..1dca647478f 100644--- a/spec/features/admin/project_custom_fields/project_mappings_spec.rb+++ b/spec/features/admin/project_custom_fields/project_mappings_spec.rb@@ -57,7 +57,7 @@ RSpec.describe "Project Custom Field Mappings", :js dovisit project_mappings_admin_settings_project_custom_field_path(project_custom_field)end- it "renders the project custom field mappings page" do+ it "renders a list of projects linked to the custom field" doaggregate_failures "shows a correct breadcrumb menu" dowithin ".PageHeader-breadcrumbs" doexpect(page).to have_link("Administration")@@ -80,15 +80,9 @@ RSpec.describe "Project Custom Field Mappings", :js doexpect(page).to have_no_text(archived_project.name)endend-- aggregate_failures "allows to unlinking a project" do- project_custom_field_mappings_page.click_menu_item_of("Deactivate for this project", project)-- expect(page).to have_no_text(project.name)- endend- it "allows to link a project" do+ it "allows linking a project to a custom field" doproject = create(:project)subproject = create(:project, parent: project)click_on "Add projects"@@ -107,6 +101,41 @@ RSpec.describe "Project Custom Field Mappings", :js doexpect(page).to have_text(project.name)expect(page).to have_text(subproject.name)++ aggregate_failures "pagination links maintain the correct url" do+ within ".op-pagination" do+ pagination_links = page.all(".op-pagination--item-link")+ expect(pagination_links.size).to be_positive++ pagination_links.each do |pagination_link|+ uri = URI.parse(pagination_link["href"])+ expect(uri.path).to eq(project_mappings_admin_settings_project_custom_field_path(project_custom_field))+ end+ end+ end+ end++ it "allows unlinking a project from a custom field" do+ project = create(:project)+ create(:project_custom_field_project_mapping, project_custom_field:, project:)++ visit project_mappings_admin_settings_project_custom_field_path(project_custom_field)++ project_custom_field_mappings_page.click_menu_item_of("Deactivate for this project", project)++ expect(page).to have_no_text(project.name)++ aggregate_failures "pagination links maintain the correct url after unlinking is done" do+ within ".op-pagination" do+ pagination_links = page.all(".op-pagination--item-link")+ expect(pagination_links.size).to be_positive++ pagination_links.each do |pagination_link|+ uri = URI.parse(pagination_link["href"])+ expect(uri.path).to eq(project_mappings_admin_settings_project_custom_field_path(project_custom_field))+ end+ end+ endendcontext "and the project custom field is required" do