2961: Don't call #render_index from #index on folders_controller because #index
[arvados.git] / apps / workbench / app / controllers / virtual_machines_controller.rb
index 9ccbfa68219eaa8fd3a5348365db3e795b9eb85a..c3512e2e4d1028635cda1a51b1c09f2a2b63ade5 100644 (file)
@@ -1,2 +1,25 @@
 class VirtualMachinesController < ApplicationController
+  def index_pane_list
+    %w(recent help)
+  end
+  def index
+    @objects ||= model_class.all
+    @vm_logins = {}
+    if @objects.andand.first
+      Link.where(tail_uuid: current_user.uuid,
+                 head_uuid: @objects.collect(&:uuid),
+                 link_class: 'permission',
+                 name: 'can_login').
+        each do |perm_link|
+        if perm_link.properties.andand[:username]
+          @vm_logins[perm_link.head_uuid] ||= []
+          @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
+        end
+      end
+      @objects.each do |vm|
+        vm.current_user_logins = @vm_logins[vm.uuid].andand.compact || []
+      end
+    end
+    super
+  end
 end