11450: workflows index page
authorradhika <radhika@curoverse.com>
Fri, 14 Apr 2017 17:29:54 +0000 (13:29 -0400)
committerradhika <radhika@curoverse.com>
Wed, 19 Apr 2017 15:27:19 +0000 (11:27 -0400)
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/models/workflow.rb
apps/workbench/app/views/workflows/_show_recent.html.erb [new file with mode: 0644]
apps/workbench/test/integration/work_units_test.rb

index 056f12f6c8e70faa77f45d5f5d356439d528a1ec..41b33706d1b72d8afad059437ed5cfe1748701bf 100644 (file)
@@ -607,6 +607,7 @@ module ApplicationHelper
 
   RESOURCE_CLASS_ICONS = {
     "Collection" => "fa-archive",
+    "ContainerRequest" => "fa-gears",
     "Group" => "fa-users",
     "Human" => "fa-male",  # FIXME: Use a more inclusive icon.
     "Job" => "fa-gears",
@@ -621,6 +622,7 @@ module ApplicationHelper
     "Trait" => "fa-clipboard",
     "User" => "fa-user",
     "VirtualMachine" => "fa-terminal",
+    "Workflow" => "fa-gears",
   }
   DEFAULT_ICON_CLASS = "fa-cube"
 
index 553f1410316ed14ec0a9d4a9c0074792231a934b..c59125fd08fa2700540b973623192950b6dbb646 100644 (file)
@@ -2,4 +2,12 @@ class Workflow < ArvadosBase
   def self.goes_in_projects?
     true
   end
+
+  def self.creatable?
+    false
+  end
+
+  def textile_attributes
+    [ 'description' ]
+  end
 end
diff --git a/apps/workbench/app/views/workflows/_show_recent.html.erb b/apps/workbench/app/views/workflows/_show_recent.html.erb
new file mode 100644 (file)
index 0000000..94d39c1
--- /dev/null
@@ -0,0 +1,65 @@
+<%= render partial: "paging", locals: {results: @objects, object: @object} %>
+
+<table class="table table-condensed arv-index">
+  <colgroup>
+    <col width="10%" />
+    <col width="10%" />
+    <col width="25%" />
+    <col width="40%" />
+    <col width="15%" />
+  </colgroup>
+
+  <thead>
+    <tr class="contain-align-left">
+      <th></th>
+      <th></th>
+      <th> name </th>
+      <th> description </th>
+      <th> owner </th>
+    </tr>
+  </thead>
+
+  <tbody>
+    <% @objects.sort_by { |ob| ob[:created_at] }.reverse.each do |ob| %>
+      <tr>
+        <td>
+          <%= button_to(choose_projects_path(id: "run-workflow-button",
+                                             title: 'Choose project',
+                                             editable: true,
+                                             action_name: 'Choose',
+                                             action_href: work_units_path,
+                                             action_method: 'post',
+                                             action_data: {'selection_param' => 'work_unit[owner_uuid]',
+                                                           'work_unit[template_uuid]' => ob.uuid,
+                                                           'success' => 'redirect-to-created-object'
+                                                          }.to_json),
+                  { class: "btn btn-default btn-xs", title: "Run #{ob.name}", remote: true, method: :get }
+              ) do %>
+                 <i class="fa fa-fw fa-play"></i> Run
+          <% end %>
+        </td>
+
+        <td>
+          <%= render :partial => "show_object_button", :locals => {object: ob, size: 'xs'} %>
+        </td>
+
+        <td>
+          <%= render_editable_attribute ob, 'name' %>
+        </td>
+
+        <td>
+          <% if ob.description %>
+            <%= render_attribute_as_textile(ob, "description", ob.description, false) %>
+            <br />
+          <% end %>
+        </td>
+
+        <td>
+          <%= link_to_if_arvados_object ob.owner_uuid, friendly_name: true %>
+        </td>
+      </tr>
+    <% end %>
+  </tbody>
+</table>
+
+<%= render partial: "paging", locals: {results: @objects, object: @object} %>
index 91b382d1bd0402e25488ec80e08e9c61ea1c745d..f9f5addb1561849b34f0f80ae659417468dc797e 100644 (file)
@@ -254,4 +254,28 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
       end
     end
   end
+
+  test 'Run from workflows index page' do
+    visit page_with_token('active', '/workflows')
+
+    wf_count = page.all('a[data-original-title="show workflow"]').count
+    assert_equal true, wf_count>0
+
+    # Run one of the workflows
+    wf_name = 'Workflow with input specifications'
+    within('tr', text: wf_name) do
+      find('a,button', text: 'Run').click
+    end
+
+    # Choose project for the container_request being created
+    within('.modal-dialog') do
+      find('.selectable', text: 'A Project').click
+      find('button', text: 'Choose').click
+    end
+
+    # In newly created container_request page now
+    assert_text 'A Project' # CR created in "A Project"
+    assert_text "This container request was created from the workflow #{wf_name}"
+    assert_match /Provide a value for .* then click the \"Run\" button to start the workflow/, page.text
+  end
 end