Skip to content

Commit

Permalink
Redirect to index page by status when discarding a job
Browse files Browse the repository at this point in the history
This is a follow-up to #157, which redirected back after discarding
instead of redirecting to the failed job page always, since you can
discard a job from the scheduled jobs page as well. However, this
doesn't work in the case of discarding a job from its individual page,
because in that case we'd try to redirect to the job, and the job no
longer exists, which results in a 404.

With this change, we just redirect to wherever the status of the
discarded job is.
  • Loading branch information
rosa committed Oct 31, 2024
1 parent 04d66fd commit 2e2af60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/mission_control/jobs/discards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ class MissionControl::Jobs::DiscardsController < MissionControl::Jobs::Applicati

def create
@job.discard
redirect_back fallback_location: application_jobs_url(@application, :failed), notice: "Discarded job with id #{@job.job_id}"
redirect_to redirect_location, notice: "Discarded job with id #{@job.job_id}"
end

private
def jobs_relation
ActiveJob.jobs.failed
end

def redirect_location
status = @job.status.presence_in(supported_job_statuses) || :failed
application_jobs_url(@application, status)
end
end

0 comments on commit 2e2af60

Please sign in to comment.