def show_pane_list
%w(Status Log Details Provenance Advanced)
end
+
+ def rerun_job_with_options_popup
+ respond_to do |format|
+ format.js
+ format.html
+ end
+ end
+
+ def rerun_job_with_options
+ 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']
+
+ if params['use_script'] == 'latest'
+ @object.script_version = job_info['supplied_script_version']
+ else
+ @object.script_version = job_info['script_version']
+ end
+
+ @object.save!
+ show
+ end
end
--- /dev/null
+<%
+ job_info = {}
+ job_info['script'] = params[:script]
+ job_info['script_version'] = params[:script_version]
+ job_info['repository'] = params[:repository]
+ job_info['supplied_script_version'] = params[:supplied_script_version]
+ job_info['nondeterministic'] = params[:nondeterministic]
+ job_info['script_parameters'] = params[:script_parameters]
+ job_info['runtime_constraints'] = params[:runtime_constraints]
+%>
+
+<div class="modal fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <%= form_tag rerun_job_with_options_path do |f| %>
+ <div class="modal-header">
+ <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">×</button>
+ <div>
+ <div class="col-sm-6"> <h4 class="modal-title">Re-run job</h4> </div>
+ </div>
+ <br/>
+ </div>
+
+ <div class="modal-body">
+ <p> If this job is part of a pipeline, that pipeline would not know about the new job you are running.
+ If you want to update your pipeline results, please re-run the pipeline instead.
+ <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") %>
+ <%= 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>
+ <input type="hidden" name="job_info" value="<%=job_info.to_json%>">
+ </div>
+ </div>
+
+ <div class="modal-footer">
+ <button type="submit" class="btn btn-primary" name="rerun-with-options" value="RunningOnServer">Run now</button>
+ <button class="btn btn-default" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">Cancel</button>
+ </div>
+ <% end %>
+ </div>
+ </div>
+</div>
<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%>
- <%= form_tag '/jobs', style: "display:inline" do |f| %>
- <% [:script, :repository, :supplied_script_version, :nondeterministic].each do |d| %>
- <%= hidden_field :job, d, :value => @object[d] %>
- <% end %>
- <%= hidden_field :job, :script_version, :value => @object[:supplied_script_version] %>
- <% [: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-latest-job-button",
- title: 'Re-run job using the latest script version'}) do%>
- <i class="fa fa-fw fa-gear"></i> Re-run latest version
+ <% 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 %>
<% end %>
- <% end %>
<% end %>
--- /dev/null
+$("#rerun-job-with-options-popup").html("<%= escape_javascript(render partial: 'rerun_job_with_options_popup') %>");
+$("#rerun-job-with-options-popup .modal").modal('show');
<%= render partial: 'title_and_buttons' %>
<%= render partial: 'content', layout: 'content_layout', locals: {pane_list: controller.show_pane_list }%>
+<div id="rerun-job-with-options-popup"></div>
get "users/setup" => 'users#setup', :as => :setup_user
get "report_issue_popup" => 'actions#report_issue_popup', :as => :report_issue_popup
post "report_issue" => 'actions#report_issue', :as => :report_issue
+ get "rerun-job-with-options-popup" => 'jobs#rerun_job_with_options_popup', :as => :rerun_job_with_options_popup
+ post "rerun-job-with-options" => 'jobs#rerun_job_with_options', :as => :rerun_job_with_options
resources :nodes
resources :humans
resources :traits
wait_for_ajax
assert page.has_text? 'Showing only 100 bytes of this log'
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|
+ test "Rerun #{job_name} job, expect options #{expect_options},
+ use options #{use_options} and click option #{click_option}" 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
+ end
+
+ # We see Fiddlesticks, but let's make sure the correct script version is sought.
+ if use_options && !click_option
+ 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"
+ end
+ end
+ end
end
input2: "stuff2"
output: ea10d51bcf88862dbcc36eb292017dfd+45
+job_with_latest_version:
+ uuid: zzzzz-8i9sb-nj8ioxnrvjtyk2b
+ owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+ cancelled_at: ~
+ cancelled_by_user_uuid: ~
+ cancelled_by_client_uuid: ~
+ script: hash
+ repository: foo
+ script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250
+ supplied_script_version: master
+ script_parameters:
+ input: 1f4b0bc7583c2a7f9102c395f4ffc5e3+45
+ created_at: <%= 4.minute.ago.to_s(:db) %>
+ started_at: <%= 3.minute.ago.to_s(:db) %>
+ finished_at: <%= 2.minute.ago.to_s(:db) %>
+ running: false
+ success: true
+ output: fa7aeb5140e2848d39b416daeef4ffc5+45
+ priority: 0
+ log: ea10d51bcf88862dbcc36eb292017dfd+45
+ is_locked_by_uuid: ~
+ tasks_summary:
+ failed: 0
+ todo: 0
+ running: 0
+ done: 1
+ runtime_constraints: {}
+ state: Complete
# Test Helper trims the rest of the file