12125: Workbench 404 page checks if item is in the trash.
[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], is_trashed: true)
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.any? %>
20     <h2>Trashed</h2>
21
22     <p>The <%= req_item %> is in the trash.
23
24     <% object = check_trash.first %>
25     <% if object.editable? %>
26       <% msg = "Untrash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %>
27       <%= link_to({action: 'untrash_items', selection: [object.uuid], controller: :trash_items}, remote: true, method: :post,
28         title: "Untrash", style: 'cursor: pointer;') do %>
29
30       <% end %>
31
32       <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %>
33       <%= hidden_field_tag :selection, [object.uuid] %>
34       <button type="submit">Click here to untrash this item <i class="fa fa-fw fa-recycle"></i></button>
35     <% end %>
36     </p>
37
38   <% else %>
39
40 <h2>Not Found</h2>
41
42 <p>The <%= req_item %> was not found.</p>
43
44 <% if !current_user %>
45
46   <p>
47     <%= link_to(arvados_api_client.arvados_login_url(return_to: strip_token_from_path(request.url)),
48                 {class: "btn btn-primary report-issue-modal-window"}) do %>
49       <i class="fa fa-fw fa-sign-in"></i> Log in
50     <% end %>
51     to view private data.
52   </p>
53
54 <% elsif class_name %>
55
56   <p>
57     Perhaps you'd like to <%= link_to("browse all
58     #{class_name_h.pluralize}", action: :index, controller:
59     class_name.tableize) %>?
60   </p>
61
62 <% end %>
63
64 <% end %>
65
66 <% error_message = "The #{req_item_plain_text} was not found." %>
67 <%= render :partial => "report_error", :locals => {error_message: error_message, error_type: '404'} %>