FIX: "Toggle topic bump" wasn't visible for TL4 users

FIX: “Toggle topic bump” wasn’t visible for TL4 users

diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js.es6 b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
index 4bafccc..dc63706 100644
--- a/app/assets/javascripts/select-kit/components/composer-actions.js.es6
+++ b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
@@ -193,8 +193,11 @@ export default DropdownSelectBoxComponent.extend({
     }
 
     const currentUser = Discourse.User.current();
+    const showToggleTopicBump =
+      currentUser &&
+      (currentUser.get("staff") || currentUser.trust_level === 4);
 
-    if (action === REPLY && currentUser && currentUser.get("staff")) {
+    if (action === REPLY && showToggleTopicBump) {
       items.push({
         name: I18n.t("composer.composer_actions.toggle_topic_bump.label"),
         description: I18n.t("composer.composer_actions.toggle_topic_bump.desc"),
diff --git a/test/javascripts/acceptance/composer-actions-test.js.es6 b/test/javascripts/acceptance/composer-actions-test.js.es6
index da25c05..40fdd40 100644
--- a/test/javascripts/acceptance/composer-actions-test.js.es6
+++ b/test/javascripts/acceptance/composer-actions-test.js.es6
@@ -291,10 +291,10 @@ QUnit.test("replying to post as staff", async assert => {
   assert.equal(composerActions.rowByIndex(4).value(), "toggle_topic_bump");
 });
 
-QUnit.test("replying to post as regular user", async assert => {
+QUnit.test("replying to post as TL3 user", async assert => {
   const composerActions = selectKit(".composer-actions");
 
-  replaceCurrentUser({ staff: false, admin: false });
+  replaceCurrentUser({ staff: false, admin: false, trust_level: 3 });
   await visit("/t/internationalization-localization/280");
   await click("article#post_3 button.reply");
   await composerActions.expand();
@@ -309,6 +309,18 @@ QUnit.test("replying to post as regular user", async assert => {
   });
 });
 
+QUnit.test("replying to post as TL4 user", async assert => {
+  const composerActions = selectKit(".composer-actions");
+
+  replaceCurrentUser({ staff: false, admin: false, trust_level: 4 });
+  await visit("/t/internationalization-localization/280");
+  await click("article#post_3 button.reply");
+  await composerActions.expand();
+
+  assert.equal(composerActions.rows().length, 4);
+  assert.equal(composerActions.rowByIndex(3).value(), "toggle_topic_bump");
+});
+
 QUnit.test(
   "replying to first post - reply_as_private_message",
   async assert => {

GitHub
sha: dc477d12

2 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there: