From 7c26d84a84b6bf0a51173117ecd0dd57d71ee329 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 12 May 2021 12:04:56 +0100 Subject: [PATCH] Rework some of the OAuth2 views, adding links and messages when there are no applications. --- .../oauth2_applications/_application.html.erb | 2 +- app/views/oauth2_applications/index.html.erb | 22 +++++--- app/views/oauth2_applications/show.html.erb | 5 ++ app/views/oauth2_authorizations/new.html.erb | 50 +++++++++---------- .../_application.html.erb | 2 +- .../index.html.erb | 24 +++++---- config/locales/en.yml | 10 +++- 7 files changed, 70 insertions(+), 45 deletions(-) diff --git a/app/views/oauth2_applications/_application.html.erb b/app/views/oauth2_applications/_application.html.erb index f08f7be93..564fa81eb 100644 --- a/app/views/oauth2_applications/_application.html.erb +++ b/app/views/oauth2_applications/_application.html.erb @@ -1,7 +1,7 @@ -
-
-
- <%= 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 %> -
-
- <%= 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 %> -
+
+
+ <%= 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 %> +
+
+ <%= 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 %>
diff --git a/app/views/oauth2_authorized_applications/_application.html.erb b/app/views/oauth2_authorized_applications/_application.html.erb index f8e9a1185..3781c1df3 100644 --- a/app/views/oauth2_authorized_applications/_application.html.erb +++ b/app/views/oauth2_authorized_applications/_application.html.erb @@ -1,6 +1,6 @@ - <%= application.name %> + <%= link_to application.name, oauth_application_path(application) %>
    diff --git a/app/views/oauth2_authorized_applications/index.html.erb b/app/views/oauth2_authorized_applications/index.html.erb index dca65e9f9..336de1406 100644 --- a/app/views/oauth2_authorized_applications/index.html.erb +++ b/app/views/oauth2_authorized_applications/index.html.erb @@ -2,13 +2,17 @@

    <%= t ".title" %>

    <% end %> - - - - - - - - <%= render :partial => "application", :collection => @applications %> - -
    <%= t ".application" %><%= t ".permissions" %>
    +<% if @applications.length > 0 %> + + + + + + + + <%= render :partial => "application", :collection => @applications %> + +
    <%= t ".application" %><%= t ".permissions" %>
    +<% else %> +

    <%= t ".no_applications_html", :oauth2 => link_to(t(".oauth_2"), "https://oauth.net/2/") %>

    +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index dfb8c25eb..91a39eb5c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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?" -- 2.43.2