Skip to content

Commit

Permalink
Fix display of expired key and still show links to developer document…
Browse files Browse the repository at this point in the history
…ation with expired key
  • Loading branch information
mlandauer committed Aug 28, 2024
1 parent 5c256a2 commit 3415562
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 51 deletions.
4 changes: 3 additions & 1 deletion app/views/api_keys/_api_key.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<%# 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) %>
<% else %>
<%= api_key.value %>
<div class="text-xl text-navy">
<%= api_key.value %>
</div>
<% end %>
</div>

Expand Down
69 changes: 19 additions & 50 deletions app/views/api_keys/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,25 @@
</p>
</div>

<div class="divide-y divide-light-grey">
<%# TODO: Only display this section if we have active keys? %>
<section class="pt-10 pb-14">
<%# TODO: Seems a bit weird having an "active keys" heading if there's no inactive keys heading. Hmmm.... %>
<%= render HeadingComponent.new(tag: :h3, extra_classes: "mb-4").with_content("Active keys") %>
<%# TODO: Sort them into a sensible order %>
<%= render @api_keys %>

<%# TODO: How should this look if there is more than one active key? %>
<%# TODO: Add a sensible sort order %>
<% if @api_keys.select(&:active?).empty? %>
<% if @api_keys.empty? %>
<%= render "create_key_box" %>
<%= render "ongoing_access_box" %>
<% else %>
<%# If a user already has a key (which is now inactive) don't allow them to create another %>
<p class="mb-4 text-xl text-navy">No active keys</p>
<% end %>
<% else %>
<%= render @api_keys.select(&:active?) %>
<% end %>
<p class="text-xl text-navy">
<%# TODO: Link to actual place %>
Check out the <%= pa_link_to "API Developer Documentation", api_howto_path %>
</p>

<p class="text-xl text-navy">
<%# TODO: Link to actual place %>
<%# TODO: Note that the be_nice section has been removed %>
Remind yourself of our <%= pa_link_to "API code of conduct", api_howto_path(anchor: "be_nice") %>
</p>
</section>
<% if @api_keys.empty? %>
<%= render "create_key_box" %>
<% else %>
<%# It would be better to show links to the developer documentation very near to the active key %>
<p class="text-xl text-navy">
Check out the <%= pa_link_to "API Developer Documentation", api_developer_path %>
</p>

<% unless @api_keys.reject(&:active?).empty? %>
<section class="pt-10 text-xl pb-14 text-navy">
<%= render HeadingComponent.new(tag: :h3, extra_classes: "mb-4").with_content("Inactive keys") %>
<%= render @api_keys.reject(&:active?) %>
</section>
<% end %>
<p class="text-xl text-navy">
<%# TODO: Link to actual place %>
<%# TODO: Note that the be_nice section has been removed %>
Remind yourself of our <%= pa_link_to "API code of conduct", api_howto_path(anchor: "be_nice") %>
</p>
<% end %>

<section class="pt-16 text-xl text-navy">
<%# TODO: Add a real link here %>
<%# TODO: Under what circumstances do we say "for continued access"? %>
<%
=begin
%>
<p class="pb-4">
For continued access explore our ongoing plans <%= pa_link_to "here", "#" %>
</p>
<%
=end
%>
<%= image_tag "illustration/dog.svg", alt: "" %>
</section>
</div>
<%# Don't show the ongoing access box if they have an active license that doesn't expire %>
<% unless @api_keys.find(&:active?) && @api_keys.find(&:active?).expires_at.nil? %>
<%= render "ongoing_access_box" %>
<% end %>

0 comments on commit 3415562

Please sign in to comment.