]> git.openstreetmap.org Git - rails.git/commitdiff
Rework some of the OAuth2 views, adding links and messages when there are no applicat...
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 12 May 2021 11:04:56 +0000 (12:04 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 19 May 2021 15:22:14 +0000 (16:22 +0100)
app/views/oauth2_applications/_application.html.erb
app/views/oauth2_applications/index.html.erb
app/views/oauth2_applications/show.html.erb
app/views/oauth2_authorizations/new.html.erb
app/views/oauth2_authorized_applications/_application.html.erb
app/views/oauth2_authorized_applications/index.html.erb
config/locales/en.yml

index f08f7be9314a82c66e38e6a4d057e319364d9f8d..564fa81ebf33ad83ce07f55b2d8af173de932466 100644 (file)
@@ -1,7 +1,7 @@
 <tr>
   <td class="align-middle">
     <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| -%>
         <li class="text-muted"><%= uri %></li>
       <% end -%>
index a2d4cc0892a25a0a0c373b3d7842d538ea76c25f..240b34d31c6312dcda05739ab3e910dce18d748f 100644 (file)
@@ -2,12 +2,22 @@
   <h1><%= t ".title" %></h1>
 <% 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>
   <%= link_to t(".new"), new_oauth_application_path, :class => "btn btn-outline-primary" %>
 </p>
-
-<table class="table table-borderless table-striped">
-  <tbody>
-    <%= render :partial => "application", :collection => @applications %>
-  </tbody>
-</table>
index 1a991f0c6de004cc780a209bd8fe9be999ebc01e..e8ab7836dbca5a1b282e868635458ac58158867a 100644 (file)
@@ -42,3 +42,8 @@
     </td>
   </tr>
 </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>
index 00d2a01afdc4bf97cb0294605297ec095d3debe2..3b943a043c503f886cc7280160e840725f213b8a 100644 (file)
   <% end -%>
 </ul>
 
-<div class="container">
-  <div class="row justify-content-start">
-    <div class="col-auto pl-0">
-      <%= bootstrap_form_tag :action => :create do |f| %>
-        <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
-        <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
-        <%= f.hidden_field :state, :value => @pre_auth.state %>
-        <%= f.hidden_field :response_type, :value => @pre_auth.response_type %>
-        <%= f.hidden_field :scope, :value => @pre_auth.scope %>
-        <%= f.hidden_field :code_challenge, :value => @pre_auth.code_challenge %>
-        <%= f.hidden_field :code_challenge_method, :value => @pre_auth.code_challenge_method %>
-        <%= f.primary t(".authorize") %>
-      <% end %>
-    </div>
-    <div class="col-auto pl-0">
-      <%= bootstrap_form_tag :action => :destroy, :html => { :method => :delete } do |f| %>
-        <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
-        <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
-        <%= f.hidden_field :state, :value => @pre_auth.state %>
-        <%= f.hidden_field :response_type, :value => @pre_auth.response_type %>
-        <%= f.hidden_field :scope, :value => @pre_auth.scope %>
-        <%= f.hidden_field :code_challenge, :value => @pre_auth.code_challenge %>
-        <%= f.hidden_field :code_challenge_method, :value => @pre_auth.code_challenge_method %>
-        <%= f.submit t(".deny") %>
-      <% end %>
-    </div>
+<div class="row justify-content-start no-gutters mx-n1">
+  <div class="col-auto mx-1">
+    <%= bootstrap_form_tag :action => :create do |f| %>
+      <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
+      <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
+      <%= f.hidden_field :state, :value => @pre_auth.state %>
+      <%= f.hidden_field :response_type, :value => @pre_auth.response_type %>
+      <%= f.hidden_field :scope, :value => @pre_auth.scope %>
+      <%= f.hidden_field :code_challenge, :value => @pre_auth.code_challenge %>
+      <%= f.hidden_field :code_challenge_method, :value => @pre_auth.code_challenge_method %>
+      <%= f.primary t(".authorize") %>
+    <% end %>
+  </div>
+  <div class="col-auto mx-1">
+    <%= bootstrap_form_tag :action => :destroy, :html => { :method => :delete } do |f| %>
+      <%= f.hidden_field :client_id, :value => @pre_auth.client.uid %>
+      <%= f.hidden_field :redirect_uri, :value => @pre_auth.redirect_uri %>
+      <%= f.hidden_field :state, :value => @pre_auth.state %>
+      <%= f.hidden_field :response_type, :value => @pre_auth.response_type %>
+      <%= f.hidden_field :scope, :value => @pre_auth.scope %>
+      <%= f.hidden_field :code_challenge, :value => @pre_auth.code_challenge %>
+      <%= f.hidden_field :code_challenge_method, :value => @pre_auth.code_challenge_method %>
+      <%= f.submit t(".deny") %>
+    <% end %>
   </div>
 </div>
index f8e9a11850cc0cf0e6b77a47c4c4652aaa756267..3781c1df3f264c3607c73b86b3d185cfbe7e615b 100644 (file)
@@ -1,6 +1,6 @@
 <tr>
   <td class="align-middle">
-    <%= application.name %>
+    <%= link_to application.name, oauth_application_path(application) %>
   </td>
   <td class="align-middle">
     <ul class="list-unstyled mb-0">
index dca65e9f9648e2d530ef82508edc43e15e4cd7c3..336de14060d7f9a106b213f6926a061019812dc0 100644 (file)
@@ -2,13 +2,17 @@
   <h1><%= t ".title" %></h1>
 <% end %>
 
-<table class="table table-borderless table-striped">
-  <thead>
-    <th><%= t ".application" %></th>
-    <th><%= t ".permissions" %></th>
-    <th></th>
-  </thead>
-  <tbody>
-    <%= render :partial => "application", :collection => @applications %>
-  </tbody>
-</table>
+<% if @applications.length > 0 %>
+  <table class="table table-borderless table-striped">
+    <thead>
+      <th><%= t ".application" %></th>
+      <th><%= t ".permissions" %></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 %>
index dfb8c25eb7f1beb4c1158b7e5e87ccd10948ffb6..91a39eb5cc683e88ded9d1c69bf9971f04dec290 100644 (file)
@@ -2329,7 +2329,11 @@ en:
   oauth2_applications:
     index:
       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:
       edit: "Edit"
       delete: "Delete"
@@ -2339,6 +2343,9 @@ en:
     edit:
       title: "Edit your application"
     show:
+      edit: "Edit"
+      delete: "Delete"
+      confirm_delete: "Delete this application?"
       client_id: "Client ID"
       client_secret: "Client Secret"
       client_secret_warning: "Make sure to save this secret - it will not be accessible again"
@@ -2364,6 +2371,7 @@ en:
       title: "My authorized applications"
       application: "Application"
       permissions: "Permissions"
+      no_applications_html: "You have not yet authorized any %{oauth2} applications."
     application:
       revoke: "Revoke Access"
       confirm_revoke: "Revoke access for this application?"