Skip to content

Commit

Permalink
Highlight write_blocks permission when showing authorizations
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Oct 21, 2023
1 parent 9767fd9 commit 33c491d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions app/helpers/authorization_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module AuthorizationHelper
include ActionView::Helpers::TranslationHelper

def authorization_scope(scope)
html = []
if scope == "write_blocks"
html << image_tag("roles/moderator.png", :srcset => image_path("roles/moderator.svg", :class => "align-text-bottom"), :size => "20x20")
html << " "
end
html << t("oauth.scopes.#{scope}")
safe_join(html)
end
end
2 changes: 1 addition & 1 deletion app/views/oauth2_applications/_application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<td class="align-middle">
<ul class="list-unstyled mb-0">
<% application.scopes.each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %> <code class="text-muted">(<%= scope %>)</code></li>
<li><%= authorization_scope(scope) %> <code class="text-muted">(<%= scope %>)</code></li>
<% end -%>
</ul>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/oauth2_authorizations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ul>
<% @pre_auth.scopes.each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %></li>
<li><%= authorization_scope(scope) %></li>
<% end -%>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<td class="align-middle">
<ul class="list-unstyled mb-0">
<% application.authorized_scopes_for(current_user).each do |scope| -%>
<li><%= t "oauth.scopes.#{scope}" %></li>
<li><%= authorization_scope(scope) %></li>
<% end -%>
</ul>
</td>
Expand Down

0 comments on commit 33c491d

Please sign in to comment.