Skip to content

Commit

Permalink
Backport of refact: upgrade Promise.then to async/await into release/…
Browse files Browse the repository at this point in the history
…1.3.x (#14990)

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core committed Oct 20, 2022
1 parent 7996f64 commit b5a8059
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .changelog/14798.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug-fix
ui: always show ports on allocations page
```
24 changes: 12 additions & 12 deletions ui/app/routes/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ export default class AllocationRoute extends Route.extend(WithWatchers) {
}
}

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

@watchRecord('allocation') watch;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/templates/components/allocation-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<td data-test-short-id>
<LinkTo
@route="allocations.allocation"
@model={{this.allocation}}
@model={{this.allocation.id}}
class="is-primary"
>
{{this.allocation.shortId}}
Expand Down

0 comments on commit b5a8059

Please sign in to comment.