diff --git a/app/models/user.rb b/app/models/user.rb index 12a72335b..7fecbe7ec 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,6 +36,11 @@ def active_permanent_api_key? api_keys.any? { |key| key.active? && key.permanent? } end + sig { returns(T::Boolean) } + def active_api_key? + api_keys.any?(&:active?) + end + # rubocop:disable Style/ArgumentsForwarding # TODO: Arguments forwarding doesn't seem to be supported by sorbet right now? sig { params(notification: T.untyped, args: T.untyped).void } diff --git a/app/views/api_keys/_api_key.html.erb b/app/views/api_keys/_api_key.html.erb index ebddb54ec..5f0687daf 100644 --- a/app/views/api_keys/_api_key.html.erb +++ b/app/views/api_keys/_api_key.html.erb @@ -1,31 +1,54 @@ -

- Plan type: <%= api_key.plan.capitalize %> -

+
+

+ Plan type: <%= api_key.plan.capitalize %> +

-
- <% if api_key.disabled? %> -

- Key disabled - <%# TODO: Add some ability to question this / contact us %> -

- <% elsif api_key.expires_at.nil? %> -

- Key does not expire -

- <% else %> -

- <% if api_key.expires_at > Time.current %> - <%# TODO: Highlight future expiry in some way? %> - Expires in: - <%= time_tag_with_hover(api_key.expires_at, distance_of_time_in_words(Time.current, api_key.expires_at)) %> - <% else %> - Key expired - <% end %> -

+
+ <% if api_key.disabled? %> +

+ Key disabled + <%# TODO: Add some ability to question this / contact us %> +

+ <% elsif api_key.expires_at.nil? %> +

+ Key does not expire +

+ <% else %> +

+ <% if api_key.expires_at > Time.current %> + <%# TODO: Highlight future expiry in some way? %> + Expires in: + <%= time_tag_with_hover(api_key.expires_at, distance_of_time_in_words(Time.current, api_key.expires_at)) %> + <% else %> + Key expired + <% end %> +

+ <% end %> +
+ +
+ <%# TODO: Add a note for the user to remind them not to share this key with anyone %> + <%= render ClickToCopyComponent.new.with_content(api_key.value) %> +
+ + <% if api_key.expired? && !current_user.active_api_key? %> + <%# TODO: Extract this into a dismissable box component %> +
+
+

Your trial access to our API is up!

+

+ We hope you've found it useful. If you want support choosing a new plan + <%# TODO: Prefill contact form %> + <%= link_to "get in touch", documentation_contact_path, class: "hover:opacity-80 focus:outline-none focus:bg-sun-yellow focus:text-navy font-bold underline" %>. +

+
+ <%# TODO: This button doesn't do anything without javascript, so hide it until js is running %> + +
<% end %>
-
- <%# TODO: Add a note for the user to remind them not to share this key with anyone %> - <%= render ClickToCopyComponent.new.with_content(api_key.value) %> -