github.com/hernad/nomad@v1.6.112/ui/app/routes/policies.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 withForbiddenState from 'nomad-ui/mixins/with-forbidden-state'; 8 import WithModelErrorHandling from 'nomad-ui/mixins/with-model-error-handling'; 9 import { inject as service } from '@ember/service'; 10 import { hash } from 'rsvp'; 11 12 export default class PoliciesRoute extends Route.extend( 13 withForbiddenState, 14 WithModelErrorHandling 15 ) { 16 @service can; 17 @service store; 18 @service router; 19 20 beforeModel() { 21 if (this.can.cannot('list policies')) { 22 this.router.transitionTo('/jobs'); 23 } 24 } 25 26 async model() { 27 return await hash({ 28 policies: this.store.query('policy', { reload: true }), 29 tokens: 30 this.can.can('list tokens') && 31 this.store.query('token', { reload: true }), 32 }); 33 } 34 }