Merge branch '2659-anonymous-share-projects' refs #2659
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index eacf8b144e22fb9eb79ef05f47445763c6d1c3e9..613ed98f88cc22fb83ee65b3870b20605c5ce419 100644 (file)
@@ -3,6 +3,10 @@ require "arvados/keep"
 class CollectionsController < ApplicationController
   include ActionController::Live
 
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
   skip_around_filter(:require_thread_api_token,
                      only: [:show_file, :show_file_links])
   skip_before_filter(:find_object_by_uuid,
@@ -180,6 +184,16 @@ class CollectionsController < ApplicationController
 
   def show
     return super if !@object
+
+    @logs = []
+
+    if params["tab_pane"] == "Provenance_graph"
+      @prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
+                                                            {:request => request,
+                                                             :direction => :bottom_up,
+                                                             :combine_jobs => :script_only}) rescue nil
+    end
+
     if current_user
       if Keep::Locator.parse params["uuid"]
         @same_pdh = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]])
@@ -215,12 +229,6 @@ class CollectionsController < ApplicationController
           .results.any?
         @search_sharing = search_scopes
 
-        if params["tab_pane"] == "Provenance_graph"
-          @prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
-                                                                {:request => request,
-                                                                  :direction => :bottom_up,
-                                                                  :combine_jobs => :script_only}) rescue nil
-        end
         if params["tab_pane"] == "Used_by"
           @used_by_svg = ProvenanceHelper::create_provenance_graph(@object.used_by, "used_by_svg",
                                                                    {:request => request,
@@ -235,10 +243,7 @@ class CollectionsController < ApplicationController
 
   def sharing_popup
     @search_sharing = search_scopes
-    respond_to do |format|
-      format.html
-      format.js
-    end
+    render("sharing_popup.js", content_type: "text/javascript")
   end
 
   helper_method :download_link
@@ -248,18 +253,15 @@ class CollectionsController < ApplicationController
   end
 
   def share
-    a = ApiClientAuthorization.create(scopes: sharing_scopes)
-    @search_sharing = search_scopes
-    render 'sharing_popup'
+    ApiClientAuthorization.create(scopes: sharing_scopes)
+    sharing_popup
   end
 
   def unshare
-    @search_sharing = search_scopes
-    @search_sharing.each do |s|
+    search_scopes.each do |s|
       s.destroy
     end
-    @search_sharing = search_scopes
-    render 'sharing_popup'
+    sharing_popup
   end
 
   protected