Commit 79ecf479 authored by Michael Lange's avatar Michael Lange
Browse files

Make allocation pages extend the job breadcrumb trail

Showing with 57 additions and 8 deletions
+57 -8
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
export default Controller.extend({});
export default Controller.extend({
breadcrumbs: computed('model.job', function() {
return [
{ label: 'Jobs', args: ['jobs'] },
{
label: this.get('model.job.name'),
args: [
'jobs.job',
this.get('model.job'),
qpBuilder({
jobNamespace: this.get('model.namespace.name') || 'default',
}),
],
},
{
label: this.get('model.taskGroupName'),
args: [
'jobs.job.task-group',
this.get('model.job'),
this.get('model.taskGroupName'),
qpBuilder({
jobNamespace: this.get('model.namespace.name') || 'default',
}),
],
},
{
label: this.get('model.shortId'),
args: ['allocations.allocation', this.get('model')],
},
];
}),
});
import { alias } from '@ember/object/computed';
import Controller from '@ember/controller';
import Controller, { inject as controller } from '@ember/controller';
import Sortable from 'nomad-ui/mixins/sortable';
export default Controller.extend(Sortable, {
allocationController: controller('allocations.allocation'),
queryParams: {
sortProperty: 'sort',
sortDescending: 'desc',
......@@ -11,6 +13,8 @@ export default Controller.extend(Sortable, {
sortProperty: 'name',
sortDescending: false,
breadcrumbs: alias('allocationController.breadcrumbs'),
listToSort: alias('model.states'),
sortedStates: alias('listSorted'),
});
import Route from '@ember/routing/route';
import WithModelErrorHandling from 'nomad-ui/mixins/with-model-error-handling';
import { collect } from '@ember/object/computed';
import { watchRecord } from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
import notifyError from 'nomad-ui/utils/notify-error';
export default Route.extend(WithModelErrorHandling, WithWatchers, {
export default Route.extend(WithWatchers, {
startWatchers(controller, model) {
controller.set('watcher', this.get('watch').perform(model));
},
model() {
// Preload the job for the allocation since it's required for the breadcrumb trail
return this._super(...arguments)
.then(allocation => allocation.get('job').then(() => allocation))
.catch(notifyError(this));
},
watch: watchRecord('allocation'),
watchers: collect('watch'),
......
{{#global-header class="page-header"}}
<li><a href="#">Allocations</a></li>
<li class="is-active">
{{#link-to "allocations.allocation" model}}{{model.shortId}}{{/link-to}}
</li>
{{#each breadcrumbs as |breadcrumb index|}}
<li class="{{if (eq (inc index) breadcrumbs.length) "is-active"}}">
{{#link-to
data-test-breadcrumb=breadcrumb.label
params=breadcrumb.args}}
{{breadcrumb.label}}
{{/link-to}}
</li>
{{/each}}
{{/global-header}}
{{#gutter-menu class="page-body"}}
<section class="section">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment