mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
d53ef125e0
no issue - updates `package.json` details to better reflect the separation from the `Ghost` package - update ember config and all import statements to reflect the new `ghost-admin` module name in `package.json`
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
|
|
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
|
|
import styleBody from 'ghost-admin/mixins/style-body';
|
|
import NotFoundHandler from 'ghost-admin/mixins/404-handler';
|
|
|
|
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, NotFoundHandler, {
|
|
titleToken: 'Team - User',
|
|
|
|
classNames: ['team-view-user'],
|
|
|
|
model(params) {
|
|
return this.store.queryRecord('user', {slug: params.user_slug, include: 'count.posts'});
|
|
},
|
|
|
|
serialize(model) {
|
|
return {user_slug: model.get('slug')};
|
|
},
|
|
|
|
afterModel(user) {
|
|
this._super(...arguments);
|
|
|
|
return this.get('session.user').then((currentUser) => {
|
|
let isOwnProfile = user.get('id') === currentUser.get('id');
|
|
let isAuthor = currentUser.get('isAuthor');
|
|
let isEditor = currentUser.get('isEditor');
|
|
|
|
if (isAuthor && !isOwnProfile) {
|
|
this.transitionTo('team.user', currentUser);
|
|
} else if (isEditor && !isOwnProfile && !user.get('isAuthor')) {
|
|
this.transitionTo('team');
|
|
}
|
|
});
|
|
},
|
|
|
|
deactivate() {
|
|
let model = this.modelFor('team.user');
|
|
|
|
// we want to revert any unsaved changes on exit
|
|
if (model && model.get('hasDirtyAttributes')) {
|
|
model.rollbackAttributes();
|
|
}
|
|
|
|
model.get('errors').clear();
|
|
|
|
this._super(...arguments);
|
|
},
|
|
|
|
actions: {
|
|
didTransition() {
|
|
this.modelFor('team.user').get('errors').clear();
|
|
},
|
|
|
|
save() {
|
|
this.get('controller').send('save');
|
|
}
|
|
}
|
|
});
|