From 342d29f272f6ea1d7f739b86da1148aed53dd0c5 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Mon, 27 Nov 2023 18:42:34 +0200 Subject: [PATCH] allow to permanently delete template in the cloud --- app/controllers/templates_controller.rb | 4 +++- app/views/templates/_template.html.erb | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 971a6ba2..e8861725 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -58,9 +58,11 @@ class TemplatesController < ApplicationController def destroy notice = - if !Docuseal.multitenant? && params[:permanently].present? + if params[:permanently].present? @template.destroy! + Rollbar.info("Remove template: #{@template.id}") if defined?(Rollbar) + 'Template has been removed.' else @template.update!(deleted_at: Time.current) diff --git a/app/views/templates/_template.html.erb b/app/views/templates/_template.html.erb index 5982a1d8..bad6bc5f 100644 --- a/app/views/templates/_template.html.erb +++ b/app/views/templates/_template.html.erb @@ -52,9 +52,9 @@ <% end %> - <% if (!template.deleted_at? || !Docuseal.multitenant?) && can?(:destroy, template) %> - - <%= button_to template_path(template), data: { turbo_confirm: 'Are you sure?' }, params: { permanently: template.deleted_at? }.compact_blank, method: :delete, class: 'btn btn-xs hover:btn-outline bg-base-200 btn-circle', aria_label: 'Restore' do %> + <% if can?(:destroy, template) %> + + <%= button_to template_path(template), data: { turbo_confirm: template.deleted_at? ? 'Template deletion is irreversible and will permanently remove all associated signed documents with it. Are you sure?' : 'Are you sure?' }, params: { permanently: template.deleted_at? }.compact_blank, method: :delete, class: 'btn btn-xs hover:btn-outline bg-base-200 btn-circle', aria_label: 'Restore' do %> <%= svg_icon('trash', class: 'w-4 h-4 enabled') %> <%= svg_icon('loader', class: 'w-4 h-4 animate-spin disabled') %> <% end %>