From dc477d12284ee7b3792b6f70e225ef264374e6ca Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Wed, 2 Jan 2019 20:15:12 +0100 Subject: [PATCH] FIX: "Toggle topic bump" wasn't visible for TL4 users --- .../components/composer-actions.js.es6 | 5 ++++- .../acceptance/composer-actions-test.js.es6 | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) 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 4bafccc342..dc63706985 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 da25c05343..40fdd40a83 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 => {