Files
akkounts/app/components/rs_auth_component.rb
T
raucao cd87c1f61a
CI / Test (pull_request) Successful in 41s
Add storage dashboard card and per-app details modal
- Rework RsAuthComponent into a card that shows the app, its device, an
  access summary and the permission status
- Add RsAuthDetailsModalComponent with the full scope list, device,
  connected date and permission expiry, plus Launch and Revoke actions
  (built on the existing ModalComponent)
- Add RemoteStorageAuthorization#device_name (parsed from the user agent)
  and #expired?
- Sort connected apps by name

Part of #254
2026-11-02 16:40:33 +04:00

37 lines
748 B
Ruby

# frozen_string_literal: true
class RsAuthComponent < ViewComponent::Base
include OauthHelper
def initialize(auth:)
@auth = auth
@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 scope_summary
return "All folders and files" if root_access?
count = @auth.permissions.size
"#{count} #{'folder'.pluralize(count)}"
end
def device_name
@auth.device_name.presence || "Unknown device"
end
def expiry_label
return "Never expires" if @auth.expire_at.blank?
return "Expired" if @auth.expired?
"Expires #{@auth.expire_at.strftime('%-d %b %Y')}"
end
end