12125: Update trash tests
[arvados.git] / apps / workbench / app / views / application / 404.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <%
6    if (controller.andand.action_name == 'show') and params[:uuid]
7      check_trash = controller.model_class.include_trash(true).where(uuid: params[:uuid])
8      class_name = controller.model_class.to_s.underscore
9      class_name_h = class_name.humanize(capitalize: false)
10      req_item = safe_join([class_name_h, " with UUID ",
11                              raw("<code>"), params[:uuid], raw("</code>")], "")
12      req_item_plain_text = safe_join([class_name_h, " with UUID ", params[:uuid]])
13    else
14      req_item = "page you requested"
15      req_item_plain_text = "page you requested"
16    end
17 %>
18
19   <% if check_trash.andand.any? %>
20     <h2>Trashed</h2>
21
22       <% object = check_trash.first %>
23
24       <% untrash_object = object %>
25       <% while !untrash_object.is_trashed %>
26         <% owner = Group.where(uuid: untrash_object.owner_uuid).include_trash(true).first %>
27         <% if owner.nil? then %>
28           <% break %>
29         <% else %>
30           <% untrash_object = owner %>
31         <% end %>
32       <% end %>
33
34       <% untrash_name = if !untrash_object.name.blank? then
35                  "'#{untrash_object.name}'"
36                  else
37                  untrash_object.uuid
38                end %>
39
40     <p>The <%= req_item %> is
41       <% if untrash_object == object %>
42         in the trash.
43       <% else %>
44         owned by trashed project <%= untrash_name %> (<code><%= untrash_object.uuid %></code>).
45       <% end %>
46     </p>
47
48     <p>
49       It will be permanently deleted at <%= render_localized_date(untrash_object.delete_at) %>.
50     </p>
51
52   <p>
53     <% if untrash_object != object %>
54       You must untrash the owner project to access this <%= class_name_h %>.
55     <% end %>
56       <% if untrash_object.editable? %>
57         <% msg = "Untrash '#{untrash_name}'?" %>
58         <%= link_to({action: 'untrash_items', selection: [untrash_object.uuid], controller: :trash_items}, remote: true, method: :post,
59         title: "Untrash", style: 'cursor: pointer;') do %>
60
61         <% end %>
62
63         <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %>
64         <%= hidden_field_tag :selection, [untrash_object.uuid] %>
65         <button type="submit">Click here to untrash <%= untrash_name %> <i class="fa fa-fw fa-recycle"></i></button>
66       <% end %>
67     </p>
68
69   <% else %>
70
71 <h2>Not Found</h2>
72
73 <p>The <%= req_item %> was not found.</p>
74
75 <% if !current_user %>
76
77   <p>
78     <%= link_to(arvados_api_client.arvados_login_url(return_to: strip_token_from_path(request.url)),
79                 {class: "btn btn-primary report-issue-modal-window"}) do %>
80       <i class="fa fa-fw fa-sign-in"></i> Log in
81     <% end %>
82     to view private data.
83   </p>
84
85 <% elsif class_name %>
86
87   <p>
88     Perhaps you'd like to <%= link_to("browse all
89     #{class_name_h.pluralize}", action: :index, controller:
90     class_name.tableize) %>?
91   </p>
92
93 <% end %>
94
95 <% end %>
96
97 <% error_message = "The #{req_item_plain_text} was not found." %>
98 <%= render :partial => "report_error", :locals => {error_message: error_message, error_type: '404'} %>