FIX: no reply as a new topic without permission (#25641)

`create topic allowed groups` site setting controls permission to create a new topic.

If a user cannot create a topic, a reply as a new topic button should not be visible as well.
This commit is contained in:
Krzysztof Kotlarek 2024-02-13 09:26:13 +11:00 committed by GitHub
parent 021a02c3d8
commit 949b5f3fa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -153,6 +153,18 @@ acceptance("Composer Actions", function (needs) {
assert.ok(!exists(".dialog-body"));
});
test("reply_as_new_topic without a permission to create topic", async function (assert) {
updateCurrentUser({ can_create_topic: false });
await visit("/t/internationalization-localization/280");
await click(".create.reply");
const composerActions = selectKit(".composer-actions");
await composerActions.expand();
assert.ok(
!exists(".composer-actions svg.d-icon-plus"),
"reply as new topic icon is not visible"
);
});
test("reply_as_new_group_message", async function (assert) {
await visit("/t/lorem-ipsum-dolor-sit-amet/130");
await click(".create.reply");

View File

@ -137,6 +137,7 @@ export default DropdownSelectBoxComponent.extend({
this.topic &&
!this.topic.isPrivateMessage &&
!this.isEditing &&
this.currentUser.can_create_topic &&
_topicSnapshot
) {
items.push({
@ -222,7 +223,7 @@ export default DropdownSelectBoxComponent.extend({
});
}
if (items.length === 0) {
if (items.length === 0 && this.currentUser.can_create_topic) {
items.push({
name: I18n.t("composer.composer_actions.create_topic.label"),
description: I18n.t("composer.composer_actions.create_topic.desc"),