Skip to content

A platform for community discussion. Free, open, simple.

FIX: Change rootNone behavior in category-chooser (#8692)

Jarek Radoszff5a82b614f1
diff --git a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
index bf611e359c6..95e681f3966 100644
--- a/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
+++ b/app/assets/javascripts/discourse/templates/components/edit-category-general.hbs
@@ -12,7 +12,7 @@
<section class='field'>
<label>{{i18n 'category.parent'}}</label>
{{category-chooser
- none="category.none"
+ rootNone=true
value=category.parent_category_id
excludeCategoryId=category.id
categories=parentCategories
diff --git a/app/assets/javascripts/select-kit/components/category-chooser.js.es6 b/app/assets/javascripts/select-kit/components/category-chooser.js.es6
index 8a91e9868e2..43f690b1133 100644
--- a/app/assets/javascripts/select-kit/components/category-chooser.js.es6
+++ b/app/assets/javascripts/select-kit/components/category-chooser.js.es6
@@ -3,7 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
import PermissionType from "discourse/models/permission-type";
import Category from "discourse/models/category";
import { categoryBadgeHTML } from "discourse/helpers/category-link";
-const { get, isNone, isEmpty } = Ember;
+const { get, isPresent, isEmpty } = Ember;
export default ComboBoxComponent.extend({
pluginApiIdentifiers: ["category-chooser"],
@@ -55,15 +55,13 @@ export default ComboBoxComponent.extend({
@discourseComputed("rootNone", "rootNoneLabel")
none(rootNone, rootNoneLabel) {
- if (
+ if (isPresent(rootNone)) {
+ return rootNoneLabel || "category.none";
+ } else if (
this.siteSettings.allow_uncategorized_topics ||
this.allowUncategorized
) {
- if (!isNone(rootNone)) {
- return rootNoneLabel || "category.none";
- } else {
- return Category.findUncategorized();
- }
+ return Category.findUncategorized();
} else {
return "category.choose";
}
diff --git a/test/javascripts/components/category-chooser-test.js.es6 b/test/javascripts/components/category-chooser-test.js.es6
index 79cc252682a..f311f4d4f1e 100644
--- a/test/javascripts/components/category-chooser-test.js.es6
+++ b/test/javascripts/components/category-chooser-test.js.es6
@@ -73,7 +73,7 @@ componentTest("with allowUncategorized=null rootNone=true", {
test(assert) {
assert.equal(this.subject.header().value(), null);
- assert.equal(this.subject.header().title(), "category");
+ assert.equal(this.subject.header().title(), "(no category)");
}
});
@@ -88,7 +88,7 @@ componentTest("with disallowed uncategorized, rootNone and rootNoneLabel", {
test(assert) {
assert.equal(this.subject.header().value(), null);
- assert.equal(this.subject.header().title(), "category");
+ assert.equal(this.subject.header().title(), "root none label");
}
});