From 44578ba65cd8c498612ead5dfe5058c23f80db3f Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 20 Sep 2023 16:52:30 +0200 Subject: [PATCH] fix(attachment): keep direct_upload behavior in poll url Co-Authored-By: Christophe Robillard --- app/components/attachment/edit_component.rb | 2 +- app/controllers/attachments_controller.rb | 1 + app/views/attachments/show.turbo_stream.haml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/components/attachment/edit_component.rb b/app/components/attachment/edit_component.rb index ba8b786cd..5d8c11612 100644 --- a/app/components/attachment/edit_component.rb +++ b/app/components/attachment/edit_component.rb @@ -83,7 +83,7 @@ class Attachment::EditComponent < ApplicationComponent if champ.present? auto_attach_url else - attachment_path(user_can_edit: true, view_as: @view_as, auto_attach_url: @auto_attach_url) + attachment_path(user_can_edit: true, view_as: @view_as, auto_attach_url: @auto_attach_url, direct_upload: @direct_upload) end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ee5d20d79..410c64212 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -6,6 +6,7 @@ class AttachmentsController < ApplicationController @attachment = @blob.attachments.find(params[:id]) @user_can_edit = cast_bool(params[:user_can_edit]) + @direct_upload = cast_bool(params[:direct_upload]) @view_as = params[:view_as]&.to_sym @auto_attach_url = params[:auto_attach_url] diff --git a/app/views/attachments/show.turbo_stream.haml b/app/views/attachments/show.turbo_stream.haml index 440cf52b2..c7cb61769 100644 --- a/app/views/attachments/show.turbo_stream.haml +++ b/app/views/attachments/show.turbo_stream.haml @@ -1,5 +1,5 @@ = turbo_stream.replace dom_id(@attachment, :edit) do - if @user_can_edit - = render Attachment::EditComponent.new(attachment: @attachment, attached_file: @attachment.record.public_send(@attachment.name), auto_attach_url: @auto_attach_url, view_as: @view_as) + = render Attachment::EditComponent.new(attachment: @attachment, attached_file: @attachment.record.public_send(@attachment.name), auto_attach_url: @auto_attach_url, view_as: @view_as, direct_upload: @direct_upload) - else = render Attachment::ShowComponent.new(attachment: @attachment)