5417: a few changes from based on review feedback. also, account for dataclass=File...
authorRadhika Chippada <radhika@curoverse.com>
Thu, 16 Apr 2015 17:35:58 +0000 (13:35 -0400)
committerRadhika Chippada <radhika@curoverse.com>
Thu, 16 Apr 2015 17:35:58 +0000 (13:35 -0400)
apps/workbench/app/controllers/pipeline_instances_controller.rb
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/helpers/pipeline_instances_helper.rb
apps/workbench/test/integration/anonymous_access_test.rb
services/api/test/fixtures/pipeline_instances.yml

index 4a7348a8ec3ec28848a833c8cb43f531c39fafba..57deee43e0506ee1817d40dabfba976bc6846747 100644 (file)
@@ -295,7 +295,7 @@ class PipelineInstancesController < ApplicationController
     @object.components.each do |k, component|
       next if !component
       component[:script_parameters].andand.each do |p, tv|
-        if (tv.is_a? Hash) and (tv[:dataclass] == "Collection")
+        if (tv.is_a? Hash) and ((tv[:dataclass] == "Collection") || (tv[:dataclass] == "File"))
           if tv[:value]
             value = tv[:value]
           elsif tv[:default]
index 4af7d29cf3cc8f5aaa165cf426cf18645e0e45e1..923a366d538509f04ce4ce1e5a3f3558321d6913 100644 (file)
@@ -187,28 +187,35 @@ module ApplicationHelper
     if readable
       link_to_if_arvados_object attrvalue, opts
     elsif opts[:required] and current_user # no need to show this for anonymous user
-      raw('<div><input type="text" style="border:none;width:100%;background:#ffdddd" disabled=true class="required unreadable-input" value="' + link_text_if_not_readable + '" ></input></div>')
+      raw('<div><input type="text" style="border:none;width:100%;background:#ffdddd" disabled=true class="required unreadable-input" value="') + link_text_if_not_readable + raw('" ></input></div>')
     else
       link_text_if_not_readable
     end
   end
 
+  # This method takes advantage of preloaded collections and objects.
+  # Hence you can improve performance by first preloading objects
+  # related to the page context before using this method.
   def object_readable attrvalue, resource_class=nil
-    # if it is a collection filename, check readable for the locator
-    attrvalue = attrvalue.split('/')[0] if attrvalue
-
-    resource_class = resource_class_for_uuid(attrvalue)
+    resource_class = resource_class_for_uuid(attrvalue) if resource_class.nil?
     return if resource_class.nil?
 
+    return_value = nil
     if resource_class.to_s == 'Collection'
+      # if it is a collection filename, check readable for the locator
+      attrvalue = attrvalue.split('/')[0] if attrvalue
+
       if CollectionsHelper.match(attrvalue)
-        collection_for_pdh(attrvalue).any?
+        found = collection_for_pdh(attrvalue)
+        return_value = found.first if found.any?
       else
-        collections_for_object(attrvalue).any?
+        found = collections_for_object(attrvalue)
+        return_value = found.first if found.any?
       end
     else
-      object_for_dataclass(resource_class, attrvalue)
+      return_value = object_for_dataclass(resource_class, attrvalue)
     end
+    return_value
   end
 
   def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={})
index 3fbd27249a0b76c4c12d70ea00cae0acf18a299d..ba05f9e88cd7cd2f0345c993d5e60a7603e2bb8c 100644 (file)
@@ -308,8 +308,8 @@ module PipelineInstancesHelper
 
   def render_unreadable_inputs_present
     if current_user and controller.class.name.eql?('PipelineInstancesController') and unreadable_inputs_present?
-      raw('<div class="unreadable-inputs-present">' +
-            '<p style="color:#ff6666">One or more inputs provided are not readable by you. ' +
+      raw('<div class="alert alert-danger unreadable-inputs-present">' +
+            '<p>One or more inputs provided are not readable by you. ' +
               'Please correct these before you can run the pipeline.</p></div>')
     end
   end
index d1782b8c2da4f27b3d149a7ea36566c6356decc4..9f31ef948603f4577d86f0400a2d3f21cac71015 100644 (file)
@@ -247,6 +247,7 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false, 'spectator'],
     ['new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', true, 'admin'],
+    ['new_pipeline_in_publicly_accessible_project_with_dataclass_file_and_other_objects_elsewhere', false, 'spectator'],
   ].each do |fixture, objects_readable, user=nil|
     test "access #{fixture} in public project with objects readable=#{objects_readable} with user #{user}" do
       object = api_fixture('pipeline_instances')[fixture]
index 1f1b128133d32c22d715909c2f45d91aecd010ab..92d87073a1ec9a0213e65fd00fb1ce5adc90f7e1 100644 (file)
@@ -338,6 +338,23 @@ new_pipeline_in_publicly_accessible_project_but_other_objects_elsewhere:
           dataclass: Collection
           value: zzzzz-4zz18-bv31uwvy3neko21
 
+new_pipeline_in_publicly_accessible_project_with_dataclass_file_and_other_objects_elsewhere:
+  uuid: zzzzz-d1hrv-newsharenotfile
+  owner_uuid: zzzzz-j7d0g-zhxawtyetzwc5f0
+  name: Pipeline in public project in New state with file type data class with objects elsewhere
+  pipeline_template_uuid: zzzzz-p5p6p-aox0k0ofxrystgw
+  state: New
+  created_at: 2014-09-15 12:00:00
+  components:
+    foo:
+      script: foo
+      script_version: master
+      script_parameters:
+        input:
+          required: true
+          dataclass: File
+          value: zzzzz-4zz18-bv31uwvy3neko21
+
 pipeline_in_running_state:
   name: running_with_job
   state: Ready