]> source.dussan.org Git - redmine.git/commitdiff
Merged r23227 - r23231 from trunk to 6.0-stable (#23980).
authorMarius Balteanu <marius.balteanu@zitec.com>
Sun, 10 Nov 2024 15:36:46 +0000 (15:36 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Sun, 10 Nov 2024 15:36:46 +0000 (15:36 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/6.0-stable@23232 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/assets/images/icons.svg
app/helpers/application_helper.rb
app/helpers/icons_helper.rb
app/views/projects/settings/_members.html.erb
config/icon_source.yml
test/helpers/application_helper_test.rb
test/helpers/icons_helper_test.rb

index c94249ba8c8def7fe68094fa538ad636cdd78fda..84d68904a7b3d54ca2018a0a079682cd54aa34d1 100644 (file)
       <path d="M16 19h6"/>
       <path d="M19 16v6"/>
     </symbol>
+    <symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--key">
+      <path d="M16.555 3.843l3.602 3.602a2.877 2.877 0 0 1 0 4.069l-2.643 2.643a2.877 2.877 0 0 1 -4.069 0l-.301 -.301l-6.558 6.558a2 2 0 0 1 -1.239 .578l-.175 .008h-1.172a1 1 0 0 1 -.993 -.883l-.007 -.117v-1.172a2 2 0 0 1 .467 -1.284l.119 -.13l.414 -.414h2v-2h2v-2l2.144 -2.144l-.301 -.301a2.877 2.877 0 0 1 0 -4.069l2.643 -2.643a2.877 2.877 0 0 1 4.069 0z"/>
+      <path d="M15 9h.01"/>
+    </symbol>
     <symbol viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" id="icon--link">
       <path d="M9 15l6 -6"/>
       <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464"/>
index 4a02d8376b128a64ea56b6c1caf7443162f64dd7..bac8da2667c73ce4f6c63b99b73c98fdba61a960 100644 (file)
@@ -60,23 +60,23 @@ module ApplicationHelper
     only_path = options[:only_path].nil? ? true : options[:only_path]
     case principal
     when User
-      name = h(principal.name(options[:format]))
-      name = "@".html_safe + name if options[:mention]
+      name = principal.name(options[:format])
+      name = "@#{name}" if options[:mention]
       css_classes = ''
       if principal.active? || (User.current.admin? && principal.logged?)
         url = user_url(principal, :only_path => only_path)
         css_classes += principal.css_classes
       end
     when Group
-      name = h(principal.to_s)
+      name = principal.to_s
       url = group_url(principal, :only_path => only_path)
       css_classes = principal.css_classes
     else
-      name = h(principal.to_s)
+      name = principal.to_s
     end
 
     css_classes += " #{options[:class]}" if css_classes && options[:class].present?
-    url ? link_to(principal_icon(principal.class.name.downcase).to_s + name, url, :class => css_classes) : name
+    url ? link_to(principal_icon(principal).to_s + name, url, :class => css_classes) : h(name)
   end
 
   # Displays a link to edit group page if current user is admin
@@ -657,7 +657,7 @@ module ApplicationHelper
           check_box_tag(name, principal.id, false, :id => nil) +
             (avatar(principal, :size => 16).presence ||
                content_tag(
-                 'span', principal_icon(principal.class.name.downcase),
+                 'span', principal_icon(principal),
                  :class => "name icon icon-#{principal.class.name.downcase}"
                )
             ) + principal.to_s
index 5654f3a2f82e87845290f4653714d12f6c4668a2..99006308e5cc3c44d3995ed67040f7b08f15babe 100644 (file)
@@ -36,20 +36,23 @@ module IconsHelper
     end
   end
 
-  def file_icon(entry, name, size: DEFAULT_ICON_SIZE, css_class: nil)
+  def file_icon(entry, name, **options)
     if entry.is_dir?
-      sprite_icon("folder", name, size: size, css_class: css_class)
+      sprite_icon("folder", name, **options)
     else
       icon_name = icon_for_mime_type(Redmine::MimeType.css_class_of(name))
-      sprite_icon(icon_name, name, size: size, css_class: css_class)
+      sprite_icon(icon_name, name, **options)
     end
   end
 
-  def principal_icon(principal_class, size: DEFAULT_ICON_SIZE, css_class: nil)
-    sprite_icon('group', size: size, css_class: css_class) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class)
+  def principal_icon(principal, **options)
+    raise ArgumentError, "First argument has to be a Principal, was #{principal.inspect}" unless principal.is_a?(Principal)
+
+    principal_class = principal.class.name.downcase
+    sprite_icon('group', **options) if ['groupanonymous', 'groupnonmember', 'group'].include?(principal_class)
   end
 
-  def activity_event_type_icon(event_type, size: DEFAULT_ICON_SIZE, css_class: nil)
+  def activity_event_type_icon(event_type, **options)
     icon_name = case event_type
                 when 'reply'
                   'comments'
@@ -61,7 +64,7 @@ module IconsHelper
                   event_type
                 end
 
-    sprite_icon(icon_name, size: size, css_class: css_class)
+    sprite_icon(icon_name, **options)
   end
 
   private
index bd953d2478a4a68d74c018e744b85bb793c6693d..6e13808b6aeef44760f6e1d67aa403d8500952eb 100644 (file)
@@ -20,7 +20,7 @@
   <% next if member.new_record? %>
   <tr id="member-<%= member.id %>" class="member">
   <td class="name icon icon-<%= member.principal.class.name.downcase %>">
-    <%= principal_icon(member.principal.class.name.downcase) %>
+    <%= principal_icon(member.principal) %>
     <%= link_to_user member.principal %>
   </td>
   <td class="roles">
index 05d024718f4be7e48c906030d9def53634e1dbc1..a97b4bcb909def23ed448eb70b78d3fbe953dbc2 100644 (file)
   svg: chevrons-right
 - name: chevrons-left
   svg: chevrons-left
+- name: key
+  svg: key
index a2c4ac82f36cc78155ee08c1e23e68c6451e23ad..3ffa24281a2f9bf53578e6c0406a98d3034fa068 100644 (file)
@@ -1868,8 +1868,8 @@ class ApplicationHelperTest < Redmine::HelperTest
 
   def test_link_to_principal_should_link_to_group
     group = Group.find(10)
-    result = link_to('A Team', '/groups/10', :class => 'group')
-    assert_equal result, link_to_principal(group)
+    result = %r{<a class="group" href="/groups/10"><svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-\w+.svg#icon--group"></use></svg>A Team</a>}
+    assert_match result, link_to_principal(group)
   end
 
   def test_link_to_principal_should_return_string_representation_for_unknown_type_principal
@@ -2027,7 +2027,7 @@ class ApplicationHelperTest < Redmine::HelperTest
       tags = principals_check_box_tags(name, principals)
       principals.each_with_index do |principal, i|
         assert_not_include avatar_tags[i], tags
-        assert_include content_tag('span', principal_icon(principal.class.name.downcase), :class => "name icon icon-#{principal.class.name.downcase}"), tags
+        assert_include content_tag('span', principal_icon(principal), :class => "name icon icon-#{principal.class.name.downcase}"), tags
       end
     end
   end
index 688c6dbac5b0b85ec58da1959fa9ceaa7f4b636a..ab3e743fdeddc61f801fe59e5554d7798b47eace 100644 (file)
@@ -22,6 +22,8 @@ require_relative '../test_helper'
 class IconsHelperTest < Redmine::HelperTest
   include IconsHelper
 
+  fixtures :users
+
   def test_sprite_icon_should_return_svg_with_defaults
     expected = %r{<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-\w+.svg#icon--edit"></use></svg>$}
     icon = sprite_icon('edit')
@@ -98,8 +100,8 @@ class IconsHelperTest < Redmine::HelperTest
   def test_principal_icon_should_return_group_icon_for_group_classes
     expected = %r{<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/icons-\w+.svg#icon--group"></use></svg>}
 
-    %w(groupanonymous groupnonmember group).each do |principal_class|
-      assert_match expected, principal_icon(principal_class)
+    [Principal.find(12), Principal.find(13), Principal.find(10)].each do |principal|
+      assert_match expected, principal_icon(principal)
     end
   end