mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
3cc10bfa83
no issue - ran [`ember-native-class-codemod`](https://github.com/ember-codemods/ember-native-class-codemod) on members-related files - updated files to remove need for `@classic` decorator where possible - switched to tracked properties - removed usage of `this.get/set/toggleProperty` etc - swapped usage of `{{action 'foo'}}` for `{{this.foo}}`
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
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 labels for filter dropdown
|
|
setupController(controller) {
|
|
super.setupController(...arguments);
|
|
controller.fetchMembersTask.perform();
|
|
if (!controller.hasLoadedLabels) {
|
|
this.store.query('label', {limit: 'all'}).then(() => {
|
|
controller.hasLoadedLabels = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
deactivate() {
|
|
super.deactivate(...arguments);
|
|
this.controller.modalLabel && this.controller.modalLabel.rollbackAttributes();
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Members'
|
|
};
|
|
}
|
|
}
|