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>
<% if check_trash.andand.any? %>
<h2>Trashed</h2>
<% if check_trash.andand.any? %>
<h2>Trashed</h2>
- <p>The <%= req_item %> is in the trash.
-
<% object = check_trash.first %>
<% 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>
- <%= 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 %>
+
+
+ <%= 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>
<td colspan="2" class="trash-project-msg">
<%= link_to_if_arvados_object @owners[obj.owner_uuid], friendly_name: true %>
<br>
<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.
- <% if obj.is_trashed %>
- <%= render partial: 'untrash_item', locals: {object:obj} %>
- <% end %>
+ <%= render partial: 'untrash_item', locals: {object:obj} %>
SPDX-License-Identifier: AGPL-3.0 %>
<% if object.editable? %>
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 %>