From 783490f7631e48ddcd6e6ab30fde1e03290cb36e Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 21 Dec 2016 13:39:41 -0500 Subject: [PATCH] FIX: with featured links enabled and uncategorized topic not allowed, allow featued links behaviour before choosing a category --- app/assets/javascripts/discourse/models/composer.js.es6 | 3 ++- test/javascripts/models/composer-test.js.es6 | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6 index 6863433cfe5..bb833c7c1c7 100644 --- a/app/assets/javascripts/discourse/models/composer.js.es6 +++ b/app/assets/javascripts/discourse/models/composer.js.es6 @@ -143,7 +143,8 @@ const Composer = RestModel.extend({ if (!this.siteSettings.topic_featured_link_enabled || !canEditTitle || creatingPrivateMessage) { return false; } const categoryIds = this.site.get('topic_featured_link_allowed_category_ids'); - if (!categoryId && categoryIds && categoryIds.indexOf(this.site.get('uncategorized_category_id')) !== -1) { return true; } + if (!categoryId && categoryIds && + (categoryIds.indexOf(this.site.get('uncategorized_category_id')) !== -1 || !this.siteSettings.allow_uncategorized_topics)) { return true; } return categoryIds === undefined || !categoryIds.length || categoryIds.indexOf(categoryId) !== -1; }, diff --git a/test/javascripts/models/composer-test.js.es6 b/test/javascripts/models/composer-test.js.es6 index 86208aa5843..d7bcf53af7c 100644 --- a/test/javascripts/models/composer-test.js.es6 +++ b/test/javascripts/models/composer-test.js.es6 @@ -248,3 +248,11 @@ test("title placeholder depends on what you're doing", function() { composer = createComposer({action: Composer.PRIVATE_MESSAGE}); equal(composer.get('titlePlaceholder'), 'composer.title_placeholder', "placeholder for private message with topic links enabled"); }); + +test("allows featured link before choosing a category", function() { + Discourse.SiteSettings.topic_featured_link_enabled = true; + Discourse.SiteSettings.allow_uncategorized_topics = false; + let composer = createComposer({action: Composer.CREATE_TOPIC}); + equal(composer.get('titlePlaceholder'), 'composer.title_or_link_placeholder', "placeholder invites you to paste a link"); + ok(composer.get('canEditTopicFeaturedLink'), "can paste link"); +});