Merge branch '3504-clients-compatible-with-3036' refs #3504
[arvados.git] / apps / workbench / app / controllers / actions_controller.rb
index 9a76e9aed412522ffa14166e0b9aadbe1f8e8acf..fd4ebc4cd4a890bad064f415f5e7e839f02cd9a7 100644 (file)
@@ -10,6 +10,19 @@ class ActionsController < ApplicationController
     ArvadosBase::resource_class_for_uuid(params[:uuid])
   end
 
+  def show
+    @object = model_class.andand.find(params[:uuid])
+    if @object.is_a? Link and
+        @object.link_class == 'name' and
+        ArvadosBase::resource_class_for_uuid(@object.head_uuid) == Collection
+      redirect_to collection_path(id: @object.uuid)
+    elsif @object
+      redirect_to @object
+    else
+      raise ActiveRecord::RecordNotFound
+    end
+  end
+
   def post
     params.keys.collect(&:to_sym).each do |param|
       if @@exposed_actions[param]
@@ -29,12 +42,13 @@ class ActionsController < ApplicationController
 
   def move_or_copy action
     uuids_to_add = params["selection"]
+    uuids_to_add = [ uuids_to_add ] unless uuids_to_add.is_a? Array
     uuids_to_add.
       collect { |x| ArvadosBase::resource_class_for_uuid(x) }.
       uniq.
       each do |resource_class|
       resource_class.filter([['uuid','in',uuids_to_add]]).each do |src|
-        if resource_class == Collection
+        if resource_class == Collection and not Collection.attribute_info.include?(:name)
           dst = Link.new(owner_uuid: @object.uuid,
                          tail_uuid: @object.uuid,
                          head_uuid: src.uuid,
@@ -51,6 +65,9 @@ class ActionsController < ApplicationController
                 dst.name = "Copy of unnamed #{dst.class_for_display.downcase}"
               end
             end
+            if resource_class == Collection
+              dst.manifest_text = Collection.select([:manifest_text]).where(uuid: src.uuid).first.manifest_text
+            end
           when :move
             dst = src
           else