2961: Changed index methods on some controllers to use render_index instead of
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index 1d710419dad09a55810a2abba05a5693812adb7f..064acc689babe5a39db7b3d2ce23cf8e36a05c9d 100644 (file)
@@ -88,6 +88,8 @@ class CollectionsController < ApplicationController
       info[:links] << link
     end
     @request_url = request.url
+
+    render_index
   end
 
   def show_file_links
@@ -121,11 +123,15 @@ class CollectionsController < ApplicationController
   end
 
   def sharing_scopes
-    ["GET /arvados/v1/collections/#{@object.uuid}", "GET /arvados/v1/keep_services"]
+    ["GET /arvados/v1/collections/#{@object.uuid}", "GET /arvados/v1/collections/#{@object.uuid}/", "GET /arvados/v1/keep_services/accessible"]
   end
 
   def search_scopes
-    ApiClientAuthorization.where(filters: [['scopes', '=', sharing_scopes]])
+    begin
+      ApiClientAuthorization.filter([['scopes', '=', sharing_scopes]]).results
+    rescue ArvadosApiClient::AccessForbiddenException
+      nil
+    end
   end
 
   def show
@@ -150,7 +156,7 @@ class CollectionsController < ApplicationController
         .where(head_uuid: @object.uuid, tail_uuid: current_user.uuid,
                link_class: 'resources', name: 'wants')
         .results.any?
-      @search_sharing = search_scopes.select { |s| s.scopes != ['all'] }
+      @search_sharing = search_scopes
     end
     @prov_svg = ProvenanceHelper::create_provenance_graph(@object.provenance, "provenance_svg",
                                                           {:request => request,
@@ -161,10 +167,12 @@ class CollectionsController < ApplicationController
                                                                :direction => :top_down,
                                                                :combine_jobs => :script_only,
                                                                :pdata_only => true}) rescue nil
+
+    super
   end
 
   def sharing_popup
-    @search_sharing = search_scopes.select { |s| s.scopes != ['all'] }
+    @search_sharing = search_scopes
     respond_to do |format|
       format.html
       format.js
@@ -179,16 +187,16 @@ class CollectionsController < ApplicationController
 
   def share
     a = ApiClientAuthorization.create(scopes: sharing_scopes)
-    @search_sharing = search_scopes.select { |s| s.scopes != ['all'] }
+    @search_sharing = search_scopes
     render 'sharing_popup'
   end
 
   def unshare
-    @search_sharing = search_scopes.select { |s| s.scopes != ['all'] }
+    @search_sharing = search_scopes
     @search_sharing.each do |s|
       s.destroy
     end
-    @search_sharing = search_scopes.select { |s| s.scopes != ['all'] }
+    @search_sharing = search_scopes
     render 'sharing_popup'
   end