github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/policies.js (about) 1 import Route from '@ember/routing/route'; 2 import withForbiddenState from 'nomad-ui/mixins/with-forbidden-state'; 3 import WithModelErrorHandling from 'nomad-ui/mixins/with-model-error-handling'; 4 import { inject as service } from '@ember/service'; 5 import { hash } from 'rsvp'; 6 7 export default class PoliciesRoute extends Route.extend( 8 withForbiddenState, 9 WithModelErrorHandling 10 ) { 11 @service can; 12 @service store; 13 @service router; 14 15 beforeModel() { 16 if (this.can.cannot('list policies')) { 17 this.router.transitionTo('/jobs'); 18 } 19 } 20 21 async model() { 22 return await hash({ 23 policies: this.store.query('policy', { reload: true }), 24 tokens: this.store.query('token', { reload: true }), 25 }); 26 } 27 }