refact: upgrade Promise.then to async/await (#14798)

* refact: upgrade Promise.then to async/await

* naive solution (#14800)

* refact: use id instead of model

* chore:  add changelog entry

* refact: add conditional safety around alloc
This commit is contained in:
Jai 2022-10-20 14:25:41 -04:00 committed by GitHub
parent 0fddb4d7e8
commit 08fde3a4ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

3
.changelog/14798.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug-fix
ui: always show ports on allocations page
```

View File

@ -36,18 +36,18 @@ export default class AllocationRoute extends Route.extend(WithWatchers) {
} }
} }
model() { async model() {
// Preload the job for the allocation since it's required for the breadcrumb trail try {
return super // Preload the job for the allocation since it's required for the breadcrumb trail
.model(...arguments) const allocation = await super.model(...arguments);
.then((allocation) => { const jobId = allocation?.belongsTo('job').id();
const jobId = allocation.belongsTo('job').id(); const getJob = this.store.findRecord('job', jobId);
return this.store const getNamespaces = this.store.findAll('namespace');
.findRecord('job', jobId) await Promise.all([getJob, getNamespaces]);
.then(() => this.store.findAll('namespace')) // namespaces belong to a job and are an asynchronous relationship so we can peak them later on return allocation;
.then(() => allocation); } catch {
}) notifyError(this);
.catch(notifyError(this)); }
} }
@watchRecord('allocation') watch; @watchRecord('allocation') watch;

View File

@ -33,7 +33,7 @@
<td data-test-short-id> <td data-test-short-id>
<LinkTo <LinkTo
@route="allocations.allocation" @route="allocations.allocation"
@model={{this.allocation}} @model={{this.allocation.id}}
class="is-primary" class="is-primary"
> >
{{this.allocation.shortId}} {{this.allocation.shortId}}