Skip to content

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

FIX: Allow users to quote in closed topics (#17645)

Penar Musaraj7592754c9022
diff --git a/app/assets/javascripts/discourse/app/components/quote-button.js b/app/assets/javascripts/discourse/app/components/quote-button.js
index 40d13d7af32..a5066f754a1 100644
--- a/app/assets/javascripts/discourse/app/components/quote-button.js
+++ b/app/assets/javascripts/discourse/app/components/quote-button.js
@@ -417,12 +417,14 @@ export default Component.extend(KeyEnterEscape, {
return getAbsoluteURL(postUrl(topic.slug, topic.id, postNumber));
},
- @discourseComputed("topic.details.can_create_post", "composerVisible")
- embedQuoteButton(canCreatePost, composerOpened) {
+ @discourseComputed(
+ "topic.details.can_create_post",
+ "topic.details.can_reply_as_new_topic"
+ )
+ embedQuoteButton(canCreatePost, canReplyAsNewTopic) {
return (
- (canCreatePost || composerOpened) &&
- this.currentUser &&
- this.currentUser.get("enable_quoting")
+ (canCreatePost || canReplyAsNewTopic) &&
+ this.currentUser?.get("enable_quoting")
);
},
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
index 6fb32201ff7..2859e2c9110 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-quote-button-test.js
@@ -8,6 +8,8 @@ import {
} from "discourse/tests/helpers/qunit-helpers";
import I18n from "I18n";
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
+import { cloneJSON } from "discourse-common/lib/object";
+import topicFixtures from "discourse/tests/fixtures/topic";
import { test } from "qunit";
// This tests are flaky on Firefox. Fails with `calling set on destroyed object`
@@ -64,6 +66,32 @@ acceptance("Topic - Quote button - logged in", function (needs) {
);
});
+acceptance("Closed Topic - Quote button - logged in", function (needs) {
+ needs.user();
+
+ needs.pretender((server, helper) => {
+ const topicResponse = cloneJSON(topicFixtures["/t/280/1.json"]);
+ topicResponse.closed = true;
+ topicResponse.details.can_create_post = false;
+
+ server.get("/t/280.json", () => helper.response(topicResponse));
+ });
+
+ chromeTest("Shows quote button in closed topics", async function (assert) {
+ await visit("/t/internationalization-localization/280");
+ await selectText("#post_1 .cooked p:first-child");
+ assert.ok(exists(".insert-quote"), "it shows the quote button");
+
+ await click(".insert-quote");
+ assert.ok(
+ query(".d-editor-input")
+ .value.trim()
+ .startsWith("Continuing the discussion from"),
+ "quote action defaults to reply as new topic (since topic is closed)"
+ );
+ });
+});
+
acceptance("Topic - Quote button - anonymous", function (needs) {
needs.settings({
share_quote_visibility: "anonymous",