Skip to content

Commit

Permalink
Add confirmation dialog for enqueuing disabled jobs to ensure consist…
Browse files Browse the repository at this point in the history
…ent behavior and Refactor URL encoding by storing CGI.escape and gsub result in a variable (#482)
  • Loading branch information
satyakampandya authored Sep 12, 2024
1 parent b090aa9 commit cbec90b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/sidekiq/cron/views/cron.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@
<tbody>
<% @cron_jobs.sort{ |a,b| a.sort_name <=> b.sort_name }.each do |job| %>
<% klass = (job.status == 'disabled') ? 'bg-danger text-muted' : '' %>
<% escaped_job_name = CGI.escape(job.name).gsub('+', '%20') %>
<tr>
<td class="<%= klass %>"><%= t job.status %></td>
<td class="<%= klass %>">
<a href="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>" title="<%= job.description %>">
<a href="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>" title="<%= job.description %>">
<b class="<%= klass %>"><%= job.name %></b>
</a>
<br/>
Expand All @@ -79,24 +80,24 @@
<td class="<%= klass %>"><%= job.last_enqueue_time ? relative_time(job.last_enqueue_time) : "-" %></td>
<td class="<%= klass %>">
<% if job.status == 'enabled' %>
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>/enque" method="post">
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>/enque" method="post">
<%= csrf_tag if respond_to?(:csrf_tag) %>
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
</form>
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>/disable" method="post">
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>/disable" method="post">
<%= csrf_tag if respond_to?(:csrf_tag) %>
<input class='btn btn-warn btn-xs pull-left' type="submit" name="disable" value="<%= t('Disable') %>"/>
</form>
<% else %>
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>/enque" method="post">
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>/enque" method="post">
<%= csrf_tag if respond_to?(:csrf_tag) %>
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>"/>
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>" data-confirm="<%= t('AreYouSureEnqueueCronJob', :job => job.name) %>"/>
</form>
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>/enable" method="post">
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>/enable" method="post">
<%= csrf_tag if respond_to?(:csrf_tag) %>
<input class='btn btn-warn btn-xs pull-left' type="submit" name="enable" value="<%= t('Enable') %>"/>
</form>
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= CGI.escape(job.name).gsub('+', '%20') %>/delete" method="post">
<form action="<%= root_path %>cron/namespaces/<%= @current_namespace %>/jobs/<%= escaped_job_name %>/delete" method="post">
<%= csrf_tag if respond_to?(:csrf_tag) %>
<input class='btn btn-xs btn-danger pull-left help-block' type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => job.name) %>"/>
</form>
Expand Down

0 comments on commit cbec90b

Please sign in to comment.