Merge branch 'master' of git.curoverse.com:arvados into 2638-add-cache-age-disk-usage...
[arvados.git] / apps / workbench / app / controllers / folders_controller.rb
index e0ac625bab8a042a483b9eb56c74837cc16590b7..86ee42b10db54ecd389254d2470c210bc30c64e1 100644 (file)
@@ -9,6 +9,7 @@ class FoldersController < ApplicationController
 
   def remove_item
     @removed_uuids = []
+    links = []
     item = ArvadosBase.find params[:item_uuid]
     if (item.class == Link and
         item.link_class == 'name' and
@@ -16,8 +17,15 @@ class FoldersController < ApplicationController
       # Given uuid is a name link, linking an object to this
       # folder. First follow the link to find the item we're removing,
       # then delete the link.
-      link = item
-      item = ArvadosBase.find link.head_uuid
+      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
@@ -57,7 +65,6 @@ class FoldersController < ApplicationController
         @shared_with_me << folder
       end
     end
-    @object
   end
 
   def show