From 14c14df4dddf272575ab01054f615f32f3fcc5ec Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sat, 7 Sep 2019 19:33:32 -0500 Subject: [PATCH] recycle bin improvements --- app/controllers/content_controller.rb | 6 ++-- app/views/content/deleted.html.erb | 43 ++++++++++++++++++++------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 8fb40a4e..cc4dc7c9 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -334,11 +334,13 @@ class ContentController < ApplicationController # List all recently-deleted content def deleted + @maximum_recovery_time = current_user.on_premium_plan? ? 7.days : 48.hours + @content_pages = {} @activated_content_types.each do |content_type| - @content_pages[content_type] = content_type.constantize.with_deleted.where('deleted_at > ?', 24.hours.ago).where(user_id: current_user.id) + @content_pages[content_type] = content_type.constantize.with_deleted.where('deleted_at > ?', @maximum_recovery_time.ago).where(user_id: current_user.id) end - @content_pages["Document"] = current_user.documents.with_deleted.where('deleted_at > ?', 24.hours.ago) + @content_pages["Document"] = current_user.documents.with_deleted.where('deleted_at > ?', @maximum_recovery_time.ago) # Override controller @sidenav_expansion = 'my account' diff --git a/app/views/content/deleted.html.erb b/app/views/content/deleted.html.erb index fcd7bd29..f45aa5d5 100644 --- a/app/views/content/deleted.html.erb +++ b/app/views/content/deleted.html.erb @@ -1,17 +1,40 @@
-
-
+
-

- Pages can be "un-deleted" for up to 24 hours after deletion. - After this time, they are permanently deleted and cannot be recovered. - Use this page if you've accidentally deleted a page and need to recover it. -

+
+
+
Your notebook's recycle bin
+

+ Hello there! +

+
+

+ Whenever you delete a page from your notebook, it ends up here for a little while. + While a page is here, you can recover it at any time to add it back to your notebook. + If not recovered, the page will be automatically and permanently deleted. +

+
+

+ In other words, use this page if you've accidentally deleted a page and need to recover it. +

+
+
+ <%= image_tag 'tristan/small.png', + class: 'tooltipped tristan', + data: { + position: 'left', + enterDelay: '500', + tooltip: "Hey, I'm Tristan! I'm happy to help you around Notebook.ai." + } %> +
+
+
+
<% showed_any_content = false %> @@ -78,13 +101,13 @@ <% end %>

- " style="font-size: 80%"> + " style="font-size: 80%"> delete deleted <%= time_ago_in_words content.deleted_at %> ago - " style="font-size: 80%"> + " style="font-size: 80%"> alarm - recoverable for the next <%= distance_of_time_in_words(DateTime.current, content.deleted_at + 24.hours) %> + recoverable for the next <%= distance_of_time_in_words(DateTime.current, content.deleted_at + @maximum_recovery_time) %>