Ghost/ghost/admin/app/routes/members.js
Kevin Ansfield 3cc10bfa83 Updated members routes/controllers with Octane idioms
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}}`
2020-05-20 16:39:31 +01:00

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'
};
}
}