FIX: don't show Create Topic button on full search page to users who can't create topics

This commit is contained in:
Neil Lalonde 2017-11-10 15:38:54 -05:00
parent 4270c93666
commit bd8f8ea1f9
2 changed files with 8 additions and 4 deletions

View File

@ -159,9 +159,9 @@ export default Ember.Controller.extend({
return this.currentUser && this.currentUser.staff && hasResults;
},
@computed('expanded')
canCreateTopic(expanded) {
return this.currentUser && !this.site.mobileView && !expanded;
@computed('expanded', 'model.grouped_search_result.can_create_topic')
canCreateTopic(expanded, userCanCreateTopic) {
return this.currentUser && userCanCreateTopic && !this.site.mobileView && !expanded;
},
@computed('expanded')

View File

@ -3,7 +3,7 @@ class GroupedSearchResultSerializer < ApplicationSerializer
has_many :users, serializer: SearchResultUserSerializer
has_many :categories, serializer: BasicCategorySerializer
has_many :tags, serializer: TagSerializer
attributes :more_posts, :more_users, :more_categories, :term, :search_log_id, :more_full_page_results
attributes :more_posts, :more_users, :more_categories, :term, :search_log_id, :more_full_page_results, :can_create_topic
def search_log_id
object.search_log_id
@ -17,4 +17,8 @@ class GroupedSearchResultSerializer < ApplicationSerializer
SiteSetting.tagging_enabled
end
def can_create_topic
scope.can_create?(Topic)
end
end