FEATURE: SiteSetting to default user path to different routes (#20962)

This commit is contained in:
Mark VanLandingham 2023-04-04 11:48:48 -05:00 committed by GitHub
parent 17ba00c395
commit 73325c6c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 1 deletions

View File

@ -26,7 +26,12 @@ export default {
let siteSettings = container.lookup("service:site-settings");
initializeDefaultHomepage(siteSettings);
DiscourseURL.rewrite(/^\/u\/([^\/]+)\/?$/, "/u/$1/summary", {
let defaultUserRoute = siteSettings.view_user_route || "summary";
if (!container.lookup(`route:user.${defaultUserRoute}`)) {
defaultUserRoute = "summary";
}
DiscourseURL.rewrite(/^\/u\/([^\/]+)\/?$/, `/u/$1/${defaultUserRoute}`, {
exceptions: [
"/u/account-created",
"/users/account-created",

View File

@ -335,6 +335,30 @@ acceptance(
}
);
acceptance("User - Invalid view_user_route setting", function (needs) {
needs.settings({
view_user_route: "X",
});
test("It defaults to summary", async function (assert) {
await visit("/u/eviltrout");
assert.strictEqual(currentRouteName(), "user.summary");
});
});
acceptance("User - Valid view_user_route setting", function (needs) {
needs.settings({
view_user_route: "activity",
});
test("It defaults to summary", async function (assert) {
await visit("/u/eviltrout");
assert.strictEqual(currentRouteName(), "userActivity.index");
});
});
acceptance("User - Logout", function (needs) {
needs.user({ username: "eviltrout" });

View File

@ -2466,6 +2466,11 @@ uncategorized:
default: 0
hidden: true
view_user_route:
default: "summary"
hidden: true
client: true
tos_topic_id:
default: -1
hidden: true