1 class FoldersController < ApplicationController
7 %w(My_folders Shared_with_me)
13 item = ArvadosBase.find params[:item_uuid]
14 if (item.class == Link and
15 item.link_class == 'name' and
16 item.tail_uuid = @object.uuid)
17 # Given uuid is a name link, linking an object to this
18 # folder. First follow the link to find the item we're removing,
19 # then delete the link.
21 item = ArvadosBase.find item.head_uuid
23 # Given uuid is an object. Delete all names.
24 links += Link.where(tail_uuid: @object.uuid,
29 @removed_uuids << link.uuid
32 if item.owner_uuid == @object.uuid
33 # Object is owned by this folder. Remove it from the folder by
34 # changing owner to the current user.
35 item.update_attributes owner_uuid: current_user
36 @removed_uuids << item.uuid
43 @objects = Group.where(group_class: 'folder').order('name')
48 @objects.each do |folder|
49 if !owner_of[folder.uuid]
51 owner_of[folder.uuid] = folder.owner_uuid
53 if owner_of[folder.owner_uuid]
54 if owner_of[folder.uuid] != owner_of[folder.owner_uuid]
55 owner_of[folder.uuid] = owner_of[folder.owner_uuid]
61 @objects.each do |folder|
62 if owner_of[folder.uuid] == current_user.uuid
65 @shared_with_me << folder
71 @objects = @object.contents include_linked: true
72 @share_links = Link.filter([['head_uuid', '=', @object.uuid],
73 ['link_class', '=', 'permission']])
74 @logs = Log.limit(10).filter([['object_uuid', '=', @object.uuid]])
76 @objects_and_names = []
77 @objects.each do |object|
78 if !(name_links = @objects.links_for(object, 'name')).empty?
79 name_links.each do |name_link|
80 @objects_and_names << [object, name_link]
83 @objects_and_names << [object,
84 Link.new(tail_uuid: @object.uuid,
85 head_uuid: object.uuid,
95 @new_resource_attrs = (params['folder'] || {}).merge(group_class: 'folder')
96 @new_resource_attrs[:name] ||= 'New folder'