From 12d797b3513bba475a8939eda9fa202f28bc5306 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Tue, 7 May 2024 15:23:38 +0300 Subject: [PATCH] Use inline svgs for moderator scope icons --- app/helpers/authorization_helper.rb | 2 +- app/helpers/user_roles_helper.rb | 4 ++-- config/locales/en.yml | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/helpers/authorization_helper.rb b/app/helpers/authorization_helper.rb index 11c8c298f..3a95d54ea 100644 --- a/app/helpers/authorization_helper.rb +++ b/app/helpers/authorization_helper.rb @@ -6,7 +6,7 @@ module AuthorizationHelper html << t("oauth.scopes.#{scope}") if Oauth::MODERATOR_SCOPES.include? scope html << " " - html << image_tag("roles/moderator.png", :srcset => image_path("roles/moderator.svg", :class => "align-text-bottom"), :size => "20x20") + html << role_icon_svg_tag("moderator", false, t("oauth.for_roles.moderator"), :class => "align-text-bottom") end safe_join(html) end diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 1308cdfa7..4634cb015 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -21,7 +21,7 @@ module UserRolesHelper end end - def role_icon_svg_tag(role, blank, title) + def role_icon_svg_tag(role, blank, title, **options) role_colors = { "administrator" => "#f69e42", "moderator" => "#0606ff", @@ -30,7 +30,7 @@ module UserRolesHelper color = role_colors[role] || "currentColor" 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" - tag.svg(:width => 20, :height => 20) do + tag.svg(:width => 20, :height => 20, **options) do concat tag.title(title) concat tag.path(:d => path_data, :fill => color, :stroke => color, "stroke-width" => 2, "stroke-linejoin" => "round") concat tag.path(:d => path_data, :fill => "#fff") if blank diff --git a/config/locales/en.yml b/config/locales/en.yml index 4570183d0..45c44765d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2637,6 +2637,8 @@ en: write_redactions: Redact map data read_email: Read user email address skip_authorization: Auto approve application + for_roles: + moderator: This permission is for actions available only to moderators oauth_clients: new: title: "Register a new application" -- 2.39.5