From 6afdf38337e3278234d03480b64e50beaddcd105 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 19 Oct 2017 18:01:33 -0400 Subject: [PATCH] 12125: 404 page searches owners to find actual trashed object. Change untrash behavior so that untrash button always directs to 404 page for untrash confirmation. Provides better consistency of UX and ensures that multiple levels of trash (such as a trashed collection within a trashed project) are handled. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../app/views/application/404.html.erb | 55 +++++++++++++------ .../trash_items/_show_trash_rows.html.erb | 6 +- .../views/trash_items/_untrash_item.html.erb | 8 +-- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/apps/workbench/app/views/application/404.html.erb b/apps/workbench/app/views/application/404.html.erb index 2d9b5cf2c6..9750b9178b 100644 --- a/apps/workbench/app/views/application/404.html.erb +++ b/apps/workbench/app/views/application/404.html.erb @@ -19,28 +19,51 @@ SPDX-License-Identifier: AGPL-3.0 %> <% if check_trash.andand.any? %>

Trashed

-

The <%= req_item %> is in the trash. - <% object = check_trash.first %> - <% if object.is_trashed - untrash_object = object - else - end %> + <% untrash_object = object %> + <% while !untrash_object.is_trashed %> + <% owner = Group.where(uuid: untrash_object.owner_uuid).include_trash(true).first %> + <% if owner.nil? then %> + <% break %> + <% else %> + <% untrash_object = owner %> + <% end %> + <% end %> - <% if untrash_object.editable? %> - <% msg = "Untrash '" + if !untrash_object.name.blank? then untrash_object.name else untrash_object.uuid end + "'?" %> - <%= link_to({action: 'untrash_items', selection: [untrash_object.uuid], controller: :trash_items}, remote: true, method: :post, - title: "Untrash", style: 'cursor: pointer;') do %> + <% untrash_name = if !untrash_object.name.blank? then + "'#{untrash_object.name}'" + else + untrash_object.uuid + end %> + +

The <%= req_item %> is + <% if untrash_object == object %> + in the trash. + <% else %> + owned by trashed project <%= untrash_name %> (<%= untrash_object.uuid %>). + <% end %> +

- <% end %> - <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %> - <%= hidden_field_tag :selection, [untrash_object.uuid] %> - +

+ It will be permanently deleted at <%= render_localized_date(untrash_object.delete_at) %>. +

+ +

+ <% if untrash_object != object %> + You must untrash the owner project to access this <%= class_name_h %>. + <% end %> + <% if untrash_object.editable? %> + <% msg = "Untrash '#{untrash_name}'?" %> + <%= link_to({action: 'untrash_items', selection: [untrash_object.uuid], controller: :trash_items}, remote: true, method: :post, + title: "Untrash", style: 'cursor: pointer;') do %> + <% end %> - <% else %> - <% %> + + <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %> + <%= hidden_field_tag :selection, [untrash_object.uuid] %> + <% end %>

diff --git a/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb index ee61e45594..7d7bf7b824 100644 --- a/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb +++ b/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb @@ -30,7 +30,7 @@ SPDX-License-Identifier: AGPL-3.0 %> <%= link_to_if_arvados_object @owners[obj.owner_uuid], friendly_name: true %>
- This item is contained within a trashed project. You must untrash the parent project to recover it. + This item is contained within a trashed project. <% end %> @@ -40,9 +40,7 @@ SPDX-License-Identifier: AGPL-3.0 %> <% end %> - <% if obj.is_trashed %> - <%= render partial: 'untrash_item', locals: {object:obj} %> - <% end %> + <%= render partial: 'untrash_item', locals: {object:obj} %> diff --git a/apps/workbench/app/views/trash_items/_untrash_item.html.erb b/apps/workbench/app/views/trash_items/_untrash_item.html.erb index 901d396fcb..50780d9497 100644 --- a/apps/workbench/app/views/trash_items/_untrash_item.html.erb +++ b/apps/workbench/app/views/trash_items/_untrash_item.html.erb @@ -3,9 +3,7 @@ SPDX-License-Identifier: AGPL-3.0 %> <% if object.editable? %> - <% msg = "Untrash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %> - <%= link_to({action: 'untrash_items', selection: [object.uuid]}, remote: true, method: :post, - title: "Untrash", style: 'cursor: pointer;') do %> - - <% end %> + <%= link_to(url_for(object), {title: "Untrash", style: 'cursor: pointer;'}) do %> + + <% end %> <% end %> -- 2.30.2