10112: add Run button to workflow#show page
authorradhika <radhika@curoverse.com>
Wed, 26 Apr 2017 16:15:24 +0000 (12:15 -0400)
committerradhika <radhika@curoverse.com>
Wed, 26 Apr 2017 16:15:24 +0000 (12:15 -0400)
apps/workbench/app/views/container_requests/_extra_tab_line_buttons.html.erb
apps/workbench/app/views/workflows/show.html.erb [new file with mode: 0644]
apps/workbench/test/integration/work_units_test.rb

index fd7953551729d722b8cff678feb73baadc81f7d2..7f90af2eec5c948c3067ebeee15641e4284db7e8 100644 (file)
@@ -1,7 +1,6 @@
 <% if @object.state == 'Final' %>
   <%= link_to(copy_container_request_path('id' => @object.uuid),
       class: 'btn btn-sm btn-primary',
-      title: 'Re-run',
       data: {toggle: :tooltip, placement: :top}, title: 'This will make a copy and take you there. You can then make any needed changes and run it',
       method: :post,
       ) do %>
diff --git a/apps/workbench/app/views/workflows/show.html.erb b/apps/workbench/app/views/workflows/show.html.erb
new file mode 100644 (file)
index 0000000..f14ac1e
--- /dev/null
@@ -0,0 +1,20 @@
+<% if current_user.andand.is_active %>
+  <% content_for :tab_line_buttons do %>
+    <%= link_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]' => @object.uuid,
+                                                   'success' => 'redirect-to-created-object'
+                                                  }.to_json),
+          { class: "btn btn-primary btn-sm", title: "Run #{@object.name}", remote: true }
+        ) do %>
+      <i class="fa fa-fw fa-gear"></i> Run this workflow
+    <% end %>
+  <% end %>
+<% end %>
+
+<%= render file: 'application/show.html.erb', locals: local_assigns %>
index f9f5addb1561849b34f0f80ae659417468dc797e..87a9771d2bbd7811604367f42bbae2c5a6da6e7e 100644 (file)
@@ -278,4 +278,21 @@ class WorkUnitsTest < ActionDispatch::IntegrationTest
     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
+
+  test 'Run workflow from show page' do
+    visit page_with_token('active', '/workflows/zzzzz-7fd4e-validwithinputs')
+
+    find('a,button', text: 'Run this workflow').click
+
+    # 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"
+    assert_match /Provide a value for .* then click the \"Run\" button to start the workflow/, page.text
+  end
 end