<%= auth.device_label %>
- <%= tag.span "Connected #{auth.created_at.strftime('%-d %b %Y')}",
- title: connected_at_title(auth) %>
+ Connected <%= timestamp_tag(auth.created_at, title: connected_at_title(auth)) %>
·
- <%= tag.span status_label(auth),
- title: (expires_at_title(auth) if auth.expire_at.present?),
- class: ("text-red-700" if auth.expired?) %>
+ <%= tag.span class: ("text-red-700" if auth.expired?) do %>
+ <% if auth.expire_at.present? %>
+ <%= expiry_prefix(auth) %> <%= timestamp_tag(auth.expire_at, title: expires_at_title(auth)) %>
+ <% else %>
+ Never expires
+ <% end %>
+ <% end %>
<%= button_to "Revoke access", services_storage_rs_auth_path(auth), method: :delete,
diff --git a/app/components/rs_auth_details_modal_component.rb b/app/components/rs_auth_details_modal_component.rb
index be140d1..90aef7f 100644
--- a/app/components/rs_auth_details_modal_component.rb
+++ b/app/components/rs_auth_details_modal_component.rb
@@ -9,13 +9,15 @@ class RsAuthDetailsModalComponent < ViewComponent::Base
@web_app = @auth.web_app
end
- def status_label(auth)
- return "Never expires" if auth.expire_at.blank?
- return "Expired on #{auth.expire_at.strftime('%-d %b %Y')}" if auth.expired?
+ # "Expires" / "Expired on", or nothing when there is no expiry to describe.
+ def expiry_prefix(auth)
+ return nil if auth.expire_at.blank?
- "Expires #{auth.expire_at.strftime('%-d %b %Y')}"
+ auth.expired? ? "Expired on" : "Expires"
end
+ # Fallbacks for the hover titles, used when JavaScript is unavailable.
+ # app/javascript/local_time.js replaces them with the reader's own zone.
def connected_at_title(auth)
auth.created_at.strftime("%-d %b %Y, %H:%M")
end
@@ -23,4 +25,10 @@ class RsAuthDetailsModalComponent < ViewComponent::Base
def expires_at_title(auth)
auth.expire_at.strftime("%-d %b %Y, %H:%M")
end
+
+ # A