FEATURE: Allow admin to manage group owners on group page.

This commit is contained in:
Guo Xiang Tan 2018-03-22 12:33:42 +08:00
parent bfe38b2118
commit 1cc0961566
5 changed files with 49 additions and 6 deletions

View File

@ -8,8 +8,8 @@ export default DropdownButton.extend({
text: iconHTML('ellipsis-h'),
classNames: ['group-member-dropdown'],
@computed()
dropDownContent() {
@computed("member.owner")
dropDownContent(isOwner) {
const items = [
{
id: 'removeMember',
@ -22,6 +22,30 @@ export default DropdownButton.extend({
}
];
if (this.currentUser && this.currentUser.admin) {
if (isOwner) {
items.push({
id: 'removeOwner',
title: I18n.t('groups.members.remove_owner'),
description: I18n.t(
'groups.members.remove_owner_description',
{ username: this.get('member.username') }
),
icon: 'shield'
});
} else {
items.push({
id: 'makeOwner',
title: I18n.t('groups.members.make_owner'),
description: I18n.t(
'groups.members.make_owner_description',
{ username: this.get('member.username') }
),
icon: 'shield'
});
}
}
return items;
},
@ -30,6 +54,12 @@ export default DropdownButton.extend({
case 'removeMember':
this.sendAction('removeMember', this.get('member'));
break;
case 'makeOwner':
this.sendAction('makeOwner', this.get('member.username'));
break;
case 'removeOwner':
this.sendAction('removeOwner', this.get('member'));
break;
}
}
});

View File

@ -41,6 +41,14 @@ export default Ember.Controller.extend({
this.get('model').removeMember(user);
},
makeOwner(username) {
this.get('model').addOwners(username);
},
removeOwner(user) {
this.get('model').removeOwner(user);
},
addMembers() {
const usernames = this.get('usernames');
if (usernames && usernames.length > 0) {

View File

@ -87,12 +87,11 @@ const Group = RestModel.extend({
},
addOwners(usernames) {
var self = this;
return ajax(`/admin/groups/${this.get('id')}/owners.json`, {
type: "PUT",
data: { group: { usernames: usernames } }
}).then(function() {
self.findMembers();
}).then(() => {
this.findMembers();
});
},

View File

@ -27,6 +27,8 @@
{{#if canManageGroup}}
{{group-member-dropdown
removeMember="removeMember"
makeOwner="makeOwner"
removeOwner="removeOwner"
member=m}}
{{/if}}
</td>

View File

@ -466,8 +466,12 @@ en:
activity: "Activity"
members:
title: "Members"
remove_member: "Remove member"
remove_member: "Remove Member"
remove_member_description: "Remove <b>%{username}</b> from this group"
make_owner: "Make Owner"
make_owner_description: "Make <b>%{username}</b> an owner of this group"
remove_owner: "Remove as Owner"
remove_owner_description: "Remove <b>%{username}</b> as an owner of this group"
topics: "Topics"
posts: "Posts"
mentions: "Mentions"