mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 10:55:25 +08:00
FIX: Append /all to URL if default list is 'none' (#15460)
It was impossible to select the 'all' filter for categories that have the default list filter set to 'no subcategories'. This happens because '/all' was not appended to the URL and in the absence of any list filter ('all' or 'none'), the default list filter ('none') was automatically selected.
This commit is contained in:
parent
793c3ae7d4
commit
c0d72ec3d6
|
@ -507,7 +507,9 @@ export function getCategoryAndTagUrl(category, subcategories, tag) {
|
|||
|
||||
if (category) {
|
||||
url = category.path;
|
||||
if (!subcategories) {
|
||||
if (subcategories && category.default_list_filter === "none") {
|
||||
url += "/all";
|
||||
} else if (!subcategories && category.default_list_filter === "all") {
|
||||
url += "/none";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import DiscourseURL, { prefixProtocol, userPath } from "discourse/lib/url";
|
||||
import DiscourseURL, {
|
||||
getCategoryAndTagUrl,
|
||||
prefixProtocol,
|
||||
userPath,
|
||||
} from "discourse/lib/url";
|
||||
import { module, test } from "qunit";
|
||||
import User from "discourse/models/user";
|
||||
import { logIn } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
@ -100,6 +104,40 @@ module("Unit | Utility | url", function () {
|
|||
);
|
||||
});
|
||||
|
||||
test("getCategoryAndTagUrl", function (assert) {
|
||||
assert.strictEqual(
|
||||
getCategoryAndTagUrl(
|
||||
{ path: "/c/foo/1", default_list_filter: "all" },
|
||||
true
|
||||
),
|
||||
"/c/foo/1"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
getCategoryAndTagUrl(
|
||||
{ path: "/c/foo/1", default_list_filter: "all" },
|
||||
false
|
||||
),
|
||||
"/c/foo/1/none"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
getCategoryAndTagUrl(
|
||||
{ path: "/c/foo/1", default_list_filter: "none" },
|
||||
true
|
||||
),
|
||||
"/c/foo/1/all"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
getCategoryAndTagUrl(
|
||||
{ path: "/c/foo/1", default_list_filter: "none" },
|
||||
false
|
||||
),
|
||||
"/c/foo/1"
|
||||
);
|
||||
});
|
||||
|
||||
test("routeTo redirects secure media URLS because they are server side only", async function (assert) {
|
||||
sinon.stub(DiscourseURL, "redirectTo");
|
||||
sinon.stub(DiscourseURL, "handleURL");
|
||||
|
|
Loading…
Reference in New Issue
Block a user