mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Hide Uncategorized in site menu when disabled. (#7509)
This commit is contained in:
parent
4e91839c97
commit
c06b00a54e
@ -204,6 +204,12 @@ export default createWidget("hamburger-menu", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.siteSettings.allow_uncategorized_topics) {
|
||||||
|
categories = categories.filter(
|
||||||
|
c => c.id !== this.site.uncategorized_category_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const moreCount = categories.length - maxCategoriesToDisplay;
|
const moreCount = categories.length - maxCategoriesToDisplay;
|
||||||
categories = categories.slice(0, maxCategoriesToDisplay);
|
categories = categories.slice(0, maxCategoriesToDisplay);
|
||||||
|
|
||||||
|
@ -125,19 +125,38 @@ widgetTest("top categories - anonymous", {
|
|||||||
|
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.siteSettings.header_dropdown_category_count = 8;
|
this.siteSettings.header_dropdown_category_count = 8;
|
||||||
maxCategoriesToDisplay = this.siteSettings.header_dropdown_category_count;
|
|
||||||
categoriesByCount = this.site.get("categoriesByCount");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
test(assert) {
|
test(assert) {
|
||||||
const count = categoriesByCount.length;
|
assert.equal(find(".category-link").length, 8);
|
||||||
const maximum =
|
|
||||||
count <= maxCategoriesToDisplay ? count : maxCategoriesToDisplay;
|
|
||||||
assert.equal(find(".category-link").length, maximum);
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".category-link .category-name").text(),
|
find(".category-link .category-name").text(),
|
||||||
categoriesByCount
|
this.site
|
||||||
.slice(0, maxCategoriesToDisplay)
|
.get("categoriesByCount")
|
||||||
|
.slice(0, 8)
|
||||||
|
.map(c => c.name)
|
||||||
|
.join("")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
widgetTest("top categories - allow_uncategorized_topics", {
|
||||||
|
template: '{{mount-widget widget="hamburger-menu"}}',
|
||||||
|
anonymous: true,
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.siteSettings.allow_uncategorized_topics = false;
|
||||||
|
this.siteSettings.header_dropdown_category_count = 8;
|
||||||
|
},
|
||||||
|
|
||||||
|
test(assert) {
|
||||||
|
assert.equal(find(".category-link").length, 8);
|
||||||
|
assert.equal(
|
||||||
|
find(".category-link .category-name").text(),
|
||||||
|
this.site
|
||||||
|
.get("categoriesByCount")
|
||||||
|
.filter(c => c.name !== "uncategorized")
|
||||||
|
.slice(0, 8)
|
||||||
.map(c => c.name)
|
.map(c => c.name)
|
||||||
.join("")
|
.join("")
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user