mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 20:54:00 -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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.siteSettings.tags_sort_alphabetically) {
|
return sidebarTags.sort((a, b) => {
|
||||||
return sidebarTags.sort((a, b) => {
|
return a.name.localeCompare(b.name);
|
||||||
return a.name.localeCompare(b);
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return sidebarTags;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
sidebarTagNames: mapBy("sidebarTags", "name"),
|
sidebarTagNames: mapBy("sidebarTags", "name"),
|
||||||
|
@ -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";
|
||||||
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
||||||
@ -43,16 +44,16 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||||||
watched_tags: ["tag2", "tag3"],
|
watched_tags: ["tag2", "tag3"],
|
||||||
watching_first_post_tags: [],
|
watching_first_post_tags: [],
|
||||||
sidebar_tags: [
|
sidebar_tags: [
|
||||||
{ name: "tag1", pm_only: false },
|
|
||||||
{ name: "tag2", pm_only: false },
|
{ name: "tag2", pm_only: false },
|
||||||
{
|
{ name: "tag1", pm_only: false },
|
||||||
name: "tag3",
|
|
||||||
pm_only: false,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "tag4",
|
name: "tag4",
|
||||||
pm_only: true,
|
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) {
|
test("tag section links for user", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user