From e97cb20c2a5601d5ca7e6e9f23c2d7138539b2d8 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 20 May 2020 16:46:49 +1000 Subject: [PATCH] UX: strip text from PM bookmark and share buttons Also organize priorities in an easier to reason about way and shift bookmark topic so it is after link. (consistent with posts) --- .../app/initializers/topic-footer-buttons.js | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js b/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js index a13ccd2219f..e00c947310e 100644 --- a/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js +++ b/app/assets/javascripts/discourse/app/initializers/topic-footer-buttons.js @@ -3,6 +3,13 @@ import showModal from "discourse/lib/show-modal"; import { registerTopicFooterButton } from "discourse/lib/register-topic-footer-button"; import { formattedReminderTime } from "discourse/lib/bookmark"; +const SHARE_PRIORITY = 1000; +const BOOKMARK_PRIORITY = 900; +const ARCHIVE_PRIORITY = 800; +const FLAG_PRIORITY = 700; +const EDIT_MESSAGE_PRIORITY = 600; +const DEFER_PRIORITY = 500; + export default { name: "topic-footer-buttons", @@ -11,8 +18,12 @@ export default { registerTopicFooterButton({ id: "share-and-invite", icon: "link", - priority: 999, - label: "topic.share.title", + priority: SHARE_PRIORITY, + label() { + if (!this.get("topic.isPrivateMessage") || this.site.mobileView) { + return "topic.share.title"; + } + }, title: "topic.share.help", action() { const panels = [ @@ -67,7 +78,7 @@ export default { registerTopicFooterButton({ id: "flag", icon: "flag", - priority: 998, + priority: FLAG_PRIORITY, label: "topic.flag_topic.title", title: "topic.flag_topic.help", action: "showFlagTopic", @@ -93,14 +104,16 @@ export default { } return "bookmark"; }, - priority: 1000, + priority: BOOKMARK_PRIORITY, classNames() { const bookmarked = this.get("topic.bookmarked"); return bookmarked ? ["bookmark", "bookmarked"] : ["bookmark"]; }, label() { - const bookmarked = this.get("topic.bookmarked"); - return bookmarked ? "bookmarked.clear_bookmarks" : "bookmarked.title"; + if (!this.get("topic.isPrivateMessage") || this.site.mobileView) { + const bookmarked = this.get("topic.bookmarked"); + return bookmarked ? "bookmarked.clear_bookmarks" : "bookmarked.title"; + } }, translatedTitle() { const bookmarked = this.get("topic.bookmarked"); @@ -126,7 +139,7 @@ export default { registerTopicFooterButton({ id: "archive", - priority: 996, + priority: ARCHIVE_PRIORITY, icon() { return this.archiveIcon; }, @@ -155,7 +168,7 @@ export default { registerTopicFooterButton({ id: "edit-message", - priority: 750, + priority: EDIT_MESSAGE_PRIORITY, icon: "pencil-alt", label: "topic.edit_message.title", title: "topic.edit_message.help", @@ -170,7 +183,7 @@ export default { registerTopicFooterButton({ id: "defer", icon: "circle", - priority: 300, + priority: DEFER_PRIORITY, label: "topic.defer.title", title: "topic.defer.help", action: "deferTopic",