diff --git a/app/assets/javascripts/discourse/components/group-member-dropdown.js.es6 b/app/assets/javascripts/discourse/components/group-member-dropdown.js.es6 index 27d9824faf3..92ad1966ec7 100644 --- a/app/assets/javascripts/discourse/components/group-member-dropdown.js.es6 +++ b/app/assets/javascripts/discourse/components/group-member-dropdown.js.es6 @@ -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; } } }); diff --git a/app/assets/javascripts/discourse/controllers/group-index.js.es6 b/app/assets/javascripts/discourse/controllers/group-index.js.es6 index b026ed34208..85155d8a318 100644 --- a/app/assets/javascripts/discourse/controllers/group-index.js.es6 +++ b/app/assets/javascripts/discourse/controllers/group-index.js.es6 @@ -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) { diff --git a/app/assets/javascripts/discourse/models/group.js.es6 b/app/assets/javascripts/discourse/models/group.js.es6 index c26544e7c55..b1780826591 100644 --- a/app/assets/javascripts/discourse/models/group.js.es6 +++ b/app/assets/javascripts/discourse/models/group.js.es6 @@ -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(); }); }, diff --git a/app/assets/javascripts/discourse/templates/group-index.hbs b/app/assets/javascripts/discourse/templates/group-index.hbs index 57f3b503a8c..59cba2ab528 100644 --- a/app/assets/javascripts/discourse/templates/group-index.hbs +++ b/app/assets/javascripts/discourse/templates/group-index.hbs @@ -27,6 +27,8 @@ {{#if canManageGroup}} {{group-member-dropdown removeMember="removeMember" + makeOwner="makeOwner" + removeOwner="removeOwner" member=m}} {{/if}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 909a5524bff..0a60ca08d5a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -466,8 +466,12 @@ en: activity: "Activity" members: title: "Members" - remove_member: "Remove member" + remove_member: "Remove Member" remove_member_description: "Remove %{username} from this group" + make_owner: "Make Owner" + make_owner_description: "Make %{username} an owner of this group" + remove_owner: "Remove as Owner" + remove_owner_description: "Remove %{username} as an owner of this group" topics: "Topics" posts: "Posts" mentions: "Mentions"