Skip to content

Commit

Permalink
Fixes #21704 - Prevent user from rerunning a job with missing template
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Aug 2, 2018
1 parent 0441caf commit ca7982f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/models/job_invocation_composer.rb
Expand Up @@ -186,7 +186,8 @@ def params
:concurrency_control => concurrency_control_params,
:execution_timeout_interval => job_invocation.execution_timeout_interval,
:remote_execution_feature_id => job_invocation.remote_execution_feature_id,
:template_invocations => template_invocations_params }.with_indifferent_access
:template_invocations => template_invocations_params,
:reruns => job_invocation.id }.with_indifferent_access
end

private
Expand Down Expand Up @@ -297,6 +298,7 @@ def job_template
end

attr_accessor :params, :job_invocation, :host_ids, :search_query
attr_reader :reruns
delegate :job_category, :remote_execution_feature_id, :pattern_template_invocations, :template_invocations, :targeting, :triggering, :to => :job_invocation

def initialize(params, set_defaults = false)
Expand All @@ -308,6 +310,7 @@ def initialize(params, set_defaults = false)

@host_ids = validate_host_ids(params[:host_ids])
@search_query = job_invocation.targeting.search_query if job_invocation.targeting.bookmark_id.blank?
@reruns = params[:reruns]
end

def self.from_job_invocation(job_invocation, params = {})
Expand Down
10 changes: 8 additions & 2 deletions app/views/job_invocations/_form.html.erb
Expand Up @@ -6,7 +6,13 @@

<%= form_for @composer.job_invocation, :html => {'data-refresh-url' => refresh_job_invocations_path, :id => 'job_invocation_form'} do |f| %>
<%= selectable_f f, :job_category, @composer.available_job_categories, {}, :label => _('Job category') %>
<% if @composer.reruns && @composer.job_invocation.pattern_template_invocations.empty? %>
<%= alert :text => _('Could not rerun job %{id} because its template could not be found') % { :id => @composer.reruns },
:class => 'alert alert-block alert-danger has-error',
:close => false %>
<% end %>
<%= selectable_f f, :job_category, @composer.available_job_categories, {:selected => @composer.job_invocation.job_category, :include_blank => @composer.job_invocation.job_category.nil?}, :label => _('Job category') %>
<%= f.hidden_field(:remote_execution_feature_id, :value => @composer.remote_execution_feature_id) %>
<% selected_templates_per_provider = {} %>
Expand Down Expand Up @@ -116,5 +122,5 @@
<%= render :partial => 'preview_hosts_modal' %>
<%= submit_or_cancel f, false, :cancel_path => job_invocations_path %>
<%= submit_or_cancel f, false, :cancel_path => job_invocations_path, :disabled => @composer.reruns && @composer.job_invocation.pattern_template_invocations.empty? %>
<% end %>

0 comments on commit ca7982f

Please sign in to comment.