Defect #41880
closedPlugin activity icons broken after switching to SVG icons
0%
Description
When a plugin is registered as ActivityProvider, their activities can't get an icon.
I already created the config/icon_source.yml and for the "menu :admin_menu" it works, thanks to #41715.
But no luck for the plugin activities.
In _activities.html.erb it gets the event and passes its type to get the icon, but it misses the info that the icon must be searched in the plugin assets.
<%= activity_event_type_icon e.event_type %>
Is it not possible anymore or am I holding it wrong?
Files
Updated by Marius BĂLTEANU about 1 month ago
- Assignee set to Marius BĂLTEANU
- Target version set to 6.0.2
Updated by Marius BĂLTEANU about 1 month ago
- Status changed from New to Confirmed
Is your plugin open source to run a test?
Updated by Stefan Rinkes about 1 month ago
- File activity_test.zip activity_test.zip added
I compacted it in a minimal sample.
This should give you an activity entry in your first project.
The SVG-URL is for example: href="/assets/icons-xxxxx.svg#icon--test-activity"
But should be something like: href="/assets/plugin_assets/activity_test/icons-xxxxx.svg#icon--test-activity"
Updated by Marius BĂLTEANU about 1 month ago
Thanks! I will take a look these days.
Updated by Marius BĂLTEANU 27 days ago
I'm not sure which is the best solution that can be delivered in a patch version, any ideea is welcome!
Updated by Marius BĂLTEANU 27 days ago
- File 0001-WIP.patch added
- File clipboard-202412100153-xh5so.png clipboard-202412100153-xh5so.png added
Attached is one way to fix this:
Updated by Marius BĂLTEANU 26 days ago
- Status changed from Confirmed to Resolved
- Resolution set to Fixed
I've committed the fix.
Updated by Marius BĂLTEANU 26 days ago
- Subject changed from Plugin Activity Icons broken with switch to SVGs to Plugin activity icons broken after switching to SVG icons
Updated by Stefan Rinkes 26 days ago
Updated by Stefan Rinkes 25 days ago
After trying it I don't think this is probably fixed.
I still see two issues:- Looks to me you can now only have one plugin which registers as an ActivityProvider. Icons only work for one loaded plugin.
- We have a class which inherites from Journal, which acts_as_activity_provider for issues. So
e.activity_provider_options.keys[0]
ends up as 'issues' and not the wanted key.
Updated by Stefan Rinkes 25 days ago
I came up with this diff, so plugins can register like this for their classes:
Redmine::Activity.map do |activity|
activity.register :test_activities, class_name: %w(TestActivity), plugin: :activity_test
end
Also works for multiple plugins with ActivityProviders.
---
app/views/activities/_activities.html.erb | 2 +-
lib/redmine/activity.rb | 15 +++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/app/views/activities/_activities.html.erb b/app/views/activities/_activities.html.erb
index 21ec1fb28..f2d8e22bd 100644
--- a/app/views/activities/_activities.html.erb
+++ b/app/views/activities/_activities.html.erb
@@ -4,7 +4,7 @@
<dl>
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
- <%= activity_event_type_icon e.event_type, plugin: Redmine::Activity.plugin_name(e.activity_provider_options.keys[0]) %>
+ <%= activity_event_type_icon e.event_type, plugin: Redmine::Activity.plugin_name(e.class) %>
<%= avatar(e.event_author) if e.respond_to?(:event_author) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
diff --git a/lib/redmine/activity.rb b/lib/redmine/activity.rb
index 826b81c9e..3189f4fb1 100644
--- a/lib/redmine/activity.rb
+++ b/lib/redmine/activity.rb
@@ -19,11 +19,11 @@
module Redmine
module Activity
- mattr_accessor :available_event_types, :default_event_types, :plugins_event_types, :providers
+ mattr_accessor :available_event_types, :default_event_types, :plugins_event_classes, :providers
@@available_event_types = []
@@default_event_types = []
- @@plugins_event_types = {}
+ @@plugins_event_classes = {}
@@providers = Hash.new {|h, k| h[k]=[]}
class << self
@@ -41,19 +41,22 @@ module Redmine
@@available_event_types << event_type unless @@available_event_types.include?(event_type)
@@default_event_types << event_type unless options[:default] == false
- @@plugins_event_types = { event_type => options[:plugin].to_s } unless options[:plugin].nil?
+ if options[:plugin]
+ providers.each do | provider |
+ @@plugins_event_classes[provider] = options[:plugin].to_s
+ end
+ end
@@providers[event_type] += providers
end
def delete(event_type)
@@available_event_types.delete event_type
@@default_event_types.delete event_type
- @@plugins_event_types.delete(event_type)
@@providers.delete(event_type)
end
- def plugin_name(event_type)
- @@plugins_event_types[event_type]
+ def plugin_name(class_name)
+ @@plugins_event_classes[class_name.to_s]
end
end
end
--
2.43.0