github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/acls/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 6 import WithAclActions from 'consul-ui/mixins/acl/with-actions'; 7 8 export default Route.extend(WithAclActions, { 9 repo: service('repository/acl'), 10 settings: service('settings'), 11 queryParams: { 12 s: { 13 as: 'filter', 14 replace: true, 15 }, 16 }, 17 beforeModel: function(transition) { 18 return get(this, 'settings') 19 .findBySlug('token') 20 .then(token => { 21 // If you don't have a token set or you have a 22 // token set with AccessorID set to not null (new ACL mode) 23 // then rewrite to the new acls 24 if (!token || get(token, 'AccessorID') !== null) { 25 // If you return here, you get a TransitionAborted error in the tests only 26 // everything works fine either way checking things manually 27 this.replaceWith('dc.acls.tokens'); 28 } 29 }); 30 }, 31 model: function(params) { 32 return hash({ 33 isLoading: false, 34 items: get(this, 'repo').findAllByDatacenter(this.modelFor('dc').dc.Name), 35 token: get(this, 'settings').findBySlug('token'), 36 }); 37 }, 38 setupController: function(controller, model) { 39 this._super(...arguments); 40 controller.setProperties(model); 41 }, 42 });