github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/acls/tokens/index.js (about) 1 import Route from '@ember/routing/route'; 2 import { inject as service } from '@ember/service'; 3 import { hash } from 'rsvp'; 4 import { get } from '@ember/object'; 5 import WithTokenActions from 'consul-ui/mixins/token/with-actions'; 6 export default Route.extend(WithTokenActions, { 7 repo: service('repository/token'), 8 settings: service('settings'), 9 queryParams: { 10 s: { 11 as: 'filter', 12 replace: true, 13 }, 14 }, 15 beforeModel: function(transition) { 16 return get(this, 'settings') 17 .findBySlug('token') 18 .then(token => { 19 // If you have a token set with AccessorID set to null (legacy mode) 20 // then rewrite to the old acls 21 if (token && get(token, 'AccessorID') === null) { 22 // If you return here, you get a TransitionAborted error in the tests only 23 // everything works fine either way checking things manually 24 this.replaceWith('dc.acls'); 25 } 26 }); 27 }, 28 model: function(params) { 29 const repo = get(this, 'repo'); 30 return hash({ 31 ...repo.status({ 32 items: repo.findAllByDatacenter(this.modelFor('dc').dc.Name), 33 }), 34 isLoading: false, 35 token: get(this, 'settings').findBySlug('token'), 36 }); 37 }, 38 setupController: function(controller, model) { 39 this._super(...arguments); 40 controller.setProperties(model); 41 }, 42 });