github.com/hernad/nomad@v1.6.112/ui/app/routes/jobs/job/dispatch.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Route from '@ember/routing/route'; 7 import { inject as service } from '@ember/service'; 8 9 export default class DispatchRoute extends Route { 10 @service can; 11 12 beforeModel() { 13 const job = this.modelFor('jobs.job'); 14 const namespace = job.namespace.get('name'); 15 if (this.can.cannot('dispatch job', null, { namespace })) { 16 this.transitionTo('jobs.job'); 17 } 18 } 19 20 model() { 21 const job = this.modelFor('jobs.job'); 22 if (!job) return this.transitionTo('jobs.job'); 23 return job; 24 } 25 }