diff --git a/app/components/app_catalog/web_app_icon_component.html.erb b/app/components/app_catalog/web_app_icon_component.html.erb new file mode 100644 index 0000000..3f9c5f3 --- /dev/null +++ b/app/components/app_catalog/web_app_icon_component.html.erb @@ -0,0 +1,5 @@ +<% if @image_url %> + <%= image_tag @image_url, class: "h-full w-full" %> +<% else %> + <%= render partial: "icons/remotestorage", locals: { custom_class: "h-full w-full p-0.5 text-gray-200" } %> +<% end %> diff --git a/app/components/app_catalog/web_app_icon_component.rb b/app/components/app_catalog/web_app_icon_component.rb new file mode 100644 index 0000000..8421d4f --- /dev/null +++ b/app/components/app_catalog/web_app_icon_component.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module AppCatalog + class WebAppIconComponent < ViewComponent::Base + def initialize(web_app:) + if web_app&.icon&.attached? + @image_url = image_url_for(web_app.icon) + elsif web_app&.apple_touch_icon&.attached? + @image_url = image_url_for(web_app.apple_touch_icon) + end + end + + def image_url_for(attachment) + if Setting.s3_enabled? + s3_image_url(attachment) + else + Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true) + end + end + end +end diff --git a/app/components/rs_auth_component.html.erb b/app/components/rs_auth_component.html.erb index 18ffcc8..535dc1b 100644 --- a/app/components/rs_auth_component.html.erb +++ b/app/components/rs_auth_component.html.erb @@ -1,16 +1,10 @@
<%= @auth.client_id %> diff --git a/app/views/icons/_remotestorage.html.erb b/app/views/icons/_remotestorage.html.erb index 2daafc4..4de0c04 100644 --- a/app/views/icons/_remotestorage.html.erb +++ b/app/views/icons/_remotestorage.html.erb @@ -1,5 +1,5 @@ -