Fix up table columns, use explicit Open button instead of linking uuid
[arvados.git] / apps / workbench / app / controllers / folders_controller.rb
index 3f536fbea4eeec21c1e30322daf123b613dcb16a..566b1a9da3277c199e5dd56da225dde17319e918 100644 (file)
@@ -3,8 +3,38 @@ class FoldersController < ApplicationController
     Group
   end
 
+  def index_pane_list
+    %w(My_folders Shared_with_me)
+  end
+
   def index
-    @objects = Group.where group_class: 'folder'
+    @my_folders = []
+    @shared_with_me = []
+    @objects = Group.where(group_class: 'folder').order('name')
+    owner_of = {}
+    moretodo = true
+    while moretodo
+      moretodo = false
+      @objects.each do |folder|
+        if !owner_of[folder.uuid]
+          moretodo = true
+          owner_of[folder.uuid] = folder.owner_uuid
+        end
+        if owner_of[folder.owner_uuid]
+          if owner_of[folder.uuid] != owner_of[folder.owner_uuid]
+            owner_of[folder.uuid] = owner_of[folder.owner_uuid]
+            moretodo = true
+          end
+        end
+      end
+    end
+    @objects.each do |folder|
+      if owner_of[folder.uuid] == current_user.uuid
+        @my_folders << folder
+      else
+        @shared_with_me << folder
+      end
+    end
   end
 
   def show