mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
f0e359be11
no issue - moved labels fetching into the controller to unify members+labels loading approaches - removed unnecessary `deactivate` hook on members route because the label form component already rolls back the model attributes when it's destroyed - unified non owner/admin redirect approach across members and member routes
36 lines
971 B
JavaScript
36 lines
971 B
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class MembersRoute extends AuthenticatedRoute {
|
|
@service config;
|
|
|
|
queryParams = {
|
|
label: {refreshModel: true}
|
|
};
|
|
|
|
// redirect to posts screen if:
|
|
// - TODO: members is disabled?
|
|
// - logged in user isn't owner/admin
|
|
beforeModel() {
|
|
super.beforeModel(...arguments);
|
|
return this.session.user.then((user) => {
|
|
if (!user.isOwnerOrAdmin) {
|
|
return this.transitionTo('home');
|
|
}
|
|
});
|
|
}
|
|
|
|
// trigger a background load of members plus labels for filter dropdown
|
|
setupController(controller) {
|
|
super.setupController(...arguments);
|
|
controller.fetchMembersTask.perform();
|
|
controller.fetchLabelsTask.perform();
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Members'
|
|
};
|
|
}
|
|
}
|