Fix up table columns, use explicit Open button instead of linking uuid
[arvados.git] / apps / workbench / app / controllers / folders_controller.rb
1 class FoldersController < ApplicationController
2   def model_class
3     Group
4   end
5
6   def index_pane_list
7     %w(My_folders Shared_with_me)
8   end
9
10   def index
11     @my_folders = []
12     @shared_with_me = []
13     @objects = Group.where(group_class: 'folder').order('name')
14     owner_of = {}
15     moretodo = true
16     while moretodo
17       moretodo = false
18       @objects.each do |folder|
19         if !owner_of[folder.uuid]
20           moretodo = true
21           owner_of[folder.uuid] = folder.owner_uuid
22         end
23         if owner_of[folder.owner_uuid]
24           if owner_of[folder.uuid] != owner_of[folder.owner_uuid]
25             owner_of[folder.uuid] = owner_of[folder.owner_uuid]
26             moretodo = true
27           end
28         end
29       end
30     end
31     @objects.each do |folder|
32       if owner_of[folder.uuid] == current_user.uuid
33         @my_folders << folder
34       else
35         @shared_with_me << folder
36       end
37     end
38   end
39
40   def show
41     @objects = @object.contents include_linked: true
42     @logs = Log.limit(10).filter([['object_uuid', '=', @object.uuid]])
43     super
44   end
45
46   def create
47     @new_resource_attrs = (params['folder'] || {}).merge(group_class: 'folder')
48     super
49   end
50 end