2019-01-22 19:23:26 +03:00
|
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
2020-05-20 16:55:41 +03:00
|
|
|
export default class MembersRoute extends AuthenticatedRoute {
|
|
|
|
@service config;
|
2019-01-22 19:23:26 +03:00
|
|
|
|
2020-05-20 16:55:41 +03:00
|
|
|
queryParams = {
|
2020-02-14 12:34:01 +03:00
|
|
|
label: {refreshModel: true}
|
2020-05-20 16:55:41 +03:00
|
|
|
};
|
2020-02-14 12:34:01 +03:00
|
|
|
|
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() {
|
2020-05-20 16:55:41 +03:00
|
|
|
super.beforeModel(...arguments);
|
2019-01-22 19:23:26 +03:00
|
|
|
return this.session.user.then((user) => {
|
|
|
|
if (!user.isOwnerOrAdmin) {
|
2019-03-21 12:33:14 +03:00
|
|
|
return this.transitionTo('home');
|
2019-01-22 19:23:26 +03:00
|
|
|
}
|
|
|
|
});
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|
2019-01-24 22:34:32 +03:00
|
|
|
|
2020-05-20 17:12:48 +03:00
|
|
|
// trigger a background load of members plus labels for filter dropdown
|
2019-01-24 22:34:32 +03:00
|
|
|
setupController(controller) {
|
2020-05-20 16:55:41 +03:00
|
|
|
super.setupController(...arguments);
|
|
|
|
controller.fetchMembersTask.perform();
|
2020-05-20 17:12:48 +03:00
|
|
|
controller.fetchLabelsTask.perform();
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|
|
|
|
|
2019-05-20 18:16:19 +03:00
|
|
|
buildRouteInfoMetadata() {
|
|
|
|
return {
|
|
|
|
titleToken: 'Members'
|
|
|
|
};
|
2019-01-22 19:23:26 +03:00
|
|
|
}
|
2020-05-20 16:55:41 +03:00
|
|
|
}
|