FIX: with featured links enabled and uncategorized topic not allowed, allow featued links behaviour before choosing a category

This commit is contained in:
Neil Lalonde 2016-12-21 13:39:41 -05:00
parent 0d826ea933
commit 783490f763
2 changed files with 10 additions and 1 deletions

View File

@ -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;
},

View File

@ -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");
});