[ARVADOS] created: d1814ec4769671c03b0ff597420d36e7e2772855
Git user
git at public.curoverse.com
Thu Sep 14 22:13:06 EDT 2017
at d1814ec4769671c03b0ff597420d36e7e2772855 (commit)
commit d1814ec4769671c03b0ff597420d36e7e2772855
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Sep 14 22:11:22 2017 -0400
12125: Workbench 404 page checks if item is in the trash.
Provides a convenient button to untrash it.
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb
index 27cbb32..4aac884 100644
--- a/apps/workbench/app/controllers/trash_items_controller.rb
+++ b/apps/workbench/app/controllers/trash_items_controller.rb
@@ -86,15 +86,24 @@ class TrashItemsController < ApplicationController
updates = {trash_at: nil}
- klass = resource_class_for_uuid(params[:selection][0])
+ if params[:selection].is_a? Array
+ klass = resource_class_for_uuid(params[:selection][0])
+ else
+ klass = resource_class_for_uuid(params[:selection])
+ end
+ first = nil
klass.include_trash(1).where(uuid: params[:selection]).each do |c|
+ first = c
c.untrash
@untrashed_uuids << c.uuid
end
respond_to do |format|
format.js
+ format.html do
+ redirect_to first
+ end
end
end
end
diff --git a/apps/workbench/app/views/application/404.html.erb b/apps/workbench/app/views/application/404.html.erb
index e02d0b3..31462ef 100644
--- a/apps/workbench/app/views/application/404.html.erb
+++ b/apps/workbench/app/views/application/404.html.erb
@@ -4,10 +4,11 @@ SPDX-License-Identifier: AGPL-3.0 %>
<%
if (controller.andand.action_name == 'show') and params[:uuid]
+ check_trash = controller.model_class.include_trash(true).where(uuid: params[:uuid], is_trashed: true)
class_name = controller.model_class.to_s.underscore
class_name_h = class_name.humanize(capitalize: false)
req_item = safe_join([class_name_h, " with UUID ",
- raw("<code>"), params[:uuid], raw("</code>")], "")
+ raw("<code>"), params[:uuid], raw("</code>")], "")
req_item_plain_text = safe_join([class_name_h, " with UUID ", params[:uuid]])
else
req_item = "page you requested"
@@ -15,6 +16,27 @@ SPDX-License-Identifier: AGPL-3.0 %>
end
%>
+ <% if check_trash.any? %>
+ <h2>Trashed</h2>
+
+ <p>The <%= req_item %> is in the trash.
+
+ <% object = check_trash.first %>
+ <% if object.editable? %>
+ <% msg = "Untrash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %>
+ <%= link_to({action: 'untrash_items', selection: [object.uuid], controller: :trash_items}, remote: true, method: :post,
+ title: "Untrash", style: 'cursor: pointer;') do %>
+
+ <% end %>
+
+ <%= form_tag url_for({action: 'untrash_items', controller: :trash_items}), {method: :post} %>
+ <%= hidden_field_tag :selection, [object.uuid] %>
+ <button type="submit">Click here to untrash this item <i class="fa fa-fw fa-recycle"></i></button>
+ <% end %>
+ </p>
+
+ <% else %>
+
<h2>Not Found</h2>
<p>The <%= req_item %> was not found.</p>
@@ -39,5 +61,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
<% end %>
+<% end %>
+
<% error_message = "The #{req_item_plain_text} was not found." %>
<%= render :partial => "report_error", :locals => {error_message: error_message, error_type: '404'} %>
commit 4b76af1acf39a64ebdca4abd32782b5f1921b5d5
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Sep 14 21:35:40 2017 -0400
12125: Can browse trashed projects & untrash them.
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb
index c010123..a2ed89b 100644
--- a/apps/workbench/app/controllers/projects_controller.rb
+++ b/apps/workbench/app/controllers/projects_controller.rb
@@ -134,50 +134,8 @@ class ProjectsController < ApplicationController
@removed_uuids = []
links = []
params[:item_uuids].collect { |uuid| ArvadosBase.find uuid }.each do |item|
- if (item.class == Link and
- item.link_class == 'name' and
- item.tail_uuid == @object.uuid)
- # Given uuid is a name link, linking an object to this
- # project. First follow the link to find the item we're removing,
- # then delete the link.
- links << item
- item = ArvadosBase.find item.head_uuid
- else
- # Given uuid is an object. Delete all names.
- links += Link.where(tail_uuid: @object.uuid,
- head_uuid: item.uuid,
- link_class: 'name')
- end
- links.each do |link|
- @removed_uuids << link.uuid
- link.destroy
- end
-
- if item.class == Collection
- # Use delete API on collections
- item.destroy
- @removed_uuids << item.uuid
- elsif item.owner_uuid == @object.uuid
- # Object is owned by this project. Remove it from the project by
- # changing owner to the current user.
- begin
- item.update_attributes owner_uuid: current_user.uuid
- @removed_uuids << item.uuid
- rescue ArvadosApiClient::ApiErrorResponseException => e
- if e.message.include? '_owner_uuid_'
- rename_to = item.name + ' removed from ' +
- (@object.name ? @object.name : @object.uuid) +
- ' at ' + Time.now.to_s
- updates = {}
- updates[:name] = rename_to
- updates[:owner_uuid] = current_user.uuid
- item.update_attributes updates
- @removed_uuids << item.uuid
- else
- raise
- end
- end
- end
+ item.destroy
+ @removed_uuids << item.uuid
end
end
@@ -337,7 +295,7 @@ class ProjectsController < ApplicationController
def public # Yes 'public' is the name of the action for public projects
return render_not_found if not Rails.configuration.anonymous_user_token or not Rails.configuration.enable_public_projects_page
@objects = using_specific_api_token Rails.configuration.anonymous_user_token do
- Group.where(group_class: 'project').order("updated_at DESC")
+ Group.where(group_class: 'project').order("modified_at DESC")
end
end
end
diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb
index b957798..27cbb32 100644
--- a/apps/workbench/app/controllers/trash_items_controller.rb
+++ b/apps/workbench/app/controllers/trash_items_controller.rb
@@ -22,7 +22,7 @@ class TrashItemsController < ApplicationController
if @objects.any?
@objects = @objects.sort_by { |obj| obj.trash_at }.reverse
@next_page_filters = next_page_filters('<=')
- @next_page_href = url_for(partial: :trash_rows,
+ @next_page_href = url_for(partial: params[:partial],
filters: @next_page_filters.to_json)
else
@next_page_href = nil
@@ -55,13 +55,19 @@ class TrashItemsController < ApplicationController
end
def trashed_items
+ if params[:partial] == "trashed_collection_rows"
+ query_on = Collection
+ elsif params[:partial] == "trashed_project_rows"
+ query_on = Group
+ end
+
# API server index doesn't return manifest_text by default, but our
# callers want it unless otherwise specified.
- @select ||= Collection.columns.map(&:name)
+ @select ||= query_on.columns.map(&:name) - %w(id updated_at)
limit = if params[:limit] then params[:limit].to_i else 100 end
offset = if params[:offset] then params[:offset].to_i else 0 end
- base_search = Collection.select(@select).include_trash(true).where(is_trashed: true)
+ base_search = query_on.select(@select).include_trash(true).where(is_trashed: true)
base_search = base_search.filter(params[:filters]) if params[:filters]
if params[:search].andand.length.andand > 0
@@ -80,7 +86,9 @@ class TrashItemsController < ApplicationController
updates = {trash_at: nil}
- Collection.include_trash(1).where(uuid: params[:selection]).each do |c|
+ klass = resource_class_for_uuid(params[:selection][0])
+
+ klass.include_trash(1).where(uuid: params[:selection]).each do |c|
c.untrash
@untrashed_uuids << c.uuid
end
diff --git a/apps/workbench/app/models/group.rb b/apps/workbench/app/models/group.rb
index 523e5e9..08b13bf 100644
--- a/apps/workbench/app/models/group.rb
+++ b/apps/workbench/app/models/group.rb
@@ -40,4 +40,8 @@ class Group < ArvadosBase
def self.creatable?
false
end
+
+ def untrash
+ arvados_api_client.api(self.class, "/#{self.uuid}/untrash", {"ensure_unique_name" => true})
+ end
end
diff --git a/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
deleted file mode 100644
index 6fc1676..0000000
--- a/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
+++ /dev/null
@@ -1,36 +0,0 @@
-<%# Copyright (C) The Arvados Authors. All rights reserved.
-
-SPDX-License-Identifier: AGPL-3.0 %>
-
-<% @objects.each do |obj| %>
- <tr data-object-uuid="<%= obj.uuid %>" data-kind="<%= obj.kind %>" >
- <td>
- <% if obj.editable? %>
- <%= check_box_tag 'uuids[]', obj.uuid, false, :class => 'persistent-selection', style: 'cursor: pointer;' %>
- <% end %>
- </td>
- <td>
- <%= if !obj.name.blank? then obj.name else obj.uuid end %>
- <td>
- <%= render_localized_date(obj.trash_at) if obj.trash_at %>
- <td>
- <%= render_localized_date(obj.delete_at) if obj.delete_at %>
- </td>
- <td>
- <%= link_to_if_arvados_object obj.owner_uuid, friendly_name: true %>
- </td>
- <td>
- <% for i in (0..[2, obj.files.length-1].min) %>
- <% file = obj.files[i] %>
- <% file_path = "#{file[0]}/#{file[1]}" %>
- <%= file_path %><br />
- <% end %>
- <% if obj.files.length > 3 %>
- <%= "(#{obj.files.length-3} more files)" %>
- <% end %>
- </td>
- <td>
- <%= render partial: 'untrash_item', locals: {object:obj} %>
- </td>
- </tr>
-<% end %>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb
index a78b02f..3778845 100644
--- a/apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb
+++ b/apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb
@@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
<div class="col-md-4 pull-right">
<input type="text" class="form-control filterable-control recent-trash-items"
placeholder="Search trash"
- data-filterable-target="#recent-trash-items"
+ data-filterable-target="#recent-collection-trash-items"
value="<%= params[:search] %>" />
</div>
@@ -50,8 +50,8 @@ SPDX-License-Identifier: AGPL-3.0 %>
</tr>
</thead>
- <tbody data-infinite-scroller="#recent-trash-items" id="recent-trash-items"
- data-infinite-content-href="<%= url_for partial: :trash_rows %>" >
+ <tbody data-infinite-scroller="#recent-collection-trash-items" id="recent-collection-trash-items"
+ data-infinite-content-href="<%= url_for partial: :trashed_collection_rows %>" >
</tbody>
</table>
</div>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb
index a78b02f..ef782d6 100644
--- a/apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb
+++ b/apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb
@@ -22,7 +22,7 @@ SPDX-License-Identifier: AGPL-3.0 %>
<div class="col-md-4 pull-right">
<input type="text" class="form-control filterable-control recent-trash-items"
placeholder="Search trash"
- data-filterable-target="#recent-trash-items"
+ data-filterable-target="#recent-project-trash-items"
value="<%= params[:search] %>" />
</div>
@@ -45,13 +45,13 @@ SPDX-License-Identifier: AGPL-3.0 %>
<th>Trashed at</th>
<th title="After this time, no longer available to be recovered from Trash">Permanently<br/>Deleted At</th>
<th>Owner</th>
- <th>Contents</th>
+ <th></th>
<th></th>
</tr>
</thead>
- <tbody data-infinite-scroller="#recent-trash-items" id="recent-trash-items"
- data-infinite-content-href="<%= url_for partial: :trash_rows %>" >
+ <tbody data-infinite-scroller="#recent-project-trash-items" id="recent-project-trash-items"
+ data-infinite-content-href="<%= url_for partial: :trashed_project_rows %>" >
</tbody>
</table>
</div>
commit bf04f0609ea7da1886f550854669eb8fa67d04bc
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Sep 14 20:36:24 2017 -0400
12125: Initial work, separate collection and project trash tabs.
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>
diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb
index 3604e78..b957798 100644
--- a/apps/workbench/app/controllers/trash_items_controller.rb
+++ b/apps/workbench/app/controllers/trash_items_controller.rb
@@ -8,7 +8,7 @@ class TrashItemsController < ApplicationController
end
def index_pane_list
- %w(Recent_trash)
+ %w(Trashed_collections Trashed_projects)
end
def find_objects_for_index
diff --git a/apps/workbench/app/views/trash_items/_show_recent_trash.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb
similarity index 100%
copy from apps/workbench/app/views/trash_items/_show_recent_trash.html.erb
copy to apps/workbench/app/views/trash_items/_show_trashed_collections.html.erb
diff --git a/apps/workbench/app/views/trash_items/_show_recent_trash.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb
similarity index 100%
rename from apps/workbench/app/views/trash_items/_show_recent_trash.html.erb
rename to apps/workbench/app/views/trash_items/_show_trashed_projects.html.erb
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list