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

refactor: use ViewComponent collection rendering to reduce view code size

Christophe Bliard94b3742f87a0
diff --git a/app/components/activities/item_component.rb b/app/components/activities/item_component.rb
index 89dbf8a33d4..ccfba09fb02 100644
--- a/app/components/activities/item_component.rb
+++ b/app/components/activities/item_component.rb
@@ -29,6 +29,8 @@
#++
class Activities::ItemComponent < ViewComponent::Base
+ with_collection_parameter :event
+
def initialize(event:, display_user: true)
super()
@event = event
diff --git a/app/components/activities/list_component.html.erb b/app/components/activities/list_component.html.erb
index 4abfc32f0f2..984834918e9 100644
--- a/app/components/activities/list_component.html.erb
+++ b/app/components/activities/list_component.html.erb
@@ -1,5 +1,3 @@
<ul class="op-activity-list">
- <% @events.each do |event| -%>
- <%= render(Activities::ItemComponent.new(event:, display_user: @display_user)) %>
- <% end -%>
+ <%= render(Activities::ItemComponent.with_collection(@events, display_user: @display_user)) %>
</ul>