FIX: No tags should be set if tag chooser is hidden (#11362)

If a user could not set tags because they had a trust level lower than
min_trust_level_to_tag_topics site setting, the "Create Topic" button
from a tag page would still show up and be enabled. Clicking it caused
the composer model to silently have the tags set.
This commit is contained in:
Bianca Nenciu 2020-11-27 13:03:37 +02:00 committed by GitHub
parent a0c457120a
commit eeae657ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -185,7 +185,8 @@ export default DiscourseRoute.extend(FilterModeMixin, {
if (controller.get("list.draft")) {
this.openTopicDraft(controller.get("list"));
} else {
this.controllerFor("composer")
const composerController = this.controllerFor("composer");
composerController
.open({
categoryId: controller.get("category.id"),
action: Composer.CREATE_TOPIC,
@ -194,7 +195,7 @@ export default DiscourseRoute.extend(FilterModeMixin, {
})
.then(() => {
// Pre-fill the tags input field
if (controller.get("model.id")) {
if (composerController.canEditTags && controller.get("model.id")) {
const composerModel = this.controllerFor("composer").get("model");
composerModel.set(
"tags",

View File

@ -308,4 +308,11 @@ acceptance("Tag info", function (needs) {
"removed a synonym"
);
});
test("composer will not set tags if user cannot create them", async function (assert) {
await visit("/tag/planters");
await click("#create-topic");
const composer = this.container.lookup("controller:composer");
assert.equal(composer.model.tags, null);
});
});