Clean up the remaining routes

This commit is contained in:
Michael Lange
2018-11-05 16:33:33 -08:00
parent 11ba511471
commit 705efadfe7
4 changed files with 16 additions and 9 deletions

View File

@@ -8,7 +8,9 @@ import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils';
export default Route.extend(WithWatchers, {
startWatchers(controller, model) {
controller.set('watcher', this.get('watch').perform(model));
if (model) {
controller.set('watcher', this.get('watch').perform(model));
}
},
// Allocation breadcrumbs extend from job / task group breadcrumbs

View File

@@ -17,16 +17,19 @@ export default Route.extend({
model({ name }) {
const allocation = this.modelFor('allocations.allocation');
if (allocation) {
const task = allocation.get('states').findBy('name', name);
if (task) {
return task;
}
// If there is no allocation, then there is no task.
// Let the allocation route handle the 404 error.
if (!allocation) return;
const task = allocation.get('states').findBy('name', name);
if (!task) {
const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`);
err.code = '404';
this.controllerFor('application').set('error', err);
}
return task;
},
});

View File

@@ -3,6 +3,6 @@ import Route from '@ember/routing/route';
export default Route.extend({
model() {
const task = this._super(...arguments);
return task.get('allocation.node').then(() => task);
return task && task.get('allocation.node').then(() => task);
},
});

View File

@@ -30,8 +30,10 @@ export default Route.extend(WithWatchers, {
},
startWatchers(controller, model) {
controller.set('watchModel', this.get('watch').perform(model));
controller.set('watchAllocations', this.get('watchAllocations').perform(model));
if (model) {
controller.set('watchModel', this.get('watch').perform(model));
controller.set('watchAllocations', this.get('watchAllocations').perform(model));
}
},
watch: watchRecord('node'),