Rework some of the OAuth2 views, adding links and messages when there are no applications.

This commit is contained in:
Andy Allan 2021-05-12 12:04:56 +01:00
parent b96f3867e6
commit 7c26d84a84
7 changed files with 70 additions and 45 deletions

View file

@ -1,7 +1,7 @@
<tr> <tr>
<td class="align-middle"> <td class="align-middle">
<ul class="list-unstyled mb-0"> <ul class="list-unstyled mb-0">
<li><%= application.name %></li> <li><%= link_to application.name, oauth_application_path(application) %></li>
<% application.redirect_uri.split.each do |uri| -%> <% application.redirect_uri.split.each do |uri| -%>
<li class="text-muted"><%= uri %></li> <li class="text-muted"><%= uri %></li>
<% end -%> <% end -%>

View file

@ -2,12 +2,22 @@
<h1><%= t ".title" %></h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<% if @applications.length > 0 %>
<table class="table table-borderless table-striped">
<thead>
<th><%= t ".name" %></th>
<th><%= t ".permissions" %></th>
<th></th>
<th></th>
</thead>
<tbody>
<%= render :partial => "application", :collection => @applications %>
</tbody>
</table>
<% else %>
<p><%= t ".no_applications_html", :oauth2 => link_to(t(".oauth_2"), "https://oauth.net/2/") %></p>
<% end %>
<p> <p>
<%= link_to t(".new"), new_oauth_application_path, :class => "btn btn-outline-primary" %> <%= link_to t(".new"), new_oauth_application_path, :class => "btn btn-outline-primary" %>
</p> </p>
<table class="table table-borderless table-striped">
<tbody>
<%= render :partial => "application", :collection => @applications %>
</tbody>
</table>

View file

@ -42,3 +42,8 @@
</td> </td>
</tr> </tr>
</table> </table>
<div>
<%= link_to t(".edit"), edit_oauth_application_path(@application), :class => "btn btn-outline-primary" %>
<%= link_to t(".delete"), oauth_application_path(@application), { :method => :delete, :class => "btn btn-outline-danger", :data => { :confirm => t(".confirm_delete") } } %>
</td>

View file

@ -10,9 +10,8 @@
<% end -%> <% end -%>
</ul> </ul>
<div class="container"> <div class="row justify-content-start no-gutters mx-n1">
<div class="row justify-content-start"> <div class="col-auto mx-1">
<div class="col-auto pl-0">
<%= bootstrap_form_tag :action => :create do |f| %> <%= bootstrap_form_tag :action => :create do |f| %>
<%= f.hidden_field :client_id, :value => @pre_auth.client.uid %> <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
<%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %> <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
@ -24,7 +23,7 @@
<%= f.primary t(".authorize") %> <%= f.primary t(".authorize") %>
<% end %> <% end %>
</div> </div>
<div class="col-auto pl-0"> <div class="col-auto mx-1">
<%= bootstrap_form_tag :action => :destroy, :html => { :method => :delete } do |f| %> <%= bootstrap_form_tag :action => :destroy, :html => { :method => :delete } do |f| %>
<%= f.hidden_field :client_id, :value => @pre_auth.client.uid %> <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
<%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %> <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
@ -37,4 +36,3 @@
<% end %> <% end %>
</div> </div>
</div> </div>
</div>

View file

@ -1,6 +1,6 @@
<tr> <tr>
<td class="align-middle"> <td class="align-middle">
<%= application.name %> <%= link_to application.name, oauth_application_path(application) %>
</td> </td>
<td class="align-middle"> <td class="align-middle">
<ul class="list-unstyled mb-0"> <ul class="list-unstyled mb-0">

View file

@ -2,6 +2,7 @@
<h1><%= t ".title" %></h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<% if @applications.length > 0 %>
<table class="table table-borderless table-striped"> <table class="table table-borderless table-striped">
<thead> <thead>
<th><%= t ".application" %></th> <th><%= t ".application" %></th>
@ -12,3 +13,6 @@
<%= render :partial => "application", :collection => @applications %> <%= render :partial => "application", :collection => @applications %>
</tbody> </tbody>
</table> </table>
<% else %>
<p><%= t ".no_applications_html", :oauth2 => link_to(t(".oauth_2"), "https://oauth.net/2/") %></p>
<% end %>

View file

@ -2329,7 +2329,11 @@ en:
oauth2_applications: oauth2_applications:
index: index:
title: "My client applications" title: "My client applications"
new: "Create new application" no_applications_html: "Do you have an application you would like to register for use with us using the %{oauth2} standard? You must register your application before it can make OAuth requests to this service."
oauth_2: "OAuth 2"
new: "Register new application"
name: "Name"
permissions: "Permissions"
application: application:
edit: "Edit" edit: "Edit"
delete: "Delete" delete: "Delete"
@ -2339,6 +2343,9 @@ en:
edit: edit:
title: "Edit your application" title: "Edit your application"
show: show:
edit: "Edit"
delete: "Delete"
confirm_delete: "Delete this application?"
client_id: "Client ID" client_id: "Client ID"
client_secret: "Client Secret" client_secret: "Client Secret"
client_secret_warning: "Make sure to save this secret - it will not be accessible again" client_secret_warning: "Make sure to save this secret - it will not be accessible again"
@ -2364,6 +2371,7 @@ en:
title: "My authorized applications" title: "My authorized applications"
application: "Application" application: "Application"
permissions: "Permissions" permissions: "Permissions"
no_applications_html: "You have not yet authorized any %{oauth2} applications."
application: application:
revoke: "Revoke Access" revoke: "Revoke Access"
confirm_revoke: "Revoke access for this application?" confirm_revoke: "Revoke access for this application?"