[ARVADOS] updated: 65d8f0958492fe3d95b913b785a50e97e59746a3

Git user git at public.curoverse.com
Mon Oct 9 16:41:59 EDT 2017


Summary of changes:
 .../app/assets/stylesheets/application.css.scss    |  4 ++
 .../app/controllers/trash_items_controller.rb      | 29 ++++++------
 apps/workbench/app/views/application/404.html.erb  | 29 +++++++-----
 .../views/trash_items/_show_trash_rows.html.erb    | 49 +++++++++++++++++++++
 .../_show_trashed_collection_rows.html.erb         | 51 +---------------------
 .../trash_items/_show_trashed_collections.html.erb | 12 +++--
 .../_show_trashed_project_rows.html.erb            | 35 +--------------
 .../trash_items/_show_trashed_projects.html.erb    | 14 +++---
 services/api/lib/trashable.rb                      |  2 +-
 9 files changed, 101 insertions(+), 124 deletions(-)
 create mode 100644 apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
 mode change 100644 => 120000 apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb
 mode change 100644 => 120000 apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb

       via  65d8f0958492fe3d95b913b785a50e97e59746a3 (commit)
      from  e21793cad5a2e096c4c7200b6fdbe95ded03bb4f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 65d8f0958492fe3d95b913b785a50e97e59746a3
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Oct 9 16:41:05 2017 -0400

    12125: Can search within trashed projects.
    
    Don't show items within trashed projects in the complete list, but do make it
    possible to search for them.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss
index 31f06e9..32d8025 100644
--- a/apps/workbench/app/assets/stylesheets/application.css.scss
+++ b/apps/workbench/app/assets/stylesheets/application.css.scss
@@ -203,6 +203,10 @@ li.notification {
     padding: 10px;
 }
 
+td.trash-project-msg {
+    white-space: normal;
+}
+
 // See HeaderRowFixer in application.js
 table.table-fixed-header-row {
     width: 100%;
diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb
index 797ccc3..7d6e143 100644
--- a/apps/workbench/app/controllers/trash_items_controller.rb
+++ b/apps/workbench/app/controllers/trash_items_controller.rb
@@ -66,31 +66,33 @@ class TrashItemsController < ApplicationController
 
     # API server index doesn't return manifest_text by default, but our
     # callers want it unless otherwise specified.
-    @select ||= query_on.columns.map(&:name) - %w(id updated_at)
+    #@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
 
     @objects = []
     while !@objects.any?
-      base_search = query_on.select(@select).include_trash(true)
-      base_search = base_search.filter(params[:filters]) if params[:filters]
+      base_search = query_on
 
       if !last_mod_at.nil?
         base_search = base_search.filter([["modified_at", "<=", last_mod_at], ["uuid", "not in", last_uuids]])
       end
 
-      if params[:search].andand.length.andand > 0
-        tags = Link.where(any: ['contains', params[:search]])
-        base_search = base_search.limit(limit).offset(offset)
-        @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) |
-                    base_search.where(any: ['contains', params[:search]])).
-                   uniq { |c| c.uuid }
+      base_search = base_search.include_trash(true).limit(limit).offset(offset)
+
+      if params[:filters].andand.length.andand > 0
+        tags = Link.filter(params[:filters])
+        tagged = []
+        if tags.results.length > 0
+          tagged = query_on.include_trash(true).where(uuid: tags.collect(&:head_uuid))
+        end
+        @objects = (tagged | base_search.filter(params[:filters])).uniq(&:uuid)
       else
-        @objects = base_search.limit(limit).offset(offset)
+        @objects = base_search.where(is_trashed: true)
       end
 
       if @objects.any?
-        owner_uuids = @objects.collect {|item| item.owner_uuid}.uniq
+        owner_uuids = @objects.collect(&:owner_uuid).uniq
         @owners = {}
         @not_trashed = {}
         Group.filter([["uuid", "in", owner_uuids]]).include_trash(true).each do |grp|
@@ -98,12 +100,9 @@ class TrashItemsController < ApplicationController
         end
         User.filter([["uuid", "in", owner_uuids]]).include_trash(true).each do |grp|
           @owners[grp.uuid] = grp
-        end
-
-        Group.filter([["uuid", "in", owner_uuids]]).select([:uuid]).each do |grp|
           @not_trashed[grp.uuid] = true
         end
-        User.filter([["uuid", "in", owner_uuids]]).select([:uuid]).each do |grp|
+        Group.filter([["uuid", "in", owner_uuids]]).select([:uuid]).each do |grp|
           @not_trashed[grp.uuid] = true
         end
       else
diff --git a/apps/workbench/app/views/application/404.html.erb b/apps/workbench/app/views/application/404.html.erb
index ee72ccd..2d9b5cf 100644
--- a/apps/workbench/app/views/application/404.html.erb
+++ b/apps/workbench/app/views/application/404.html.erb
@@ -4,7 +4,7 @@ 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)
+     check_trash = controller.model_class.include_trash(true).where(uuid: params[:uuid])
      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 ",
@@ -21,18 +21,27 @@ SPDX-License-Identifier: AGPL-3.0 %>
 
     <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,
+      <% object = check_trash.first %>
+
+      <% if object.is_trashed
+         untrash_object = object
+         else
+       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 %>
 
-      <% end %>
+          <% 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 %>
+          <%= 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>
+        <% end %>
+      <% else %>
+        <% %>
+      <% end %>
     </p>
 
   <% else %>
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
new file mode 100644
index 0000000..ee61e45
--- /dev/null
+++ b/apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
@@ -0,0 +1,49 @@
+<%# 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>
+    <% if obj.is_trashed %>
+      <td>
+        <%= link_to_if_arvados_object @owners[obj.owner_uuid], friendly_name: true %>
+      </td>
+
+      <td>
+        <% if obj.trash_at %>
+          <%= render_localized_date(obj.trash_at)  %>
+        <% end %>
+        <br />
+        <% if obj.delete_at %>
+          <%= render_localized_date(obj.delete_at) %>
+        <% end %>
+      </td>
+    <% else %>
+      <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.
+      </td>
+    <% end %>
+    <td>
+      <%= obj.uuid %>
+      <% if defined? obj.portable_data_hash %>
+        <br /><%= obj.portable_data_hash %>
+      <% end %>
+    </td>
+    <td>
+      <% if obj.is_trashed %>
+        <%= render partial: 'untrash_item', locals: {object:obj} %>
+      <% end %>
+    </td>
+  </tr>
+
+<% end %>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb
deleted file mode 100644
index 443c7d4..0000000
--- a/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb
+++ /dev/null
@@ -1,50 +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>
-      <td>
-        <% if obj.trash_at %>
-          <%= render_localized_date(obj.trash_at)  %>
-        <% end %>
-        <br />
-        <% if obj.delete_at %>
-          <%= render_localized_date(obj.delete_at) %>
-        <% end %>
-      </td>
-      <td>
-        <%= link_to_if_arvados_object @owners[obj.owner_uuid], friendly_name: true %>
-        <% if @not_trashed[obj.owner_uuid].nil? %>
-          (trashed)
-        <% end %>
-      </td>
-      <td>
-        <%= obj.uuid %><br /><%= obj.portable_data_hash %>
-      </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>
-        <% if @not_trashed[obj.owner_uuid].nil? %>
-        <% else %>
-          <%= render partial: 'untrash_item', locals: {object:obj} %>
-        <% end %>
-      </td>
-    </tr>
-<% end %>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb
new file mode 120000
index 0000000..6841b57
--- /dev/null
+++ b/apps/workbench/app/views/trash_items/_show_trashed_collection_rows.html.erb
@@ -0,0 +1 @@
+_show_trash_rows.html.erb
\ No newline at end of file
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 0cb941c..a2ef087 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
@@ -29,12 +29,11 @@ SPDX-License-Identifier: AGPL-3.0 %>
   <div>
     <table id="trash-index" class="topalign table table-condensed table-fixedlayout">
       <colgroup>
-        <col width="2%" />
-        <col width="20%" />
-        <col width="13%" />
-        <col width="15%" />
-        <col width="20%" />
+        <col width="5%" />
+        <col width="16%" />
         <col width="25%" />
+        <col width="20%" />
+        <col width="29%" />
         <col width="5%" />
       </colgroup>
 
@@ -42,10 +41,9 @@ SPDX-License-Identifier: AGPL-3.0 %>
         <tr class="contain-align-left">
           <th></th>
           <th>Name</th>
-          <th>Date trashed /<br />to be deleted</th>
           <th>Parent project</th>
+          <th>Date trashed /<br />to be deleted</th>
           <th>UUID /<br />Content address (PDH)</th>
-          <th>Contents</th>
           <th></th>
         </tr>
       </thead>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb
deleted file mode 100644
index ef3a478..0000000
--- a/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb
+++ /dev/null
@@ -1,34 +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>
-      <td>
-        <% if obj.trash_at %>
-          <%= render_localized_date(obj.trash_at)  %>
-        <% end %>
-        <br />
-        <% if obj.delete_at %>
-          <%= render_localized_date(obj.delete_at) %>
-        <% end %>
-      </td>
-      <td>
-        <%= link_to_if_arvados_object obj.owner_uuid, friendly_name: true %>
-      </td>
-      <td>
-        <%= obj.uuid %>
-      </td>
-      <td>
-        <%= render partial: 'untrash_item', locals: {object:obj} %>
-      </td>
-    </tr>
-<% end %>
diff --git a/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb b/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb
new file mode 120000
index 0000000..6841b57
--- /dev/null
+++ b/apps/workbench/app/views/trash_items/_show_trashed_project_rows.html.erb
@@ -0,0 +1 @@
+_show_trash_rows.html.erb
\ No newline at end of file
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 2882814..ced1990 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
@@ -29,20 +29,20 @@ SPDX-License-Identifier: AGPL-3.0 %>
   <div>
     <table id="trash-index" class="topalign table table-condensed table-fixedlayout">
       <colgroup>
-        <col width="10%" />
-        <col width="21%" />
-        <col width="21%" />
-        <col width="21%" />
-        <col width="21%" />
-        <col width="6%" />
+        <col width="5%" />
+        <col width="16%" />
+        <col width="25%" />
+        <col width="20%" />
+        <col width="29%" />
+        <col width="5%" />
       </colgroup>
 
       <thead>
         <tr class="contain-align-left">
           <th></th>
           <th>Name</th>
-          <th>Date trashed /<br />to be deleted</th>
           <th>Parent project</th>
+          <th>Date trashed /<br />to be deleted</th>
           <th>UUID</th>
           <th></th>
         </tr>
diff --git a/services/api/lib/trashable.rb b/services/api/lib/trashable.rb
index 38ebaf7..9687962 100644
--- a/services/api/lib/trashable.rb
+++ b/services/api/lib/trashable.rb
@@ -120,7 +120,7 @@ module TrashableController
         @object.save!
       end
     else
-      raise InvalidStateTransitionError
+      raise ArvadosModel::InvalidStateTransitionError.new("Item is not trashed, cannot untrash")
     end
     show
   end

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list