From 7cf63326322c92074dab53321c32ddee92627bcd Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 4 Jul 2024 17:04:30 -0400 Subject: [PATCH] [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 --- .changelog/23492.txt | 3 +++ ui/app/controllers/jobs/job.js | 27 +++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .changelog/23492.txt diff --git a/.changelog/23492.txt b/.changelog/23492.txt new file mode 100644 index 000000000..e6538f39e --- /dev/null +++ b/.changelog/23492.txt @@ -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 +``` diff --git a/ui/app/controllers/jobs/job.js b/ui/app/controllers/jobs/job.js index f1212e764..393ee2565 100644 --- a/ui/app/controllers/jobs/job.js +++ b/ui/app/controllers/jobs/job.js @@ -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; + } } } }