github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/jobs/job/dispatch.js (about)

     1  import Route from '@ember/routing/route';
     2  import { inject as service } from '@ember/service';
     3  
     4  export default class DispatchRoute extends Route {
     5    @service can;
     6  
     7    beforeModel() {
     8      const job = this.modelFor('jobs.job');
     9      const namespace = job.namespace.get('name');
    10      if (this.can.cannot('dispatch job', null, { namespace })) {
    11        this.transitionTo('jobs.job');
    12      }
    13    }
    14  
    15    model() {
    16      const job = this.modelFor('jobs.job');
    17      if (!job) return this.transitionTo('jobs.job');
    18      return job;
    19    }
    20  }