Address review nits in the storage dashboard
CI / Test (pull_request) Successful in 43s

- Move the app display name and a root-access helper onto
  RemoteStorageAuthorization, used by both components and the controller,
  removing the duplicated fallback chain and the unused OauthHelper includes
- Summarise the card's categories from the union of the app's authorizations'
  scopes, so an older token with broader access is not understated

Part of #254
This commit is contained in:
raucao committed 2026-11-03 11:44:27 +04:00
1 parent 2b1290863c
commit 0b4bb21aa7
6 files changed
+18 -20

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
</div>
<div class="min-w-0 flex-grow">
<h4 class="text-lg font-bold truncate"><%= name %></h4>
<h4 class="text-lg font-bold truncate"><%= @auth.display_name %></h4>
<p class="text-sm text-gray-500 truncate"><%= @auth.client_id %></p>
<p class="mt-2 text-sm text-gray-600">
<%= device_summary %>
+6 -6
View File
@@ -1,26 +1,26 @@
# frozen_string_literal: true
class RsAuthComponent < ViewComponent::Base
include OauthHelper
def initialize(authorizations:)
@authorizations = authorizations
@auth = authorizations.first
@web_app = @auth.web_app
end
def name
@web_app&.name.presence || @auth.app_name.presence || @auth.client_id
# The card summarises the app, so reflect the union of its authorizations'
# scopes (an older token may have broader access than the newest one).
def permissions
@authorizations.flat_map(&:permissions).uniq
end
def root_access?
(@auth.permissions & [":r", ":rw"]).any?
(permissions & [":r", ":rw"]).any?
end
def category_summary
return "All categories and files" if root_access?
count = @auth.permissions.size
count = permissions.size
"#{count} #{'category'.pluralize(count)}"
end
@@ -4,7 +4,7 @@
<%= render AppCatalog::WebAppIconComponent.new(web_app: @web_app) %>
</div>
<div class="min-w-0">
<h4 class="text-lg font-bold truncate"><%= name %></h4>
<h4 class="text-lg font-bold truncate"><%= @auth.display_name %></h4>
<p class="text-sm text-gray-500 truncate"><%= @auth.client_id %></p>
</div>
</div>
@@ -12,7 +12,7 @@
<h5 class="mt-6 mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500">
Access
</h5>
<%= render RsScopeListComponent.new(scopes: @auth.permissions, root: root_access?) %>
<%= render RsScopeListComponent.new(scopes: @auth.permissions, root: @auth.root_access?) %>
<h5 class="mt-6 mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500">
Connected devices
@@ -1,22 +1,12 @@
# frozen_string_literal: true
class RsAuthDetailsModalComponent < ViewComponent::Base
include OauthHelper
def initialize(authorizations:)
@authorizations = authorizations
@auth = authorizations.first
@web_app = @auth.web_app
end
def name
@web_app&.name.presence || @auth.app_name.presence || @auth.client_id
end
def root_access?
(@auth.permissions & [":r", ":rw"]).any?
end
def device_name(auth)
auth.device_name.presence || "Unknown device"
end
@@ -49,7 +49,7 @@ class Services::RsAuthsController < Services::BaseController
private
def app_name_for(auth)
auth.web_app&.name.presence || auth.app_name.presence || auth.client_id
auth.display_name
end
def require_service_enabled
@@ -60,6 +60,14 @@ class RemoteStorageAuthorization < ApplicationRecord
[name, os].compact.join(" on ").presence
end
def display_name
web_app&.name.presence || app_name.presence || client_id
end
def root_access?
(permissions & [":r", ":rw"]).any?
end
def delete_token_from_redis
key = "authorizations:#{user.cn}:#{token}"
redis.srem? key, redis.smembers(key)