From 59c12ce35bbc15278c3a4ffc5b5876bdd44800a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 16 Sep 2015 08:51:11 +1000 Subject: [PATCH] Stop showing wrench for non admins on topics --- .../discourse/components/show-popup-button.js.es6 | 3 +++ app/assets/javascripts/discourse/templates/topic.hbs | 1 - .../javascripts/discourse/views/topic-footer-buttons.js.es6 | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/show-popup-button.js.es6 b/app/assets/javascripts/discourse/components/show-popup-button.js.es6 index 0f1a40734..0e2447e1d 100644 --- a/app/assets/javascripts/discourse/components/show-popup-button.js.es6 +++ b/app/assets/javascripts/discourse/components/show-popup-button.js.es6 @@ -11,6 +11,9 @@ export default DButton.extend({ top: position.top }; + // TODO views/topic-footer-buttons is instansiating this via attachViewWithArgs + // attachViewWithArgs + this.appEvents = this.appEvents || this.container.lookup('app-events:main'); this.appEvents.trigger("popup-menu:open", loc); this.sendAction("action"); } diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index bb9d85454..da8cb5b85 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -86,7 +86,6 @@ {{#if loadedAllPosts}} {{view "topic-closing" topic=model}} - {{show-popup-button action="showTopicAdminMenu" title="topic_admin_menu" icon="wrench" position="absolute"}} {{view "topic-footer-buttons" topic=model}} {{#if model.pending_posts_count}} diff --git a/app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 b/app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 index 25c9974f7..2467d9a93 100644 --- a/app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-footer-buttons.js.es6 @@ -7,6 +7,7 @@ import ReplyButton from 'discourse/views/reply-button'; import PinnedButton from 'discourse/components/pinned-button'; import TopicNotificationsButton from 'discourse/components/topic-notifications-button'; import DiscourseContainerView from 'discourse/views/container'; +import ShowPopupButton from 'discourse/components/show-popup-button'; const MainPanel = Discourse.ContainerView.extend({ elementId: 'topic-footer-main-buttons', @@ -15,6 +16,11 @@ const MainPanel = Discourse.ContainerView.extend({ init() { this._super(); + if (Discourse.User.currentProp('staff')) { + const viewArgs = {action: 'showTopicAdminMenu', title: 'topic_admin_menu', icon: 'wrench', position: 'absolute'}; + this.attachViewWithArgs(viewArgs, ShowPopupButton); + } + const topic = this.get('topic'); if (!topic.get('isPrivateMessage')) { // We hide some controls from private messages