Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2133bcf

Browse files
committedOct 31, 2024·
Redirect to index page by status when discarding a job
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.
1 parent 04d66fd commit 2133bcf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎app/controllers/mission_control/jobs/discards_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ class MissionControl::Jobs::DiscardsController < MissionControl::Jobs::Applicati
33

44
def create
55
@job.discard
6-
redirect_back fallback_location: application_jobs_url(@application, :failed), notice: "Discarded job with id #{@job.job_id}"
6+
redirect_to redirect_location, notice: "Discarded job with id #{@job.job_id}"
77
end
88

99
private
1010
def jobs_relation
1111
ActiveJob.jobs.failed
1212
end
13+
14+
def redirect_location
15+
status = @job.status.presence_in(supported_job_statuses) || :failed
16+
application_jobs_url(@application, status)
17+
end
1318
end

0 commit comments

Comments
 (0)
Please sign in to comment.