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.
This commit is contained in:
Kris 2025-01-14 08:28:16 -05:00 committed by GitHub
parent f8c493f3c4
commit 7330cfa76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"),
};
}