From 7330cfa76a6e6ab7bf90702fb1db5e1a37a2eca1 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 14 Jan 2025 08:28:16 -0500 Subject: [PATCH] UX: check category permission before new topic quote (#30753) Reported here: https://meta.discourse.org/t/quoting-a-closed-topic-prefills-category-in-composer-that-should-be-off-limits/260009 Currently, if someone tries to quote a topic they don't have permission to reply to, we'll open a new topic composer with the quote so they can "continue the discussion". When doing this, we populate the current category, even if the user doesn't have permission to post in it. This is misleading, as when the user attempts to submit their topic they get an error because they lack the category permissions. This change checks the category permissions before populating it. --- app/assets/javascripts/discourse/app/controllers/topic.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.js index 57a219f8e06..435da4d4032 100644 --- a/app/assets/javascripts/discourse/app/controllers/topic.js +++ b/app/assets/javascripts/discourse/app/controllers/topic.js @@ -1201,7 +1201,9 @@ export default class TopicController extends Controller.extend( options = { action: Composer.CREATE_TOPIC, draftKey: post.topic.draft_key, - topicCategoryId: this.get("model.category.id"), + topicCategoryId: + this.get("model.category.permission") && + this.get("model.category.id"), prioritizedCategoryId: this.get("model.category.id"), }; }