From 5725144af10cb4ef9ff8cf4fbddf11e459481cb1 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 10:34:58 +0100 Subject: [PATCH 1/8] Add endpoint for starting prints --- app/controllers/print_hosts_controller.rb | 9 +++++++++ app/policies/model_file_policy.rb | 4 ++++ app/policies/print_host_policy.rb | 4 ++++ config/routes/print.rb | 6 +++++- spec/requests/print_hosts_spec.rb | 22 +++++++++++++++++++++- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/app/controllers/print_hosts_controller.rb b/app/controllers/print_hosts_controller.rb index 1ef509bdb..664117d24 100644 --- a/app/controllers/print_hosts_controller.rb +++ b/app/controllers/print_hosts_controller.rb @@ -57,6 +57,15 @@ def destroy end end + def print + @file = ModelFile.find_param(params[:file_id]) + authorize @file + # Start print + + # Done + redirect_back_or_to model_model_file_path(@file.model, @file), notice: t(".sent"), status: :see_other + end + private def print_host_params diff --git a/app/policies/model_file_policy.rb b/app/policies/model_file_policy.rb index 8d48a05df..2bb25743d 100644 --- a/app/policies/model_file_policy.rb +++ b/app/policies/model_file_policy.rb @@ -8,6 +8,10 @@ def raw? show? end + def print? + show? + end + def create? can_update_model? end diff --git a/app/policies/print_host_policy.rb b/app/policies/print_host_policy.rb index 7f08bce73..243639e9e 100644 --- a/app/policies/print_host_policy.rb +++ b/app/policies/print_host_policy.rb @@ -19,4 +19,8 @@ def update? def destroy? index? end + + def print? + index? + end end diff --git a/config/routes/print.rb b/config/routes/print.rb index ec328c293..f548ef916 100644 --- a/config/routes/print.rb +++ b/config/routes/print.rb @@ -1 +1,5 @@ -resources :print_hosts, except: [:show] +resources :print_hosts, except: [:show] do + member do + post :print + end +end diff --git a/spec/requests/print_hosts_spec.rb b/spec/requests/print_hosts_spec.rb index 69f5e61d9..a396052c2 100644 --- a/spec/requests/print_hosts_spec.rb +++ b/spec/requests/print_hosts_spec.rb @@ -2,7 +2,10 @@ RSpec.describe "PrintHosts", :after_first_run do context "when signed out" do - it "needs testing when multiuser is enabled" + it "sends logged-out users to login" do + get "/print_hosts" + expect(response).to redirect_to("/users/sign_in") + end end context "when signed in" do @@ -81,5 +84,22 @@ expect(response).to have_http_status(:forbidden) end end + + describe "POST /print_hosts/:id/print" do + let(:file) { create :model_file } + before { post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id} } + + context "when the user has access to the file", :as_administrator do + it "redirects back to file by default" do + expect(response).to redirect_to(model_model_file_path(file.model, file)) + end + + it "starts print job" + end + + it "is denied to non-administrators", :as_moderator do + expect(response).to have_http_status(:forbidden) + end + end end end From f5cc246726676a0300aca6df8018ea726ecbdb55 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 10:44:14 +0100 Subject: [PATCH 2/8] enqueue print job after post to print action --- app/controllers/print_hosts_controller.rb | 4 +--- app/models/print_host.rb | 4 ++++ spec/requests/print_hosts_spec.rb | 11 ++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/print_hosts_controller.rb b/app/controllers/print_hosts_controller.rb index 664117d24..5a44df83f 100644 --- a/app/controllers/print_hosts_controller.rb +++ b/app/controllers/print_hosts_controller.rb @@ -60,9 +60,7 @@ def destroy def print @file = ModelFile.find_param(params[:file_id]) authorize @file - # Start print - - # Done + @print_host.print_later(file: @file) redirect_back_or_to model_model_file_path(@file.model, @file), notice: t(".sent"), status: :see_other end diff --git a/app/models/print_host.rb b/app/models/print_host.rb index 9c70e4715..af33bc151 100644 --- a/app/models/print_host.rb +++ b/app/models/print_host.rb @@ -17,4 +17,8 @@ def service def input_types PROTOCOLS[protocol]::INPUT_TYPES end + + def print_later(file:) + SendFileToPrintHostJob.perform_later(print_host: self, file: file) + end end diff --git a/spec/requests/print_hosts_spec.rb b/spec/requests/print_hosts_spec.rb index a396052c2..c1b79faa1 100644 --- a/spec/requests/print_hosts_spec.rb +++ b/spec/requests/print_hosts_spec.rb @@ -86,18 +86,23 @@ end describe "POST /print_hosts/:id/print" do - let(:file) { create :model_file } - before { post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id} } + let(:file) { create(:model_file) } context "when the user has access to the file", :as_administrator do it "redirects back to file by default" do + post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id} expect(response).to redirect_to(model_model_file_path(file.model, file)) end - it "starts print job" + it "starts print job" do + expect { + post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id} + }.to have_enqueued_job(SendFileToPrintHostJob).with(print_host: print_host, file: file) + end end it "is denied to non-administrators", :as_moderator do + post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id} expect(response).to have_http_status(:forbidden) end end From 38319e0c27c97a6b6b2986a738490907d3dd5dca Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 12:22:46 +0100 Subject: [PATCH 3/8] Add translation string for success message --- config/locales/cs.yml | 2 ++ config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/es.yml | 2 ++ config/locales/fr.yml | 2 ++ config/locales/ja.yml | 2 ++ config/locales/nl.yml | 2 ++ config/locales/pl.yml | 2 ++ config/locales/pt.yml | 2 ++ config/locales/ru.yml | 2 ++ config/locales/zh-CN.yml | 2 ++ 11 files changed, 22 insertions(+) diff --git a/config/locales/cs.yml b/config/locales/cs.yml index f430e9586..70714bdf1 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -994,6 +994,8 @@ cs: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/de.yml b/config/locales/de.yml index aed522714..da5d21972 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -998,6 +998,8 @@ de: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/en.yml b/config/locales/en.yml index 519c5046d..f59e958ef 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -994,6 +994,8 @@ en: help: A friendly name for your printer protocol: help: The printer's API protocol + print: + sent: File sent to printer protocols: moonraker: Moonraker / Klipper update: diff --git a/config/locales/es.yml b/config/locales/es.yml index 1d5731168..f3c2afe99 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -994,6 +994,8 @@ es: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 05cf72b28..ec15d8b70 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -996,6 +996,8 @@ fr: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/ja.yml b/config/locales/ja.yml index d4b41660f..9c2a69953 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -994,6 +994,8 @@ ja: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index a77baf32d..8e75c965a 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -994,6 +994,8 @@ nl: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/pl.yml b/config/locales/pl.yml index e5dac41b2..e249023e7 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -994,6 +994,8 @@ pl: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 8370ab691..aac05b83f 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -994,6 +994,8 @@ pt: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 9edb361f7..cde3c9fa3 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -994,6 +994,8 @@ ru: help: protocol: help: + print: + sent: protocols: moonraker: update: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index dedf3c829..19fa6b3b4 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -994,6 +994,8 @@ zh-CN: help: protocol: help: + print: + sent: protocols: moonraker: update: From 6832371ab6a85505adfc84eaa8e779b1333ad786 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 12:23:37 +0100 Subject: [PATCH 4/8] Add print links to file dropdown menu --- app/helpers/model_files_helper.rb | 16 ++++++++++++++++ app/views/models/_file.html.erb | 2 ++ config/locales/model_files/cs.yml | 1 + config/locales/model_files/de.yml | 1 + config/locales/model_files/en.yml | 1 + config/locales/model_files/es.yml | 1 + config/locales/model_files/fr.yml | 1 + config/locales/model_files/ja.yml | 1 + config/locales/model_files/nl.yml | 1 + config/locales/model_files/pl.yml | 1 + config/locales/model_files/pt.yml | 1 + config/locales/model_files/ru.yml | 1 + config/locales/model_files/zh-CN.yml | 1 + 13 files changed, 29 insertions(+) diff --git a/app/helpers/model_files_helper.rb b/app/helpers/model_files_helper.rb index eb30d3240..398960681 100644 --- a/app/helpers/model_files_helper.rb +++ b/app/helpers/model_files_helper.rb @@ -1,4 +1,20 @@ module ModelFilesHelper + def print_links(file) + print_hosts = policy_scope(PrintHost).all.select { file.mime_type.in? it.input_types } + safe_join( + print_hosts.map do |print_host| + content_tag(:li, role: "presentation") { + link_to safe_join( + [ + Icon(icon: "printer", role: "presentation"), + t("model_files.print", print_host_name: print_host.name) + ], " " + ), print_print_host_path(print_host, file_id: file.public_id), method: "post", role: "menuitem", class: "dropdown-item" + } + end + ) + end + def app_links(file) handlers = FileHandlers.handlers_for(environment: :client, mime_type: file.mime_type) safe_join( diff --git a/app/views/models/_file.html.erb b/app/views/models/_file.html.erb index 2a1ce175b..7a220e5a0 100644 --- a/app/views/models/_file.html.erb +++ b/app/views/models/_file.html.erb @@ -37,6 +37,8 @@ <%= app_links(file.presupported_version) %> <%= DropdownDivider() %> <% end %> + <%= print_links(file) %> + <%= DropdownDivider() %> <%= DropdownItem icon: "pencil-fill", label: t(".edit"), path: edit_model_model_file_path(@model, file) if policy(file).edit? %> <%= DropdownItem icon: "image", label: t(".set_as_preview"), path: model_path(@model, "model[preview_file_id]": file.id), method: :patch if policy(@model).edit? && Components::Renderers::Three.supports?(file) || file.is_image? %> <%= DropdownItem icon: "trash", label: t(".delete"), path: model_model_file_path(@model, file), method: :delete, confirm: translate("model_files.destroy.confirm") if policy(file).destroy? %> diff --git a/config/locales/model_files/cs.yml b/config/locales/model_files/cs.yml index e78b2ceb9..721db2306 100644 --- a/config/locales/model_files/cs.yml +++ b/config/locales/model_files/cs.yml @@ -35,6 +35,7 @@ cs: help_html: Můžete použít Markdown. general: edit: Upravit informace o souboru + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/de.yml b/config/locales/model_files/de.yml index e3a3c7672..4beb87afb 100644 --- a/config/locales/model_files/de.yml +++ b/config/locales/model_files/de.yml @@ -35,6 +35,7 @@ de: help_html: 'Du kannst Markdown verwenden. ' general: edit: Dateiinformationen bearbeiten + print: relationship_fields: delete: Beziehung entfernen edit_related: Zugehörige Datei bearbeiten diff --git a/config/locales/model_files/en.yml b/config/locales/model_files/en.yml index 3dac33d47..a780cefc2 100644 --- a/config/locales/model_files/en.yml +++ b/config/locales/model_files/en.yml @@ -35,6 +35,7 @@ en: help_html: You can use Markdown. general: edit: Edit File Information + print: Print using %{print_host_name} relationship_fields: delete: Remove relationship edit_related: Edit related file diff --git a/config/locales/model_files/es.yml b/config/locales/model_files/es.yml index 0fc2bcbe7..8a63c6bdd 100644 --- a/config/locales/model_files/es.yml +++ b/config/locales/model_files/es.yml @@ -35,6 +35,7 @@ es: help_html: Puedes utilizar Markdown. general: edit: Editar la información del archivo + print: relationship_fields: delete: Eliminar relación edit_related: Editar archivo relacionado diff --git a/config/locales/model_files/fr.yml b/config/locales/model_files/fr.yml index f1051a075..5204636d8 100644 --- a/config/locales/model_files/fr.yml +++ b/config/locales/model_files/fr.yml @@ -35,6 +35,7 @@ fr: help_html: Vous pouvez utiliser du Markdown. general: edit: Modifier les informations du fichier + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/ja.yml b/config/locales/model_files/ja.yml index 1dd8cb9e7..846d555f8 100644 --- a/config/locales/model_files/ja.yml +++ b/config/locales/model_files/ja.yml @@ -35,6 +35,7 @@ ja: help_html: general: edit: + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/nl.yml b/config/locales/model_files/nl.yml index c253f762b..62bf670eb 100644 --- a/config/locales/model_files/nl.yml +++ b/config/locales/model_files/nl.yml @@ -35,6 +35,7 @@ nl: help_html: Je kunt Markdown gebruiken. general: edit: Bestandsinformatie Bewerken + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/pl.yml b/config/locales/model_files/pl.yml index b38074762..37fae5c75 100644 --- a/config/locales/model_files/pl.yml +++ b/config/locales/model_files/pl.yml @@ -35,6 +35,7 @@ pl: help_html: Możesz używać Markdown. general: edit: Edytuj informacje o pliku + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/pt.yml b/config/locales/model_files/pt.yml index d54c80b69..40de824cc 100644 --- a/config/locales/model_files/pt.yml +++ b/config/locales/model_files/pt.yml @@ -35,6 +35,7 @@ pt: help_html: general: edit: + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/ru.yml b/config/locales/model_files/ru.yml index 056db6a9b..25eb13726 100644 --- a/config/locales/model_files/ru.yml +++ b/config/locales/model_files/ru.yml @@ -35,6 +35,7 @@ ru: help_html: general: edit: + print: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/zh-CN.yml b/config/locales/model_files/zh-CN.yml index 76dcc6791..59d1720d2 100644 --- a/config/locales/model_files/zh-CN.yml +++ b/config/locales/model_files/zh-CN.yml @@ -35,6 +35,7 @@ zh-CN: help_html: 您可以使用Markdown。 general: edit: 编辑文件信息 + print: relationship_fields: delete: edit_related: From 9b14197a5feeb522a312d5a2f511bdbaf246c970 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 14:01:59 +0100 Subject: [PATCH 5/8] Add compatibility confirmation message before sending for print --- app/helpers/model_files_helper.rb | 11 +++++++++-- config/locales/model_files/cs.yml | 2 ++ config/locales/model_files/de.yml | 2 ++ config/locales/model_files/en.yml | 4 +++- config/locales/model_files/es.yml | 2 ++ config/locales/model_files/fr.yml | 2 ++ config/locales/model_files/ja.yml | 2 ++ config/locales/model_files/nl.yml | 2 ++ config/locales/model_files/pl.yml | 2 ++ config/locales/model_files/pt.yml | 2 ++ config/locales/model_files/ru.yml | 2 ++ config/locales/model_files/zh-CN.yml | 2 ++ 12 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/helpers/model_files_helper.rb b/app/helpers/model_files_helper.rb index 398960681..e5d9ee8d8 100644 --- a/app/helpers/model_files_helper.rb +++ b/app/helpers/model_files_helper.rb @@ -7,9 +7,16 @@ def print_links(file) link_to safe_join( [ Icon(icon: "printer", role: "presentation"), - t("model_files.print", print_host_name: print_host.name) + t("model_files.print.link", print_host_name: print_host.name) ], " " - ), print_print_host_path(print_host, file_id: file.public_id), method: "post", role: "menuitem", class: "dropdown-item" + ), + print_print_host_path(print_host, file_id: file.public_id), + method: "post", + role: "menuitem", + class: "dropdown-item", + data: { + confirm: translate("model_files.print.confirm") + } } end ) diff --git a/config/locales/model_files/cs.yml b/config/locales/model_files/cs.yml index 721db2306..4806fac99 100644 --- a/config/locales/model_files/cs.yml +++ b/config/locales/model_files/cs.yml @@ -36,6 +36,8 @@ cs: general: edit: Upravit informace o souboru print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/de.yml b/config/locales/model_files/de.yml index 4beb87afb..a011da03a 100644 --- a/config/locales/model_files/de.yml +++ b/config/locales/model_files/de.yml @@ -36,6 +36,8 @@ de: general: edit: Dateiinformationen bearbeiten print: + confirm: + link: relationship_fields: delete: Beziehung entfernen edit_related: Zugehörige Datei bearbeiten diff --git a/config/locales/model_files/en.yml b/config/locales/model_files/en.yml index a780cefc2..cf1950d14 100644 --- a/config/locales/model_files/en.yml +++ b/config/locales/model_files/en.yml @@ -35,7 +35,9 @@ en: help_html: You can use Markdown. general: edit: Edit File Information - print: Print using %{print_host_name} + print: + confirm: Are you sure this file is correctly set up for your printer? Manyfold doesn't check what you're sending! + link: Print using %{print_host_name} relationship_fields: delete: Remove relationship edit_related: Edit related file diff --git a/config/locales/model_files/es.yml b/config/locales/model_files/es.yml index 8a63c6bdd..a92f7379f 100644 --- a/config/locales/model_files/es.yml +++ b/config/locales/model_files/es.yml @@ -36,6 +36,8 @@ es: general: edit: Editar la información del archivo print: + confirm: + link: relationship_fields: delete: Eliminar relación edit_related: Editar archivo relacionado diff --git a/config/locales/model_files/fr.yml b/config/locales/model_files/fr.yml index 5204636d8..96d798de9 100644 --- a/config/locales/model_files/fr.yml +++ b/config/locales/model_files/fr.yml @@ -36,6 +36,8 @@ fr: general: edit: Modifier les informations du fichier print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/ja.yml b/config/locales/model_files/ja.yml index 846d555f8..958a52fae 100644 --- a/config/locales/model_files/ja.yml +++ b/config/locales/model_files/ja.yml @@ -36,6 +36,8 @@ ja: general: edit: print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/nl.yml b/config/locales/model_files/nl.yml index 62bf670eb..2661c9dcb 100644 --- a/config/locales/model_files/nl.yml +++ b/config/locales/model_files/nl.yml @@ -36,6 +36,8 @@ nl: general: edit: Bestandsinformatie Bewerken print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/pl.yml b/config/locales/model_files/pl.yml index 37fae5c75..659aca7af 100644 --- a/config/locales/model_files/pl.yml +++ b/config/locales/model_files/pl.yml @@ -36,6 +36,8 @@ pl: general: edit: Edytuj informacje o pliku print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/pt.yml b/config/locales/model_files/pt.yml index 40de824cc..4fd71a765 100644 --- a/config/locales/model_files/pt.yml +++ b/config/locales/model_files/pt.yml @@ -36,6 +36,8 @@ pt: general: edit: print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/ru.yml b/config/locales/model_files/ru.yml index 25eb13726..f510e6051 100644 --- a/config/locales/model_files/ru.yml +++ b/config/locales/model_files/ru.yml @@ -36,6 +36,8 @@ ru: general: edit: print: + confirm: + link: relationship_fields: delete: edit_related: diff --git a/config/locales/model_files/zh-CN.yml b/config/locales/model_files/zh-CN.yml index 59d1720d2..ce3197e86 100644 --- a/config/locales/model_files/zh-CN.yml +++ b/config/locales/model_files/zh-CN.yml @@ -36,6 +36,8 @@ zh-CN: general: edit: 编辑文件信息 print: + confirm: + link: relationship_fields: delete: edit_related: From 703fd4999820568ebd59226cb5bfaec3bc9d87ed Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 14:21:27 +0100 Subject: [PATCH 6/8] memoize print_hosts_for mime types --- app/helpers/model_files_helper.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/helpers/model_files_helper.rb b/app/helpers/model_files_helper.rb index e5d9ee8d8..9ef04d077 100644 --- a/app/helpers/model_files_helper.rb +++ b/app/helpers/model_files_helper.rb @@ -1,8 +1,18 @@ module ModelFilesHelper + prepend MemoWise + + def can_print?(file) + print_hosts_for(file.mime_type).any? + end + + def print_hosts_for(mime_type) + policy_scope(PrintHost).all.select { mime_type.in? it.input_types } + end + memo_wise :print_hosts_for + def print_links(file) - print_hosts = policy_scope(PrintHost).all.select { file.mime_type.in? it.input_types } safe_join( - print_hosts.map do |print_host| + print_hosts_for(file.mime_type).map do |print_host| content_tag(:li, role: "presentation") { link_to safe_join( [ From 0c88fbc334bc0869a7ab2254a6403759fa2f1851 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 14:25:09 +0100 Subject: [PATCH 7/8] hide extra separator in menu --- app/views/models/_file.html.erb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/models/_file.html.erb b/app/views/models/_file.html.erb index 7a220e5a0..ced6b8bd3 100644 --- a/app/views/models/_file.html.erb +++ b/app/views/models/_file.html.erb @@ -37,8 +37,10 @@ <%= app_links(file.presupported_version) %> <%= DropdownDivider() %> <% end %> - <%= print_links(file) %> - <%= DropdownDivider() %> + <% if can_print? file %> + <%= print_links(file) %> + <%= DropdownDivider() %> + <% end %> <%= DropdownItem icon: "pencil-fill", label: t(".edit"), path: edit_model_model_file_path(@model, file) if policy(file).edit? %> <%= DropdownItem icon: "image", label: t(".set_as_preview"), path: model_path(@model, "model[preview_file_id]": file.id), method: :patch if policy(@model).edit? && Components::Renderers::Three.supports?(file) || file.is_image? %> <%= DropdownItem icon: "trash", label: t(".delete"), path: model_model_file_path(@model, file), method: :delete, confirm: translate("model_files.destroy.confirm") if policy(file).destroy? %> From cbbfc5acc90643ed790e570b820f61b855b1ba9f Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 17 Jun 2026 14:29:41 +0100 Subject: [PATCH 8/8] Add print links to model file sidebar --- app/views/model_files/show.html.erb | 8 ++++++++ config/locales/model_files/cs.yml | 2 ++ config/locales/model_files/de.yml | 2 ++ config/locales/model_files/en.yml | 2 ++ config/locales/model_files/es.yml | 2 ++ config/locales/model_files/fr.yml | 2 ++ config/locales/model_files/ja.yml | 2 ++ config/locales/model_files/nl.yml | 2 ++ config/locales/model_files/pl.yml | 2 ++ config/locales/model_files/pt.yml | 2 ++ config/locales/model_files/ru.yml | 2 ++ config/locales/model_files/zh-CN.yml | 2 ++ 12 files changed, 30 insertions(+) diff --git a/app/views/model_files/show.html.erb b/app/views/model_files/show.html.erb index aaf0c4b8a..7d7076dfb 100644 --- a/app/views/model_files/show.html.erb +++ b/app/views/model_files/show.html.erb @@ -92,6 +92,14 @@ <% end %> <% end %> + <% if can_print? @file %> + <%= card("secondary", t(".print_card.heading")) do %> +
    + <%= print_links(@file) %> +
+ <% end %> + <% end %> + <%= render partial: "problems_card", locals: {problems: @file.problems.visible(problem_settings)} %> diff --git a/config/locales/model_files/cs.yml b/config/locales/model_files/cs.yml index 4806fac99..d2c606b6e 100644 --- a/config/locales/model_files/cs.yml +++ b/config/locales/model_files/cs.yml @@ -50,6 +50,8 @@ cs: download: menu_header: Možnosti stahování notes_heading: Poznámky + print_card: + heading: update: failure: Došlo k chybě a údaje o souboru nelze uložit. success: Detaily souboru uloženy. diff --git a/config/locales/model_files/de.yml b/config/locales/model_files/de.yml index a011da03a..f27ddf7b2 100644 --- a/config/locales/model_files/de.yml +++ b/config/locales/model_files/de.yml @@ -50,6 +50,8 @@ de: download: menu_header: Download optionen notes_heading: Notizen + print_card: + heading: update: failure: Es ist ein Fehler aufgetreten und die Dateidetails konnten nicht gespeichert werden. success: Dateieigenschaften gespeichert. diff --git a/config/locales/model_files/en.yml b/config/locales/model_files/en.yml index cf1950d14..c53ae5484 100644 --- a/config/locales/model_files/en.yml +++ b/config/locales/model_files/en.yml @@ -50,6 +50,8 @@ en: download: menu_header: Download options notes_heading: Notes + print_card: + heading: Print update: failure: An error occurred and file details could not be saved. success: File details saved. diff --git a/config/locales/model_files/es.yml b/config/locales/model_files/es.yml index a92f7379f..f5fdff6e4 100644 --- a/config/locales/model_files/es.yml +++ b/config/locales/model_files/es.yml @@ -50,6 +50,8 @@ es: download: menu_header: Opciones de Descarga notes_heading: Notas + print_card: + heading: update: failure: Se ha producido un error y no se ha podido guardar la información del fichero. success: Información del fichero guardada. diff --git a/config/locales/model_files/fr.yml b/config/locales/model_files/fr.yml index 96d798de9..2d1f85df4 100644 --- a/config/locales/model_files/fr.yml +++ b/config/locales/model_files/fr.yml @@ -50,6 +50,8 @@ fr: download: menu_header: Options de téléchargement notes_heading: Notes + print_card: + heading: update: failure: Une erreur s'est produite et les détails du fichier n'ont pas pu être sauvegardés. success: Détails du fichier sauvegardé. diff --git a/config/locales/model_files/ja.yml b/config/locales/model_files/ja.yml index 958a52fae..78165a949 100644 --- a/config/locales/model_files/ja.yml +++ b/config/locales/model_files/ja.yml @@ -50,6 +50,8 @@ ja: download: menu_header: notes_heading: + print_card: + heading: update: failure: success: diff --git a/config/locales/model_files/nl.yml b/config/locales/model_files/nl.yml index 2661c9dcb..65396b93c 100644 --- a/config/locales/model_files/nl.yml +++ b/config/locales/model_files/nl.yml @@ -50,6 +50,8 @@ nl: download: menu_header: notes_heading: Notities + print_card: + heading: update: failure: Er is een fout opgetreden en de bestandsdetails konden niet worden opgeslagen. success: Bestandsdetails opgeslagen. diff --git a/config/locales/model_files/pl.yml b/config/locales/model_files/pl.yml index 659aca7af..603884217 100644 --- a/config/locales/model_files/pl.yml +++ b/config/locales/model_files/pl.yml @@ -50,6 +50,8 @@ pl: download: menu_header: Opcje pobierania notes_heading: Notatki + print_card: + heading: update: failure: Wystąpił błąd i nie można było zapisać szczegółów pliku. success: Szczegóły pliku zostały zapisane. diff --git a/config/locales/model_files/pt.yml b/config/locales/model_files/pt.yml index 4fd71a765..b4f8f89f9 100644 --- a/config/locales/model_files/pt.yml +++ b/config/locales/model_files/pt.yml @@ -50,6 +50,8 @@ pt: download: menu_header: notes_heading: + print_card: + heading: update: failure: success: diff --git a/config/locales/model_files/ru.yml b/config/locales/model_files/ru.yml index f510e6051..a94a46c43 100644 --- a/config/locales/model_files/ru.yml +++ b/config/locales/model_files/ru.yml @@ -50,6 +50,8 @@ ru: download: menu_header: notes_heading: + print_card: + heading: update: failure: success: diff --git a/config/locales/model_files/zh-CN.yml b/config/locales/model_files/zh-CN.yml index ce3197e86..743c405fc 100644 --- a/config/locales/model_files/zh-CN.yml +++ b/config/locales/model_files/zh-CN.yml @@ -50,6 +50,8 @@ zh-CN: download: menu_header: 下载选项 notes_heading: 说明 + print_card: + heading: update: failure: 发生错误,无法保存文件详细信息。 success: 保存成功。