mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 04:59:22 -06:00
UX: Sort tags alphabetically in sidebar (#17959)
This commit is contained in:
parent
f7ed09a02c
commit
97a20d6d82
@ -320,13 +320,9 @@ const User = RestModel.extend({
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.siteSettings.tags_sort_alphabetically) {
|
||||
return sidebarTags.sort((a, b) => {
|
||||
return a.name.localeCompare(b);
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
} else {
|
||||
return sidebarTags;
|
||||
}
|
||||
},
|
||||
|
||||
sidebarTagNames: mapBy("sidebarTags", "name"),
|
||||
|
@ -7,6 +7,7 @@ import {
|
||||
exists,
|
||||
publishToMessageBus,
|
||||
query,
|
||||
queryAll,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
||||
@ -43,16 +44,16 @@ acceptance("Sidebar - Tags section", function (needs) {
|
||||
watched_tags: ["tag2", "tag3"],
|
||||
watching_first_post_tags: [],
|
||||
sidebar_tags: [
|
||||
{ name: "tag1", pm_only: false },
|
||||
{ name: "tag2", pm_only: false },
|
||||
{
|
||||
name: "tag3",
|
||||
pm_only: false,
|
||||
},
|
||||
{ name: "tag1", pm_only: false },
|
||||
{
|
||||
name: "tag4",
|
||||
pm_only: true,
|
||||
},
|
||||
{
|
||||
name: "tag3",
|
||||
pm_only: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@ -126,6 +127,26 @@ acceptance("Sidebar - Tags section", function (needs) {
|
||||
);
|
||||
});
|
||||
|
||||
test("tag section links are sorted alphabetically by tag's name", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
const tagSectionLinks = queryAll(
|
||||
".sidebar-section-tags .sidebar-section-link"
|
||||
);
|
||||
|
||||
const tagNames = [];
|
||||
|
||||
tagSectionLinks.each((_index, tagSectionLink) => {
|
||||
tagNames.push(tagSectionLink.textContent.trim());
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
tagNames,
|
||||
["tag1", "tag2", "tag3", "tag4"],
|
||||
"tag section links are displayed in the right order"
|
||||
);
|
||||
});
|
||||
|
||||
test("tag section links for user", async function (assert) {
|
||||
await visit("/");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user