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

Hide activity details for which no formatter exists

Christophe Bliard1aafe4df4168
diff --git a/app/components/activities/item_component.rb b/app/components/activities/item_component.rb
index 4ca2c90b870..077cb6c9db2 100644
--- a/app/components/activities/item_component.rb
+++ b/app/components/activities/item_component.rb
@@ -63,7 +63,7 @@ class Activities::ItemComponent < ViewComponent::Base
@rendered_details ||=
@event.journal
.details
- .flat_map { |detail| @event.journal.render_detail(detail, activity_page: @activity_page) }
+ .filter_map { |detail| @event.journal.render_detail(detail, activity_page: @activity_page) }
end
def format_activity_title(text)
diff --git a/spec/components/activities/item_component_spec.rb b/spec/components/activities/item_component_spec.rb
index 73d20a4185d..0ffdf243d50 100644
--- a/spec/components/activities/item_component_spec.rb
+++ b/spec/components/activities/item_component_spec.rb
@@ -97,4 +97,14 @@ RSpec.describe Activities::ItemComponent, type: :component do
expect(page).to have_css('.op-activity-list--item-title', text: '(Subproject: My subproject)')
end
end
+
+ context 'when a journal change does not have a formatter associated' do
+ it 'does not display the change information' do
+ event.event_description = ''
+ allow(event.journal).to receive(:details).and_return(i_do_not_have_a_formatter_associated: ['old', 'new'])
+ render_inline(described_class.new(event:))
+
+ expect(page).not_to have_css('.op-activity-list--item-detail')
+ end
+ end
end