From eeae657ca55c6fe53286dca6063db3e3a35f4fd1 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Fri, 27 Nov 2020 13:03:37 +0200 Subject: [PATCH] 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. --- app/assets/javascripts/discourse/app/routes/tag-show.js | 5 +++-- .../javascripts/discourse/tests/acceptance/tags-test.js | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/routes/tag-show.js b/app/assets/javascripts/discourse/app/routes/tag-show.js index 8fec14ea398..565c4ca23f1 100644 --- a/app/assets/javascripts/discourse/app/routes/tag-show.js +++ b/app/assets/javascripts/discourse/app/routes/tag-show.js @@ -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", diff --git a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js index f145ab9ac11..fb3339415aa 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/tags-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/tags-test.js @@ -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); + }); });