Skip to content

A platform for community discussion. Free, open, simple.

FIX: whisper available when reply to topic (#17054)

Krzysztof Kotlarek63df2b45506b
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
index eb2c6868130..018bdf7b161 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-test.js
@@ -1,5 +1,7 @@
import { click, currentURL, fillIn, settled, visit } from "@ember/test-helpers";
import { toggleCheckDraftPopup } from "discourse/controllers/composer";
+import { cloneJSON } from "discourse-common/lib/object";
+import TopicFixtures from "discourse/tests/fixtures/topic";
import LinkLookup from "discourse/lib/link-lookup";
import { withPluginApi } from "discourse/lib/plugin-api";
import Composer, {
@@ -43,6 +45,11 @@ acceptance("Composer", function (needs) {
max_users_notified_per_group_mention: 100,
});
});
+ server.get("/t/960.json", () => {
+ const topicList = cloneJSON(TopicFixtures["/t/9/1.json"]);
+ topicList.post_stream.posts[2].post_type = 4;
+ return helper.response(topicList);
+ });
});
test("composer controls", async function (assert) {
@@ -573,6 +580,36 @@ acceptance("Composer", function (needs) {
);
});
+ test("Composer can toggle whisper when switching from reply to whisper to reply to topic", async function (assert) {
+ await visit("/t/topic-with-whisper/960");
+
+ await click(".topic-post:nth-of-type(3) button.reply");
+ await click(".reply-details summary div");
+ assert.ok(
+ !exists('.reply-details li[data-value="toggle_whisper"]'),
+ "toggle whisper is not available when reply to whisper"
+ );
+ await click('.reply-details li[data-value="reply_to_topic"]');
+ await click(".reply-details summary div");
+ assert.ok(
+ exists('.reply-details li[data-value="toggle_whisper"]'),
+ "toggle whisper is available when reply to topic"
+ );
+ });
+
+ test("Composer can toggle whisper when clicking reply to topic after reply to whisper", async function (assert) {
+ await visit("/t/topic-with-whisper/960");
+
+ await click(".topic-post:nth-of-type(3) button.reply");
+ await click("#reply-control .save-or-cancel a.cancel");
+ await click(".topic-footer-main-buttons button.create");
+ await click(".reply-details summary div");
+ assert.ok(
+ exists('.reply-details li[data-value="toggle_whisper"]'),
+ "toggle whisper is available when reply to topic"
+ );
+ });
+
test("Composer with dirty reply can toggle to edit", async function (assert) {
await visit("/t/this-is-a-test-topic/9");
diff --git a/app/assets/javascripts/select-kit/addon/components/composer-actions.js b/app/assets/javascripts/select-kit/addon/components/composer-actions.js
index ac8cbb294e0..da00b80e316 100644
--- a/app/assets/javascripts/select-kit/addon/components/composer-actions.js
+++ b/app/assets/javascripts/select-kit/addon/components/composer-actions.js
@@ -182,7 +182,8 @@ export default DropdownSelectBoxComponent.extend({
// if answered post is a whisper, we can only answer with a whisper so no need for toggle
if (
this.canWhisper &&
- (!_postSnapshot ||
+ (!this.replyOptions.postLink ||
+ !_postSnapshot ||
_postSnapshot.post_type !== this.site.post_types.whisper)
) {
items.push({