fix: resolve parent on job still issue with alloc job async relationship
This commit is contained in:
parent
e957e5b7d7
commit
f7602d9a2a
|
@ -1,19 +1,34 @@
|
|||
<Trigger @do={{this.fetchParent}} as |trigger|>
|
||||
{{did-insert trigger.fns.do}}
|
||||
{{#if trigger.data.result}}
|
||||
{{#if trigger.data.isBusy}}
|
||||
<li>
|
||||
<LinkTo @params={{trigger.data.result.args}} data-test-breadcrumb={{@crumb.args.firstObject}}>
|
||||
{{trigger.data.result.label}}
|
||||
<a href="#" aria-label="loading" data-test-breadcrumb="loading">
|
||||
…
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if trigger.data.isSuccess}}
|
||||
{{#if trigger.data.result}}
|
||||
<li>
|
||||
<LinkTo
|
||||
@route="jobs.job.index"
|
||||
@model={{trigger.data.result.plainId}}
|
||||
@query={{hash namespace=(or trigger.data.result.namespace.name "default")}}
|
||||
data-test-breadcrumb={{@crumb.args.firstObject}}
|
||||
>
|
||||
{{trigger.data.result.trimmedName}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
<LinkTo
|
||||
@route="jobs.job.index"
|
||||
@model={{this.job.plainId}}
|
||||
@query={{hash namespace=(or this.job.namespace.name "default")}}
|
||||
data-test-breadcrumb={{@crumb.args.firstObject}}
|
||||
>
|
||||
{{this.job.trimmedName}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
<LinkTo
|
||||
@route={{@crumbs.args}}
|
||||
data-test-breadcrumb={{@crumb.args.firstObject}}
|
||||
{{!-- @model={{trigger.data.result}} FIX THIS PARAMETER --}}
|
||||
>
|
||||
{{this.crumb.label}}
|
||||
</LinkTo>
|
||||
</li>
|
||||
</Trigger>
|
|
@ -1,36 +1,16 @@
|
|||
import { action } from '@ember/object';
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
|
||||
|
||||
export default class BreadcrumbsJob extends Component {
|
||||
get job() {
|
||||
return this.args.crumb.job;
|
||||
}
|
||||
|
||||
@tracked parent = null;
|
||||
|
||||
generateCrumb(job) {
|
||||
return {
|
||||
label: job.get('trimmedName') || job.trimmedName,
|
||||
args: [
|
||||
'jobs.job.index',
|
||||
job.get('plainId') || job.plainId,
|
||||
qpBuilder({
|
||||
jobNamespace: job.get('namespace.name') || 'default',
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
get crumb() {
|
||||
if (!this.job) return null;
|
||||
return this.generateCrumb(this.job);
|
||||
}
|
||||
|
||||
@action
|
||||
fetchParent() {
|
||||
this.parent = this.job.parent || this.job.get('parent');
|
||||
return this.generateCrumb(this.parent);
|
||||
const hasParent = !!this.job.belongsTo('parent').id();
|
||||
if (hasParent) {
|
||||
return this.job.get('parent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,7 @@
|
|||
<Breadcrumbs as |bb|>
|
||||
{{#each bb as |breadcrumb index|}}
|
||||
{{#each bb as |breadcrumb|}}
|
||||
{{#each breadcrumb.args.crumb as |b|}}
|
||||
{{#if b.isPending}}
|
||||
<li class="{{if (eq (inc index) this.b.length) "is-active"}}">
|
||||
<a href="#" aria-label="loading" data-test-breadcrumb="loading">
|
||||
…
|
||||
</a>
|
||||
</li>
|
||||
{{else}}
|
||||
{{component (concat "breadcrumbs/" (or b.type "default")) crumb=b}}
|
||||
{{/if}}
|
||||
{{component (concat "breadcrumbs/" (or b.type "default")) crumb=b}}
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
</Breadcrumbs>
|
Loading…
Reference in a new issue