mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
refact: preserve promise.then behavior for acceptance tests (#15003)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user