mirror of
https://github.com/discourse/discourse.git
synced 2025-06-13 11:25:00 +08:00
FIX: Change rootNone behavior in category-chooser (#8692)
This breaking change was originally a deprecation fix for overriding a computed property `none`. There are 4 uses of `rootNone` in core and "all-the-plugins": 1. in discourse-chat-integration, admin-plugins-chat-edit-rule.hbs - changed behavior, that I'd consider a fix - `rootNoneLabel` is now used regardless of `siteSettings.allow_uncategorized_topics` value, which I believe was an originally intended behavior (i.e. it most likely hasn't been tested with disabled uncategorized topics) 2. in discourse-slack-official, plugins-slack.hbs - the same as 1. 3. in core, edit-category-general.hbs (in this PR) - no change in behavior 4. in discourse-googlebooks, edit-category-general.hbs - no change in behavior (since `allowUncategorized="true"` is also passed as an argument)
This commit is contained in:
@ -12,7 +12,7 @@
|
|||||||
<section class='field'>
|
<section class='field'>
|
||||||
<label>{{i18n 'category.parent'}}</label>
|
<label>{{i18n 'category.parent'}}</label>
|
||||||
{{category-chooser
|
{{category-chooser
|
||||||
none="category.none"
|
rootNone=true
|
||||||
value=category.parent_category_id
|
value=category.parent_category_id
|
||||||
excludeCategoryId=category.id
|
excludeCategoryId=category.id
|
||||||
categories=parentCategories
|
categories=parentCategories
|
||||||
|
@ -3,7 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
|
|||||||
import PermissionType from "discourse/models/permission-type";
|
import PermissionType from "discourse/models/permission-type";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||||
const { get, isNone, isEmpty } = Ember;
|
const { get, isPresent, isEmpty } = Ember;
|
||||||
|
|
||||||
export default ComboBoxComponent.extend({
|
export default ComboBoxComponent.extend({
|
||||||
pluginApiIdentifiers: ["category-chooser"],
|
pluginApiIdentifiers: ["category-chooser"],
|
||||||
@ -55,15 +55,13 @@ export default ComboBoxComponent.extend({
|
|||||||
|
|
||||||
@discourseComputed("rootNone", "rootNoneLabel")
|
@discourseComputed("rootNone", "rootNoneLabel")
|
||||||
none(rootNone, rootNoneLabel) {
|
none(rootNone, rootNoneLabel) {
|
||||||
if (
|
if (isPresent(rootNone)) {
|
||||||
|
return rootNoneLabel || "category.none";
|
||||||
|
} else if (
|
||||||
this.siteSettings.allow_uncategorized_topics ||
|
this.siteSettings.allow_uncategorized_topics ||
|
||||||
this.allowUncategorized
|
this.allowUncategorized
|
||||||
) {
|
) {
|
||||||
if (!isNone(rootNone)) {
|
|
||||||
return rootNoneLabel || "category.none";
|
|
||||||
} else {
|
|
||||||
return Category.findUncategorized();
|
return Category.findUncategorized();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return "category.choose";
|
return "category.choose";
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ componentTest("with allowUncategorized=null rootNone=true", {
|
|||||||
|
|
||||||
test(assert) {
|
test(assert) {
|
||||||
assert.equal(this.subject.header().value(), null);
|
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) {
|
test(assert) {
|
||||||
assert.equal(this.subject.header().value(), null);
|
assert.equal(this.subject.header().value(), null);
|
||||||
assert.equal(this.subject.header().title(), "category");
|
assert.equal(this.subject.header().title(), "root none label");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user