Skip to content

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

Bug/55505 Reinstate listing archived projects in project attributes "enabled in projects" page, just disable the "Deactivate in project" option (#15862)

Kabiru Mwenja651c056060f6
diff --git a/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb b/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb
index b7065bee591..3fa86bf6f1e 100644
--- a/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb
+++ b/app/components/settings/project_custom_fields/project_custom_field_mapping/row_component.rb
@@ -43,14 +43,15 @@ module Settings
private
def more_menu_detach_project
- if User.current.admin
+ project = model.first
+ if User.current.admin && project.active?
{
scheme: :default,
icon: nil,
label: I18n.t("projects.settings.project_custom_fields.actions.deactivate_for_project"),
href: unlink_admin_settings_project_custom_field_path(
id: @table.params[:custom_field].id,
- project_custom_field_project_mapping: { project_id: model.first.id }
+ project_custom_field_project_mapping: { project_id: project.id }
),
data: { turbo_method: :delete }
}
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index ffcb43b7d77..91477b145d8 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -167,7 +167,6 @@ module Admin::Settings
name: "project-custom-field-mappings-#{@custom_field.id}"
) do |query|
query.where(:available_project_attributes, "=", [@custom_field.id])
- query.where("active", "=", OpenProject::Database::DB_VALUE_TRUE)
query.select(:name)
query.order("lft" => "asc")
end
diff --git a/spec/features/admin/project_custom_fields/project_mappings_spec.rb b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
index a1e32cae731..c3442a5efb8 100644
--- a/spec/features/admin/project_custom_fields/project_mappings_spec.rb
+++ b/spec/features/admin/project_custom_fields/project_mappings_spec.rb
@@ -77,7 +77,11 @@ RSpec.describe "Project Custom Field Mappings", :js do
aggregate_failures "shows the correct project mappings" do
within "#project-table" do
expect(page).to have_text(project.name)
- expect(page).to have_no_text(archived_project.name)
+ expect(page).to have_text(archived_project.name)
+
+ within("tr#settings-project-custom-fields-project-custom-field-mapping-row-component-project-#{archived_project.id}") do
+ expect(page.find(".buttons")).not_to have_test_selector("project-list-row--action-menu")
+ end
end
end