diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-11-10 15:36:46 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-11-10 15:36:46 +0000 |
commit | f26f9c279dc28652d1204a0fbd6bd9a1ed505491 (patch) | |
tree | 4e4d4b32246244443cf53ff7bc7fe7aa4610a405 | |
parent | cb13e7a5ddbf3fe4a4bc92f85e4ba45997825240 (diff) | |
download | redmine-f26f9c279dc28652d1204a0fbd6bd9a1ed505491.tar.gz redmine-f26f9c279dc28652d1204a0fbd6bd9a1ed505491.zip |
Merged r23227 - r23231 from trunk to 6.0-stable (#23980).
git-svn-id: https://svn.redmine.org/redmine/branches/6.0-stable@23232 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/assets/images/icons.svg | 4 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 12 | ||||
-rw-r--r-- | app/helpers/icons_helper.rb | 17 | ||||
-rw-r--r-- | app/views/projects/settings/_members.html.erb | 2 | ||||
-rw-r--r-- | config/icon_source.yml | 2 | ||||
-rw-r--r-- | test/helpers/application_helper_test.rb | 6 | ||||
-rw-r--r-- | test/helpers/icons_helper_test.rb | 6 |
7 files changed, 30 insertions, 19 deletions
diff --git a/app/assets/images/icons.svg b/app/assets/images/icons.svg index c94249ba8..84d68904a 100644 --- a/app/assets/images/icons.svg +++ b/app/assets/images/icons.svg @@ -247,6 +247,10 @@ <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"/> diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4a02d8376..bac8da266 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 5654f3a2f..99006308e 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -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 diff --git a/app/views/projects/settings/_members.html.erb b/app/views/projects/settings/_members.html.erb index bd953d247..6e13808b6 100644 --- a/app/views/projects/settings/_members.html.erb +++ b/app/views/projects/settings/_members.html.erb @@ -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"> diff --git a/config/icon_source.yml b/config/icon_source.yml index 05d024718..a97b4bcb9 100644 --- a/config/icon_source.yml +++ b/config/icon_source.yml @@ -195,3 +195,5 @@ svg: chevrons-right - name: chevrons-left svg: chevrons-left +- name: key + svg: key diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index a2c4ac82f..3ffa24281 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -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 diff --git a/test/helpers/icons_helper_test.rb b/test/helpers/icons_helper_test.rb index 688c6dbac..ab3e743fd 100644 --- a/test/helpers/icons_helper_test.rb +++ b/test/helpers/icons_helper_test.rb @@ -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 |