mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 04:31:56 +08:00
FEATURE: Allow admin to manage group owners on group page.
This commit is contained in:
parent
bfe38b2118
commit
1cc0961566
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
{{#if canManageGroup}}
|
||||
{{group-member-dropdown
|
||||
removeMember="removeMember"
|
||||
makeOwner="makeOwner"
|
||||
removeOwner="removeOwner"
|
||||
member=m}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user