[ui] When a job is deleted in the background, wait until redirect before cache unload (#23492)

* Wait until the job page is moved-off before unloading the job from ember data cache

* handle transitionAborted error
This commit is contained in:
Phil Renaud
2024-07-04 17:04:30 -04:00
committed by GitHub
parent 441f8f21ff
commit 7cf6332632
2 changed files with 20 additions and 10 deletions

3
.changelog/23492.txt Normal file
View File

@@ -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
```

View File

@@ -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;
}
}
}
}