2872: all tests are updated to reflect the new ui.
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index 1d710419dad09a55810a2abba05a5693812adb7f..24b9b1f755780ee132119198267c9577e2180411 100644 (file)
@@ -7,7 +7,7 @@ class CollectionsController < ApplicationController
   RELATION_LIMIT = 5
 
   def show_pane_list
-    %w(Files Attributes Metadata Provenance_graph Used_by JSON API)
+    %w(Files Provenance_graph Used_by Advanced)
   end
 
   def set_persistent
@@ -40,6 +40,20 @@ class CollectionsController < ApplicationController
     end
   end
 
+  def choose
+    params[:limit] ||= 20
+    @objects = Link.
+      filter([['link_class','=','name'],
+              ['head_uuid','is_a','arvados#collection']])
+    find_objects_for_index
+    @next_page_href = (next_page_offset and
+                       url_for(offset: next_page_offset, partial: true))
+    @name_links = @objects
+    @objects = Collection.
+      filter([['uuid','in',@name_links.collect(&:head_uuid)]])
+    super
+  end
+
   def index
     if params[:search].andand.length.andand > 0
       tags = Link.where(any: ['contains', params[:search]])
@@ -121,11 +135,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 +168,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,
@@ -164,7 +182,7 @@ class CollectionsController < ApplicationController
   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 +197,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