From 4076085b7ffe77938b7b80a85937d97bc0bb9e24 Mon Sep 17 00:00:00 2001 From: Jai <41024828+ChaiWithJai@users.noreply.github.com> Date: Mon, 24 Oct 2022 09:04:39 -0400 Subject: [PATCH] refact: preserve promise.then behavior for acceptance tests (#15003) --- ui/app/routes/allocations/allocation.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ui/app/routes/allocations/allocation.js b/ui/app/routes/allocations/allocation.js index 186a26ccc..eb5d80200 100644 --- a/ui/app/routes/allocations/allocation.js +++ b/ui/app/routes/allocations/allocation.js @@ -36,18 +36,18 @@ export default class AllocationRoute extends Route.extend(WithWatchers) { } } - async model() { - try { - // Preload the job for the allocation since it's required for the breadcrumb trail - const allocation = await super.model(...arguments); - const jobId = allocation?.belongsTo('job').id(); - const getJob = this.store.findRecord('job', jobId); - const getNamespaces = this.store.findAll('namespace'); - await Promise.all([getJob, getNamespaces]); - return allocation; - } catch { - notifyError(this); - } + model() { + // Preload the job for the allocation since it's required for the breadcrumb trail + return super + .model(...arguments) + .then((allocation) => { + const jobId = allocation.belongsTo('job').id(); + return this.store + .findRecord('job', jobId) + .then(() => this.store.findAll('namespace')) // namespaces belong to a job and are an asynchronous relationship so we can peak them later on + .then(() => allocation); + }) + .catch(notifyError(this)); } @watchRecord('allocation') watch;