4878: show only the re-run popup option
authorRadhika Chippada <radhika@curoverse.com>
Tue, 27 Jan 2015 14:23:37 +0000 (09:23 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Tue, 27 Jan 2015 14:23:37 +0000 (09:23 -0500)
apps/workbench/app/controllers/jobs_controller.rb
apps/workbench/app/views/jobs/_rerun_job_with_options_popup.html.erb
apps/workbench/app/views/jobs/_show_job_buttons.html.erb
apps/workbench/test/integration/jobs_test.rb
apps/workbench/test/integration/websockets_test.rb
services/api/test/fixtures/jobs.yml

index 2f618ee93bb5f07403062e79785018e2f55d428d..685d13d1b550e628d65a1d6ef18851e288c7360f 100644 (file)
@@ -94,13 +94,15 @@ class JobsController < ApplicationController
     job_info = JSON.parse params['job_info']
 
     @object = Job.new
+
     @object.script = job_info['script']
     @object.repository = job_info['repository']
     @object.nondeterministic = job_info['nondeterministic']
     @object.script_parameters = job_info['script_parameters']
     @object.runtime_constraints = job_info['runtime_constraints']
+    @object.supplied_script_version = job_info['supplied_script_version']
 
-    if params['use_script'] == 'latest'
+    if 'use_latest' == params['script']
       @object.script_version = job_info['supplied_script_version']
     else
       @object.script_version = job_info['script_version']
index 6d92edd1ff76d30a9d44e0ba052b99b027720cb6..c25a4e289c2dcb1e1c6fc7d835d6615abe382296 100644 (file)
           <p> The inputs and parameters will be the same as the current job.
               Thus, the new job will not reflect any changes made to the pipeline that initiated this job. </p>
           <div style="padding-left: 1em">
-            <%= radio_button_tag(:use_script, "latest", true) %>
-            <%= label_tag(:script_use_latest, "Use latest script version") %>
-            <p style="padding-left: 1em"> Use the current commit indicated by '<%=job_info['supplied_script_version']%>' in the '<%=job_info['repository']%>' repository.</p>
-            <%= radio_button_tag(:use_script, "same") %>
+            <%= radio_button_tag(:script, "use_same", true) %>
             <%= label_tag(:script_use_same, "Use same script version as this run") %>
             <p style="padding-left: 1em"> Use the same script version as the current job.</p>
+            <% if !job_info['supplied_script_version'].nil? and
+                  !job_info['supplied_script_version'].empty? and
+                   job_info['supplied_script_version'] != job_info['script_version'] %>
+              <%= radio_button_tag(:script, "use_latest") %>
+              <%= label_tag(:script_use_latest, "Use latest script version") %>
+              <p style="padding-left: 1em"> Use the current commit indicated by '<%=job_info['supplied_script_version']%>' in the '<%=job_info['repository']%>' repository.</p>
+            <% end %>
+
             <input type="hidden" name="job_info" value="<%=job_info.to_json%>">
           </div>
         </div>
index aa5df3516f775673fe9360654fa300d525a7b153..8e9cff71d924b84c00abf617da0eb5f055af72e1 100644 (file)
@@ -1,27 +1,16 @@
 <% if @object.state != "Running" %>
-    <%= form_tag '/jobs', style: "display:inline; padding-left: 1em" do |f| %>
-      <% [:script, :script_version, :repository, :supplied_script_version, :nondeterministic].each do |d| %>
-        <%= hidden_field :job, d, :value => @object[d] %>
-      <% end %>
-      <% [:script_parameters, :runtime_constraints].each do |d| %>
-        <%= hidden_field :job, d, :value => JSON.dump(@object[d]) %>
-      <% end %>
-      <%= button_tag ({class: 'btn btn-sm btn-primary', id: "re-run-same-job-button",
-                       title: 'Re-run job using the same script version as this run'}) do %>
-        <i class="fa fa-fw fa-gear"></i> Re-run same version
-      <% end %>
-    <% end %>
-    <% if @object.respond_to? :supplied_script_version and !@object.supplied_script_version.nil? and !@object.supplied_script_version.empty? and @object.script_version != @object.supplied_script_version%>
-      <%= link_to rerun_job_with_options_popup_path(script: @object[:script],
-                                                    script_version: @object[:script_version],
-                                                    repository: @object[:repository],
-                                                    supplied_script_version: @object[:supplied_script_version],
-                                                    nondeterministic: @object[:nondeterministic],
-                                                    script_parameters: @object[:script_parameters],
-                                                    runtime_constraints: @object[:runtime_constraints]),
-          {class: 'btn btn-sm btn-primary', :remote => true, 'data-toggle' =>  "modal",
-            'data-target' => '#rerun-job-with-options', return_to: request.url} do %>
-          <i class="fa fa-fw fa-gear"></i> Re-run with options...
-      <% end %>
+<%
+  supplied_script_version = @object[:supplied_script_version] if @object.respond_to? :supplied_script_version
+%>
+    <%= link_to rerun_job_with_options_popup_path(script: @object[:script],
+                                                  script_version: @object[:script_version],
+                                                  repository: @object[:repository],
+                                                  supplied_script_version: supplied_script_version,
+                                                  nondeterministic: @object[:nondeterministic],
+                                                  script_parameters: @object[:script_parameters],
+                                                  runtime_constraints: @object[:runtime_constraints]),
+        {class: 'btn btn-sm btn-primary', :remote => true, 'data-toggle' =>  "modal",
+          'data-target' => '#rerun-job-with-options', return_to: request.url} do %>
+        <i class="fa fa-fw fa-gear"></i> Re-run job...
     <% end %>
 <% end %>
index 0de9149d1744d2268035b75f22887a2957b06845..719a8776135d519d8ae4c9edde91df07026c57a3 100644 (file)
@@ -74,44 +74,36 @@ class JobsTest < ActionDispatch::IntegrationTest
   end
 
   [
-    ['foobar', false, false, false],
-    ['job_with_latest_version', true, false, false],
-    ['job_with_latest_version', true, true, false],
-    ['job_with_latest_version', true, true, true],
-  ].each do |job_name, expect_options, use_options, click_option|
+    ['foobar', false, false],
+    ['job_with_latest_version', true, false],
+    ['job_with_latest_version', true, true],
+  ].each do |job_name, expect_options, use_latest|
     test "Rerun #{job_name} job, expect options #{expect_options},
-          use options #{use_options} and click option #{click_option}" do
+          and use latest version option #{use_latest}" do
       need_javascript
 
       job = api_fixture('jobs')[job_name]
       visit page_with_token 'active', '/jobs/'+job['uuid']
 
-      assert_selector 'a,button', text: 'Re-run same version'
       if expect_options
         assert_text 'supplied_script_version: master'
-        assert_selector 'a,button', text: 'Re-run with options'
       else
         assert_text 'supplied_script_version: (none)'
-        assert_no_selector 'a,button', text: 'Re-run with options'
       end
 
-      # Now re-run the job
-      if use_options
-        assert_triggers_dom_event 'shown.bs.modal' do
-          find('a,button', text: 'Re-run with options...').click
-        end
-        within('.modal-dialog') do
-          assert_selector 'a,button', text: 'Run now'
-          assert_selector 'a,button', text: 'Cancel'
-          page.choose('use_script_same') if click_option
-          find('button', text: 'Run now').click
-        end
-      else
-        find('a,button', text: 'Re-run same version').click
+      assert_triggers_dom_event 'shown.bs.modal' do
+        find('a,button', text: 'Re-run job...').click
+      end
+      within('.modal-dialog') do
+        assert_selector 'a,button', text: 'Run now'
+        assert_selector 'a,button', text: 'Cancel'
+        page.choose('script_use_latest') if use_latest
+        find('button', text: 'Run now').click
       end
 
-      # We see Fiddlesticks, but let's make sure the correct script version is sought.
-      if use_options && !click_option
+      # Re-run job does not actually work and we see Fiddlesticks.
+      # So, let's make sure the correct script version is sought.
+      if expect_options && use_latest
         assert_text "Script version #{job['supplied_script_version']} does not resolve to a commit"
       else
         assert_text "Script version #{job['script_version']} does not resolve to a commit"
index efc2539e7070d14efbd1c25c79a8838398bdd518..45398f909640b0c2623a9a59c0723cba9341590a 100644 (file)
@@ -122,13 +122,13 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     visit(page_with_token("admin", "/jobs/#{p.uuid}"))
 
     assert_no_text 'complete'
-    assert_no_text 'Re-run same version'
+    assert_no_text 'Re-run job'
 
     p.state = "Complete"
     p.save!
 
     assert_text 'complete'
-    assert_text 'Re-run same version'
+    assert_text 'Re-run job'
 
     Thread.current[:arvados_api_token] = nil
   end
index 2243339b75eb92e9649eff0b48d7c10439de1a40..a922a8bd1f8ce363e212d843f169b748398212ad 100644 (file)
@@ -76,6 +76,8 @@ foobar:
   cancelled_at: ~
   cancelled_by_user_uuid: ~
   cancelled_by_client_uuid: ~
+  script: hash
+  repository: foo
   script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
   script_parameters:
     input: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45