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: clearer code

Christophe Bliard59fa598a2995
diff --git a/app/components/activity_item_component.html.erb b/app/components/activity_item_component.html.erb
index ad5fbe70ba6..7d248232d29 100644
--- a/app/components/activity_item_component.html.erb
+++ b/app/components/activity_item_component.html.erb
@@ -6,16 +6,16 @@
<% end -%>
</div>
<%=
- render(ActivityItemSubtitleComponent.new(user: @display_user && @event.event_author,
+ render(ActivityItemSubtitleComponent.new(user: display_user? && @event.event_author,
datetime: @event.event_datetime,
is_creation: @journal.initial?))
%>
<% if @event.event_description.present? -%>
<div class="op-activity-list--item-description">
- <%= truncate_formatted_text(@event.event_description) %>
+ <%= helpers.truncate_formatted_text(@event.event_description) %>
</div>
<% end -%>
- <% if show_details? -%>
+ <% if display_details? -%>
<ul class="op-activity-list--item-details">
<% rendered_details.each do |detail| -%>
<li class="op-activity-list--item-detail"><%= detail %></li>
diff --git a/app/components/activity_item_component.rb b/app/components/activity_item_component.rb
index e67753b16a7..eb28c1f7d6a 100644
--- a/app/components/activity_item_component.rb
+++ b/app/components/activity_item_component.rb
@@ -29,12 +29,6 @@
#++
class ActivityItemComponent < ViewComponent::Base
- delegate :avatar,
- :format_time,
- :link_to_user,
- :truncate_formatted_text,
- to: :helpers
-
def initialize(event:, journal:, display_user: true)
super()
@event = event
@@ -46,7 +40,11 @@ class ActivityItemComponent < ViewComponent::Base
@journal.journable_type != 'Project'
end
- def show_details?
+ def display_user?
+ @display_user
+ end
+
+ def display_details?
return false if @journal.initial?
rendered_details.present?
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index f99c1115b8e..3b01da2e447 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -33,7 +33,7 @@ describe 'index users', js: true do
let(:index_page) { Pages::Admin::Users::Index.new }
- it 'works almost correctly', with_settings: { journal_aggregation_time_minutes: 0 } do
+ it 'displays the user activity list', with_settings: { journal_aggregation_time_minutes: 0 } do
# create some activities
project = create(:project_with_types)
project.update(name: 'new name', description: 'new project description')