Ghost/ghost/admin/app/routes/members.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-01-22 19:23:26 +03:00
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import {inject as service} from '@ember/service';
export default class MembersRoute extends AuthenticatedRoute {
@service store;
2019-01-22 19:23:26 +03:00
queryParams = {
label: {refreshModel: true},
searchParam: {refreshModel: true, replace: true},
paidParam: {refreshModel: true},
orderParam: {refreshModel: true}
};
2019-01-22 19:23:26 +03:00
// redirect to posts screen if:
// - TODO: members is disabled?
// - logged in user isn't owner/admin
beforeModel() {
super.beforeModel(...arguments);
2019-01-22 19:23:26 +03:00
return this.session.user.then((user) => {
if (!user.isOwnerOrAdmin) {
return this.transitionTo('home');
2019-01-22 19:23:26 +03:00
}
});
}
model(params) {
return this.controllerFor('members').fetchMembersTask.perform(params);
}
// trigger a background load of members plus labels for filter dropdown
setupController(controller) {
super.setupController(...arguments);
controller.fetchLabelsTask.perform();
}
buildRouteInfoMetadata() {
return {
titleToken: 'Members'
};
2019-01-22 19:23:26 +03:00
}
}