2018-10-19 15:17:02 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { hash } from 'rsvp';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
import WithTokenActions from 'consul-ui/mixins/token/with-actions';
|
|
|
|
export default Route.extend(WithTokenActions, {
|
2018-10-26 17:40:51 +00:00
|
|
|
repo: service('repository/token'),
|
2018-10-19 15:17:02 +00:00
|
|
|
settings: service('settings'),
|
|
|
|
queryParams: {
|
|
|
|
s: {
|
|
|
|
as: 'filter',
|
|
|
|
replace: true,
|
|
|
|
},
|
|
|
|
},
|
2018-11-02 14:44:36 +00:00
|
|
|
beforeModel: function(transition) {
|
|
|
|
return get(this, 'settings')
|
|
|
|
.findBySlug('token')
|
|
|
|
.then(token => {
|
|
|
|
// If you have a token set with AccessorID set to null (legacy mode)
|
|
|
|
// then rewrite to the old acls
|
|
|
|
if (token && get(token, 'AccessorID') === null) {
|
|
|
|
// If you return here, you get a TransitionAborted error in the tests only
|
|
|
|
// everything works fine either way checking things manually
|
|
|
|
this.replaceWith('dc.acls');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2018-10-19 15:17:02 +00:00
|
|
|
model: function(params) {
|
|
|
|
const repo = get(this, 'repo');
|
|
|
|
return hash({
|
|
|
|
...repo.status({
|
|
|
|
items: repo.findAllByDatacenter(this.modelFor('dc').dc.Name),
|
|
|
|
}),
|
|
|
|
isLoading: false,
|
|
|
|
token: get(this, 'settings').findBySlug('token'),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
setupController: function(controller, model) {
|
|
|
|
this._super(...arguments);
|
|
|
|
controller.setProperties(model);
|
|
|
|
},
|
|
|
|
});
|