3 safe_join(UserRole::ALL_ROLES.filter_map { |role| role_icon(user, role) }, " ")
6 def role_icon(user, role)
7 if current_user&.administrator?
9 link_to role_icon_svg_tag(role, false, t("users.show.role.revoke.#{role}")),
10 revoke_role_path(user, role),
12 :data => { :confirm => t("user_role.revoke.are_you_sure", :name => user.display_name, :role => role) }
14 link_to role_icon_svg_tag(role, true, t("users.show.role.grant.#{role}")),
15 grant_role_path(user, role),
17 :data => { :confirm => t("user_role.grant.are_you_sure", :name => user.display_name, :role => role) }
19 elsif user.role?(role)
20 role_icon_svg_tag(role, false, t("users.show.role.#{role}"))
24 def role_icon_svg_tag(role, blank, title)
26 "administrator" => "#f69e42",
27 "moderator" => "#0606ff",
28 "importer" => "#38e13a"
30 color = role_colors[role] || "currentColor"
32 path_data = "M 10,2 8.125,8 2,8 6.96875,11.71875 5,18 10,14 15,18 13.03125,11.71875 18,8 11.875,8 10,2 z"
33 tag.svg(:width => 20, :height => 20) do
34 concat tag.title(title)
35 concat tag.path(:d => path_data, :fill => color, :stroke => color, "stroke-width" => 2, "stroke-linejoin" => "round")
36 concat tag.path(:d => path_data, :fill => "#fff") if blank