Fix 2.4.2 upgrade notes formatting refs #19330
[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   <% untrash_object = nil %>
20
21   <% if check_trash.andand.any? %>
22     <% object = check_trash.first %>
23     <% if object.respond_to?(:is_trashed) && object.is_trashed %>
24       <% untrash_object = object %>
25     <% else %>
26       <% owner = object %>
27       <% while true %>
28         <% owner = Group.where(uuid: owner.owner_uuid).include_trash(true).first %>
29         <% if owner.nil? %>
30           <% break %>
31         <% end %>
32         <% if owner.is_trashed %>
33           <% untrash_object = owner %>
34           <% break %>
35         <% end %>
36       <% end %>
37     <% end %>
38   <% end %>
39
40   <% if !untrash_object.nil? %>
41     <h2>Trashed</h2>
42
43       <% untrash_name = if !untrash_object.name.blank? then
44                  "'#{untrash_object.name}'"
45                  else
46                  untrash_object.uuid
47                end %>
48
49     <p>The <%= req_item %> is
50       <% if untrash_object == object %>
51         in the trash.
52       <% else %>
53         owned by trashed project <%= untrash_name %> (<code><%= untrash_object.uuid %></code>).
54       <% end %>
55     </p>
56
57     <p>
58       It will be permanently deleted at <%= render_localized_date(untrash_object.delete_at) %>.
59     </p>
60
61   <p>
62     <% if untrash_object != object %>
63       You must untrash the owner project to access this <%= class_name_h %>.
64     <% end %>
65       <% if untrash_object.is_trashed and untrash_object.editable? %>
66         <% msg = "Untrash '#{untrash_name}'?" %>
67         <%= link_to({action: 'untrash_items', selection: [untrash_object.uuid], controller: :trash_items}, remote: true, method: :post,
68         title: "Untrash", style: 'cursor: pointer;') do %>
69
70         <% end %>
71
72         <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %>
73         <%= hidden_field_tag :selection, [untrash_object.uuid] %>
74         <button type="submit">Click here to untrash <%= untrash_name %> <i class="fa fa-fw fa-recycle"></i></button>
75       <% end %>
76     </p>
77
78   <% else %>
79
80 <h2>Not Found</h2>
81
82 <p>The <%= req_item %> was not found.</p>
83
84 <% if !current_user %>
85
86   <p>
87     <%= link_to(arvados_api_client.arvados_login_url(return_to: strip_token_from_path(request.url)),
88                 {class: "btn btn-primary report-issue-modal-window"}) do %>
89       <i class="fa fa-fw fa-sign-in"></i> Log in
90     <% end %>
91     to view private data.
92   </p>
93
94 <% elsif class_name %>
95
96   <p>
97     Perhaps you'd like to <%= link_to("browse all
98     #{class_name_h.pluralize}", action: :index, controller:
99     class_name.tableize) %>?
100   </p>
101
102 <% end %>
103
104 <% end %>
105
106 <% error_message = "The #{req_item_plain_text} was not found." %>
107 <%= render :partial => "report_error", :locals => {error_message: error_message, error_type: '404'} %>