From 00ec7fa21c22232f7e6affe5ddc9f71fe067393c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Wed, 25 Oct 2023 22:14:07 +0200 Subject: [PATCH] WIP Add RS auths/apps to Storage dashboard --- app/components/rs_auth_component.html.erb | 25 +++++++++++++++++++ app/components/rs_auth_component.rb | 8 ++++++ .../services/remotestorage_controller.rb | 1 + .../services/remotestorage/dashboard.html.erb | 11 +++++++- config/routes.rb | 4 +++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/components/rs_auth_component.html.erb create mode 100644 app/components/rs_auth_component.rb diff --git a/app/components/rs_auth_component.html.erb b/app/components/rs_auth_component.html.erb new file mode 100644 index 0000000..4295bc1 --- /dev/null +++ b/app/components/rs_auth_component.html.erb @@ -0,0 +1,25 @@ +
+
+ <%= image_tag s3_image_url(@web_app.icon), class: "h-full w-full" %> +
+
+

+ <%= @web_app.name %> +

+

+ <%= @auth.client_id %> +

+
+ + + + + +
+

+ <%= link_to "#", class: "btn-md btn-outline text-red-700 relative" do %> + Revoke access + <% end %> +

+
+
diff --git a/app/components/rs_auth_component.rb b/app/components/rs_auth_component.rb new file mode 100644 index 0000000..ed588bf --- /dev/null +++ b/app/components/rs_auth_component.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class RsAuthComponent < ViewComponent::Base + def initialize(auth:) + @auth = auth + @web_app = auth.web_app + end +end diff --git a/app/controllers/services/remotestorage_controller.rb b/app/controllers/services/remotestorage_controller.rb index 5d455ba..5ed1a85 100644 --- a/app/controllers/services/remotestorage_controller.rb +++ b/app/controllers/services/remotestorage_controller.rb @@ -7,6 +7,7 @@ class Services::RemotestorageController < Services::BaseController # unless current_user.services_enabled.include?(:remotestorage) # redirect_to service_remotestorage_info_path # end + @rs_auths = current_user.remote_storage_authorizations end private diff --git a/app/views/services/remotestorage/dashboard.html.erb b/app/views/services/remotestorage/dashboard.html.erb index f6b0932..1a70995 100644 --- a/app/views/services/remotestorage/dashboard.html.erb +++ b/app/views/services/remotestorage/dashboard.html.erb @@ -2,6 +2,15 @@ <%= render MainSimpleComponent.new do %>
-

Feature enabled

+

Connected Apps

+ <% if @rs_auths.any? %> +
+ <% @rs_auths.each do |auth| %> + <%= render RsAuthComponent.new(auth: auth) %> + <% end %> +
+ <% else %> +

No apps connected yet.

+ <% end %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index ad11ec3..785b7a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,4 +100,8 @@ Rails.application.routes.draw do end root to: 'dashboard#index' + + direct :s3_image do |blob| + File.join(ENV['S3_ALIAS_HOST'], blob.key) + end end