FIX: Group#mentionable and Group#messageable not fully working.

This commit is contained in:
Guo Xiang Tan 2017-10-02 16:50:27 +08:00
parent 4ae3a4e89e
commit 91c5f928c2
5 changed files with 16 additions and 7 deletions

View File

@ -85,7 +85,11 @@ export default Ember.Component.extend({
const $input = this.$('.d-editor-input'); const $input = this.$('.d-editor-input');
$input.autocomplete({ $input.autocomplete({
template: findRawTemplate('user-selector-autocomplete'), template: findRawTemplate('user-selector-autocomplete'),
dataSource: term => userSearch({ term, topicId, includeGroups: true }), dataSource: term => userSearch({
term,
topicId,
includeMentionableGroups: true
}),
key: "@", key: "@",
transformComplete: v => v.username || v.name transformComplete: v => v.username || v.name
}); });

View File

@ -48,9 +48,9 @@ export default Ember.Controller.extend({
}; };
}, },
@computed("model.mentionable") @computed("model.messageable")
displayGroupMessageButton(mentionable) { displayGroupMessageButton(messageable) {
return this.currentUser && mentionable; return this.currentUser && messageable;
}, },
@observes('model.user_count') @observes('model.user_count')

View File

@ -1,5 +1,5 @@
class GroupShowSerializer < BasicGroupSerializer class GroupShowSerializer < BasicGroupSerializer
attributes :is_group_user, :is_group_owner, :mentionable attributes :is_group_user, :is_group_owner, :mentionable, :messageable
def include_is_group_user? def include_is_group_user?
authenticated? authenticated?
@ -21,6 +21,10 @@ class GroupShowSerializer < BasicGroupSerializer
authenticated? authenticated?
end end
def include_messageable?
authenticated?
end
def mentionable def mentionable
Group.mentionable(scope.user).exists?(id: object.id) Group.mentionable(scope.user).exists?(id: object.id)
end end

View File

@ -132,7 +132,7 @@ QUnit.test("Admin Viewing Group", assert => {
andThen(() => { andThen(() => {
assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin'); assert.ok(find(".nav-pills li a[title='Edit Group']").length === 1, 'it should show edit group tab if user is admin');
assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin'); assert.ok(find(".nav-pills li a[title='Logs']").length === 1, 'it should show Logs tab if user is admin');
assert.equal(count('.group-message-button'), 1, 'it displays show group message button');
assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name'); assert.equal(find('.group-info-name').text(), 'Awesome Team', 'it should display the group name');
}); });

View File

@ -12,7 +12,8 @@ export default {
"public_exit":true, "public_exit":true,
"flair_url": 'fa-adjust', "flair_url": 'fa-adjust',
"is_group_owner":true, "is_group_owner":true,
"mentionable":true "mentionable":true,
"messageable":true
} }
}, },
"/groups/discourse/counts.json":{ "/groups/discourse/counts.json":{