12125: 404 page searches owners to find actual trashed object.
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Thu, 19 Oct 2017 22:01:33 +0000 (18:01 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 20 Oct 2017 14:12:32 +0000 (10:12 -0400)
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 <pamstutz@veritasgenetics.com>

apps/workbench/app/views/application/404.html.erb
apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
apps/workbench/app/views/trash_items/_untrash_item.html.erb

index 2d9b5cf2c62ef4481a4902041db40155ea0375bb..9750b9178b3740561459b0168383ceb065757abd 100644 (file)
@@ -19,28 +19,51 @@ SPDX-License-Identifier: AGPL-3.0 %>
   <% if check_trash.andand.any? %>
     <h2>Trashed</h2>
 
-    <p>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 %>
+
+    <p>The <%= req_item %> is
+      <% if untrash_object == object %>
+        in the trash.
+      <% else %>
+        owned by trashed project <%= untrash_name %> (<code><%= untrash_object.uuid %></code>).
+      <% end %>
+    </p>
 
-          <% end %>
 
-          <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %>
-          <%= hidden_field_tag :selection, [untrash_object.uuid] %>
-          <button type="submit">Click here to untrash this item <i class="fa fa-fw fa-recycle"></i></button>
+    <p>
+      It will be permanently deleted at <%= render_localized_date(untrash_object.delete_at) %>.
+    </p>
+
+  <p>
+    <% 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] %>
+        <button type="submit">Click here to untrash <%= untrash_name %> <i class="fa fa-fw fa-recycle"></i></button>
       <% end %>
     </p>
 
index ee61e45594428e26acd97efa3663e055f3d4e9a0..7d7bf7b82404eea975fe04a289195f11d3364a17 100644 (file)
@@ -30,7 +30,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
       <td colspan="2" class="trash-project-msg">
         <%= link_to_if_arvados_object @owners[obj.owner_uuid], friendly_name: true %>
         <br>
-        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.
       </td>
     <% end %>
     <td>
@@ -40,9 +40,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
       <% end %>
     </td>
     <td>
-      <% if obj.is_trashed %>
-        <%= render partial: 'untrash_item', locals: {object:obj} %>
-      <% end %>
+      <%= render partial: 'untrash_item', locals: {object:obj} %>
     </td>
   </tr>
 
index 901d396fcb81c14a41bce739dc4c88d90f22cd2a..50780d94973f023b0693301a47e6b365231194f3 100644 (file)
@@ -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 %>
-    <i class="fa fa-fw fa-recycle"></i>
-  <% end %>
+    <%= link_to(url_for(object), {title: "Untrash", style: 'cursor: pointer;'}) do %>
+      <i class="fa fa-fw fa-recycle"></i>
+    <% end %>
 <% end %>