github.com/manicqin/nomad@v0.9.5/ui/app/routes/allocations/allocation/task.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Route from '@ember/routing/route';
     3  import EmberError from '@ember/error';
     4  
     5  export default Route.extend({
     6    store: service(),
     7  
     8    breadcrumbs(model) {
     9      if (!model) return [];
    10      return [
    11        {
    12          label: model.get('name'),
    13          args: ['allocations.allocation.task', model.get('allocation'), model],
    14        },
    15      ];
    16    },
    17  
    18    model({ name }) {
    19      const allocation = this.modelFor('allocations.allocation');
    20  
    21      // If there is no allocation, then there is no task.
    22      // Let the allocation route handle the 404 error.
    23      if (!allocation) return;
    24  
    25      const task = allocation.get('states').findBy('name', name);
    26  
    27      if (!task) {
    28        const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`);
    29        err.code = '404';
    30        this.controllerFor('application').set('error', err);
    31      }
    32  
    33      return task;
    34    },
    35  });