2872: Fix bookmark bar causing spurious window width.
[arvados.git] / apps / workbench / app / controllers / application_controller.rb
index 9627ab6d793450af37fb5ada3aea4e5f8199d1ca..48b508a4a6e305d51764c6fd5ef4f94d43b76cfb 100644 (file)
@@ -501,12 +501,17 @@ class ApplicationController < ActionController::Base
     end
   end
 
+  helper_method :all_projects
+  def all_projects
+    @all_projects ||= Group.filter([['group_class','in',['project','folder']]])
+  end
+
   helper_method :my_projects
   def my_projects
     return @my_projects if @my_projects
     @my_projects = []
     root_of = {}
-    Group.filter([['group_class','in',['project','folder']]]).each do |g|
+    all_projects.each do |g|
       root_of[g.uuid] = g.owner_uuid
       @my_projects << g
     end
@@ -527,6 +532,12 @@ class ApplicationController < ActionController::Base
     end
   end
 
+  helper_method :projects_shared_with_me
+  def projects_shared_with_me
+    my_project_uuids = my_projects.collect &:uuid
+    all_projects.reject { |x| x.uuid.in? my_project_uuids }
+  end
+
   helper_method :recent_jobs_and_pipelines
   def recent_jobs_and_pipelines
     in_my_projects = ['owner_uuid','in',my_projects.collect(&:uuid)]
@@ -547,4 +558,34 @@ class ApplicationController < ActionController::Base
     @get_object ||= {}
     @get_object[uuid]
   end
+
+  helper_method :project_breadcrumbs
+  def project_breadcrumbs
+    crumbs = []
+    current = @name_link || @object
+    while current
+      if current.is_a?(Group) and current.group_class.in?(['project','folder'])
+        crumbs.prepend current
+      end
+      if current.is_a? Link
+        current = Group.find?(current.tail_uuid)
+      else
+        current = Group.find?(current.owner_uuid)
+      end
+    end
+    crumbs
+  end
+
+  helper_method :current_project_uuid
+  def current_project_uuid
+    if @object.is_a? Group and @object.group_class.in?(['project','folder'])
+      @object.uuid
+    elsif @name_link.andand.tail_uuid
+      @name_link.tail_uuid
+    elsif @object and resource_class_for_uuid(@object.owner_uuid) == Group
+      @object.owner_uuid
+    else
+      nil
+    end
+  end
 end