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: Remove Activities::ListComponent

Christophe Bliard5b43c1494e33
diff --git a/app/components/activities/days_component.html.erb b/app/components/activities/days_component.html.erb
index ef82be8d038..3e55eedb82d 100644
--- a/app/components/activities/days_component.html.erb
+++ b/app/components/activities/days_component.html.erb
@@ -1,11 +1,14 @@
<div class="op-activity-days">
- <% events_by_day.each do |day, events| %>
+ <% events_by_day_sorted_by_newest_first.each do |day, events| %>
<%= content_tag(@header_tag, helpers.format_activity_day(day), class: 'op-activity-days--header') %>
- <%= render(Activities::ListComponent.new(events:,
- current_project: @current_project,
- display_user: @display_user,
- activity_page: @activity_page))
- %>
+ <ul class="op-activity-list">
+ <%=
+ render(Activities::ItemComponent.with_collection(events,
+ current_project: @current_project,
+ display_user: @display_user,
+ activity_page: @activity_page))
+ %>
+ </ul>
<% end -%>
</div>
diff --git a/app/components/activities/days_component.rb b/app/components/activities/days_component.rb
index 807cca8d276..b138a5a0f43 100644
--- a/app/components/activities/days_component.rb
+++ b/app/components/activities/days_component.rb
@@ -38,9 +38,10 @@ class Activities::DaysComponent < ViewComponent::Base
@activity_page = activity_page
end
- def events_by_day
- @events_by_day ||= @events
+ def events_by_day_sorted_by_newest_first
+ @events_by_day_sorted_by_newest_first ||= @events
.group_by { |e| e.event_datetime.in_time_zone(User.current.time_zone).to_date }
+ .transform_values { |events| events.sort { |x, y| y.event_datetime <=> x.event_datetime } }
.sort_by { |day, _events| day }
.reverse
end
diff --git a/app/components/activities/list_component.html.erb b/app/components/activities/list_component.html.erb
deleted file mode 100644
index d732652e7bd..00000000000
--- a/app/components/activities/list_component.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<ul class="op-activity-list">
- <%=
- render(Activities::ItemComponent.with_collection(@events,
- current_project: @current_project,
- display_user: @display_user,
- activity_page: @activity_page))
-
- %>
-</ul>
diff --git a/app/components/activities/list_component.rb b/app/components/activities/list_component.rb
deleted file mode 100644
index 784eac34f39..00000000000
--- a/app/components/activities/list_component.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2022 the OpenProject GmbH
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License version 3.
-#
-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See COPYRIGHT and LICENSE files for more details.
-#++
-
-class Activities::ListComponent < ViewComponent::Base
- def initialize(events:, current_project:, display_user: true, activity_page: nil)
- super()
- @events = events.sort { |x, y| y.event_datetime <=> x.event_datetime }
- @current_project = current_project
- @display_user = display_user
- @activity_page = activity_page
- end
-end