[ARVADOS] updated: 884558f4505049685c7cdb5b50c4b8948f38cd1b

git at public.curoverse.com git at public.curoverse.com
Mon Feb 15 08:37:33 EST 2016


Summary of changes:
 apps/workbench/app/controllers/application_controller.rb    | 13 ++++++++-----
 .../app/views/application/_projects_tree_menu.html.erb      |  6 +++++-
 apps/workbench/test/controllers/projects_controller_test.rb |  9 +++++----
 3 files changed, 18 insertions(+), 10 deletions(-)

       via  884558f4505049685c7cdb5b50c4b8948f38cd1b (commit)
      from  6b98fad744480d42fe084d70429bf3d658a06caa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 884558f4505049685c7cdb5b50c4b8948f38cd1b
Author: radhika <radhika at curoverse.com>
Date:   Mon Feb 15 08:36:47 2016 -0500

    8183: display top three levels of projects in menu, improve message when there are too many projects, improve the test.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index cc64cfd..9438da3 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -833,26 +833,29 @@ class ApplicationController < ActionController::Base
   end
 
   # If there are more than 200 projects that are readable by the user,
-  # build the tree using only the top 200+ projects owned by the user.
+  # build the tree using only the top 200+ projects owned by the user,
+  # from the top three levels.
   # That is: get toplevel projects under home, get subprojects of
-  # these projects, and so on until we hit the limit
+  # these projects, and so on until we hit the limit.
   def my_wanted_projects user, page_size=100
     return @my_wanted_projects if @my_wanted_projects
 
     from_top = []
     uuids = [user.uuid]
     depth = 0
-    @too_many_levels = false
+    @too_many_projects = false
+    @reached_level_limit = false
     while from_top.size <= page_size*2
       current_level = Group.filter([['group_class','=','project'],
                                     ['owner_uuid', 'in', uuids]])
                       .order('name').limit(page_size*2)
       break if current_level.results.size == 0
+      @too_many_projects = true if current_level.items_available > current_level.results.size
       from_top.concat current_level.results
       uuids = current_level.results.collect { |x| x.uuid }
       depth += 1
       if depth >= 3
-        @too_many_levels = true
+        @reached_level_limit = true
         break
       end
     end
@@ -862,7 +865,7 @@ class ApplicationController < ActionController::Base
   helper_method :my_wanted_projects_tree
   def my_wanted_projects_tree user, page_size=100
     build_my_wanted_projects_tree user, page_size
-    [@my_wanted_projects_tree, @too_many_levels]
+    [@my_wanted_projects_tree, @too_many_projects, @reached_level_limit]
   end
 
   def build_my_wanted_projects_tree user, page_size=100
diff --git a/apps/workbench/app/views/application/_projects_tree_menu.html.erb b/apps/workbench/app/views/application/_projects_tree_menu.html.erb
index f8918e6..69f97e4 100644
--- a/apps/workbench/app/views/application/_projects_tree_menu.html.erb
+++ b/apps/workbench/app/views/application/_projects_tree_menu.html.erb
@@ -17,6 +17,10 @@
 <% end %>
 <% if my_tree[1] or my_tree[0].size > 200 %>
 <li role="presentation" class="dropdown-header">
-  Not all projects may have been listed.
+  Some projects have been omitted.
+</li>
+<% elsif my_tree[2] %>
+<li role="presentation" class="dropdown-header">
+  Showing top three levels of your projects.
 </li>
 <% end %>
diff --git a/apps/workbench/test/controllers/projects_controller_test.rb b/apps/workbench/test/controllers/projects_controller_test.rb
index db39666..6bdab55 100644
--- a/apps/workbench/test/controllers/projects_controller_test.rb
+++ b/apps/workbench/test/controllers/projects_controller_test.rb
@@ -421,18 +421,19 @@ class ProjectsControllerTest < ActionController::TestCase
 
   [
     ["active", 5, ["aproject", "asubproject"], "anonymously_accessible_project"],
+    ["user1_with_load", 2, ["project_with_10_collections"], "project_with_2_pipelines_and_60_jobs"],
     ["admin", 5, ["anonymously_accessible_project", "subproject_in_anonymous_accessible_project"], "aproject"],
   ].each do |user, page_size, tree_segment, unexpected|
-    test "build my projects tree for #{user} user with page size #{page_size}" do
+    test "build my projects tree for #{user} user and verify #{unexpected} is omitted" do
       use_token user
       ctrl = ProjectsController.new
 
       current_user = User.find(api_fixture('users')[user]['uuid'])
 
-      my_tree = ctrl.send :my_wanted_projects_tree, current_user, 10
+      my_tree = ctrl.send :my_wanted_projects_tree, current_user, page_size
 
       tree_segment_at_depth_1 = api_fixture('groups')[tree_segment[0]]
-      tree_segment_at_depth_2 = api_fixture('groups')[tree_segment[1]]
+      tree_segment_at_depth_2 = api_fixture('groups')[tree_segment[1]] if tree_segment[1]
 
       tree_nodes = {}
       my_tree[0].each do |x|
@@ -440,7 +441,7 @@ class ProjectsControllerTest < ActionController::TestCase
       end
 
       assert_equal(1, tree_nodes[tree_segment_at_depth_1['uuid']])
-      assert_equal(2, tree_nodes[tree_segment_at_depth_2['uuid']])
+      assert_equal(2, tree_nodes[tree_segment_at_depth_2['uuid']]) if tree_segment[1]
 
       unexpected_project = api_fixture('groups')[unexpected]
       assert_nil(tree_nodes[unexpected_project['uuid']])

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list