diff --git a/app/assets/javascripts/discourse/components/topic-status.js.es6 b/app/assets/javascripts/discourse/components/topic-status.js.es6 index 606471b4e..83ce68493 100644 --- a/app/assets/javascripts/discourse/components/topic-status.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-status.js.es6 @@ -29,11 +29,16 @@ export default Ember.Component.extend({ }); }, + canAct: function() { + return Discourse.User.current() && !this.get('disableActions'); + }.property('disableActions'), + render: function(buffer) { if (!this.get('hasDisplayableStatus')) { return; } - var self = this, - renderIconIf = function(conditionProp, name, key, actionable) { + var self = this; + + var renderIconIf = function(conditionProp, name, key, actionable) { if (!self.get(conditionProp)) { return; } var title = I18n.t("topic_statuses." + key + ".help"); @@ -47,12 +52,10 @@ export default Ember.Component.extend({ // Allow a plugin to add a custom icon to a topic this.trigger('addCustomIcon', buffer); - var togglePin = function () {}; - renderIconIf('topic.closed', 'lock', 'locked'); renderIconIf('topic.archived', 'lock', 'archived'); - renderIconIf('topic.pinned', 'thumb-tack', 'pinned', togglePin); - renderIconIf('topic.unpinned', 'thumb-tack unpinned', 'unpinned', togglePin); + renderIconIf('topic.pinned', 'thumb-tack', 'pinned', self.get("canAct") ); + renderIconIf('topic.unpinned', 'thumb-tack unpinned', 'unpinned', self.get("canAct")); renderIconIf('topic.invisible', 'eye-slash', 'invisible'); } }); diff --git a/app/assets/javascripts/discourse/controllers/search.js.es6 b/app/assets/javascripts/discourse/controllers/search.js.es6 index 97ed1fdcb..f171a112d 100644 --- a/app/assets/javascripts/discourse/controllers/search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/search.js.es6 @@ -1,4 +1,4 @@ -export default Em.ArrayController.extend(Discourse.Presence, { +export default Em.Controller.extend(Discourse.Presence, { contextChanged: function(){ if(this.get('searchContextEnabled')){ @@ -35,7 +35,7 @@ export default Em.ArrayController.extend(Discourse.Presence, { this.set('loading', true); this.searchTerm(term, this.get('typeFilter')); } else { - this.setProperties({ content: [], resultCount: 0, urls: [] }); + this.setProperties({ content: null, resultCount: 0, urls: [] }); } this.set('selectedIndex', 0); }.observes('term', 'typeFilter'), @@ -55,7 +55,6 @@ export default Em.ArrayController.extend(Discourse.Presence, { }).then(function(results) { var urls = []; if (results) { - self.set('noResults', results.length === 0); var topicMap = {}; results.topics = results.topics.map(function(topic){ @@ -98,16 +97,17 @@ export default Em.ArrayController.extend(Discourse.Presence, { } }); - console.log(results) - - self.setProperties({ resultCount: urls.length, content: results, urls: urls }); + var noResults = urls.length === 0; + self.setProperties({ noResults: noResults, + resultCount: urls.length, + content: noResults ? null : Em.Object.create(results), + urls: urls }); } - self.set('loading', false); }).catch(function() { self.set('loading', false); }); - }, 300), + }, 400), showCancelFilter: function() { if (this.get('loading')) return false; diff --git a/app/assets/javascripts/discourse/templates/search.js.handlebars b/app/assets/javascripts/discourse/templates/search.js.handlebars index 3c5d20f81..aec7c6b53 100644 --- a/app/assets/javascripts/discourse/templates/search.js.handlebars +++ b/app/assets/javascripts/discourse/templates/search.js.handlebars @@ -12,7 +12,7 @@ {{#unless noResults}} {{#each resultType in content.resultTypes}}