FIX: Show tag chooser if can_tag_pms (#18107)

The old logic did not make sense and hid the selector from regular users
even if they could tag PMs or showed selector for admins even if they
could not tag PMs.
This commit is contained in:
Bianca Nenciu 2022-08-29 15:52:19 +03:00 committed by GitHub
parent b6e0219a74
commit f351200683
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View File

@ -204,14 +204,17 @@ export default Controller.extend({
@discourseComputed("model.canEditTitle", "model.creatingPrivateMessage") @discourseComputed("model.canEditTitle", "model.creatingPrivateMessage")
canEditTags(canEditTitle, creatingPrivateMessage) { canEditTags(canEditTitle, creatingPrivateMessage) {
if (creatingPrivateMessage && (this.site.mobileView || !this.isStaffUser)) { if (creatingPrivateMessage && this.site.mobileView) {
return false; return false;
} }
const isPrivateMessage =
creatingPrivateMessage || this.get("model.topic.isPrivateMessage");
return ( return (
this.site.can_tag_topics &&
canEditTitle && canEditTitle &&
(!this.get("model.topic.isPrivateMessage") || this.site.can_tag_pms) this.site.can_tag_topics &&
(!isPrivateMessage || this.site.can_tag_pms)
); );
}, },

View File

@ -1,5 +1,6 @@
import { import {
acceptance, acceptance,
exists,
query, query,
updateCurrentUser, updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers"; } from "discourse/tests/helpers/qunit-helpers";
@ -98,4 +99,28 @@ acceptance("Composer - Tags", function (needs) {
await click("#reply-control button.create"); await click("#reply-control button.create");
assert.notStrictEqual(currentURL(), "/"); assert.notStrictEqual(currentURL(), "/");
}); });
test("users who cannot tag PMs do not see the selector", async function (assert) {
await visit("/u/charlie");
await click("button.compose-pm");
assert.notOk(exists(".composer-fields .mini-tag-chooser"));
});
});
acceptance("Composer - Tags (PMs)", function (needs) {
needs.user();
needs.pretender((server, helper) => {
server.post("/uploads/lookup-urls", () => {
return helper.response([]);
});
});
needs.site({ can_tag_topics: true, can_tag_pms: true });
test("users who can tag PMs see the selector", async function (assert) {
await visit("/u/charlie");
await click("button.compose-pm");
assert.ok(exists(".composer-fields .mini-tag-chooser"));
});
}); });