Skip to content

Commit

Permalink
backport of commit 7cf6332 (#23507)
Browse files Browse the repository at this point in the history
Co-authored-by: Phil Renaud <[email protected]>
  • Loading branch information
hc-github-team-nomad-core and philrenaud authored Jul 8, 2024
1 parent 89ecbd9 commit 6b4b895
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .changelog/23492.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix an issue where a remotely purged job would prevent redirect from taking place in the web UI
```
27 changes: 17 additions & 10 deletions ui/app/controllers/jobs/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@ export default class JobController extends Controller {
return this.model;
}

@action notFoundJobHandler() {
@action async notFoundJobHandler() {
if (
this.watchers.job.isError &&
this.watchers.job.error?.errors?.some((e) => e.status === '404')
) {
this.notifications.add({
title: `Job "${this.job.name}" has been deleted`,
message:
'The job you were looking at has been deleted; this is usually because it was purged from elsewhere.',
color: 'critical',
sticky: true,
});
this.store.unloadRecord(this.job);
this.router.transitionTo('jobs');
try {
this.notifications.add({
title: `Job "${this.job.name}" has been deleted`,
message:
'The job you were looking at has been deleted; this is usually because it was purged from elsewhere.',
color: 'critical',
sticky: true,
});
await this.router.transitionTo('jobs');
this.store.unloadRecord(this.job);
} catch (err) {
if (err.code === 'TRANSITION_ABORTED') {
return;
}
throw err;
}
}
}
}

0 comments on commit 6b4b895

Please sign in to comment.