-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolve parent on job still issue with alloc job async relationship
- Loading branch information
1 parent
5a1df04
commit e94a979
Showing
3 changed files
with
33 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |