mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Sort categories alphabetically in Sidebar (#17958)
This commit is contained in:
parent
4657110c35
commit
f7ed09a02c
@ -337,16 +337,18 @@ const User = RestModel.extend({
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Site.current().categoriesList.filter((category) => {
|
return Site.current()
|
||||||
if (
|
.categoriesList.filter((category) => {
|
||||||
this.siteSettings.suppress_uncategorized_badge &&
|
if (
|
||||||
category.isUncategorizedCategory
|
this.siteSettings.suppress_uncategorized_badge &&
|
||||||
) {
|
category.isUncategorizedCategory
|
||||||
return false;
|
) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return sidebarCategoryIds.includes(category.id);
|
return sidebarCategoryIds.includes(category.id);
|
||||||
});
|
})
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
},
|
},
|
||||||
|
|
||||||
changeUsername(new_username) {
|
changeUsername(new_username) {
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
exists,
|
exists,
|
||||||
publishToMessageBus,
|
publishToMessageBus,
|
||||||
query,
|
query,
|
||||||
|
queryAll,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
@ -149,6 +150,32 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("category section links are sorted by category name alphabetically", async function (assert) {
|
||||||
|
const { category1, category2, category3 } = setupUserSidebarCategories();
|
||||||
|
|
||||||
|
category3.set("name", "aBC");
|
||||||
|
category2.set("name", "abc");
|
||||||
|
category1.set("name", "efg");
|
||||||
|
|
||||||
|
await visit("/");
|
||||||
|
|
||||||
|
const categorySectionLinks = queryAll(
|
||||||
|
".sidebar-section-categories .sidebar-section-link"
|
||||||
|
);
|
||||||
|
|
||||||
|
const categoryNames = [];
|
||||||
|
|
||||||
|
categorySectionLinks.each((_index, categorySectionLink) => {
|
||||||
|
categoryNames.push(categorySectionLink.textContent.trim());
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
categoryNames,
|
||||||
|
["abc", "aBC", "efg"],
|
||||||
|
"category section links are displayed in the right order"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("category section links", async function (assert) {
|
test("category section links", async function (assert) {
|
||||||
const { category1, category2, category3 } = setupUserSidebarCategories();
|
const { category1, category2, category3 } = setupUserSidebarCategories();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user