UX: Correct educate message when there are no new topics (#21943)

Why does this change do?

This commit updates the educate message displayed when there are no new
topics on the `/new` route when the experimental new new view site setting is enabled.

The commit also fixes a couple of bugs:

1. Correct default auto track minutes used in the copy for unread
   topics from the 4 minutes to 5 minutes.

2. Correct link to user's preference in copy to go to tracking tab
   instead of notifications tab.
This commit is contained in:
Alan Guo Xiang Tan 2023-06-06 13:22:12 +09:00 committed by GitHub
parent c574d7c555
commit 6642958706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 3 deletions

View File

@ -195,14 +195,19 @@ const controllerOpts = {
const segments = (this.get("model.filter") || "").split("/");
const tab = segments[segments.length - 1];
let tab = segments[segments.length - 1];
if (tab !== "new" && tab !== "unread") {
return;
}
if (tab === "new" && this.currentUser.new_new_view_enabled) {
tab = "new_new";
}
return I18n.t("topics.none.educate." + tab, {
userPrefsUrl: userPath(
`${this.currentUser.get("username_lower")}/preferences/notifications`
`${this.currentUser.get("username_lower")}/preferences/tracking`
),
});
},

View File

@ -0,0 +1,31 @@
import I18n from "I18n";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { visit } from "@ember/test-helpers";
acceptance("New Topics - New new view enabled", function (needs) {
needs.user({
new_new_view_enabled: true,
});
needs.pretender((server, helper) => {
server.get("/new.json", () => {
return helper.response({
topic_list: { can_create_topic: true, topics: [] },
});
});
});
test("visiting new page when there are no new topics", async function (assert) {
await visit("/new");
const text = new DOMParser().parseFromString(
I18n.t("topics.none.educate.new_new", {
userPrefsUrl: "/u/eviltrout/preferences/tracking",
}),
"text/html"
).documentElement.textContent;
assert.dom(".topic-list-bottom .education").hasText(text);
});
});

View File

@ -2907,7 +2907,8 @@ en:
filter: "There are no topics."
educate:
new: '<p>Your new topics will appear here. By default, topics are considered new and will show a <span class="badge new-topic badge-notification" style="vertical-align:middle;line-height:inherit;"></span> indicator if they were created in the last 2 days.</p><p>Visit your <a href="%{userPrefsUrl}">preferences</a> to change this.</p>'
unread: '<p>Your unread topics appear here.</p><p>By default, topics are considered unread and will show unread counts <span class="badge unread-posts badge-notification">1</span> if you:</p><ul><li>Created the topic</li><li>Replied to the topic</li><li>Read the topic for more than 4 minutes</li></ul><p>Or if you have explicitly set the topic to Tracked or Watched via the 🔔 in each topic.</p><p>Visit your <a href="%{userPrefsUrl}">preferences</a> to change this.</p>'
unread: '<p>Your unread topics appear here.</p><p>By default, topics are considered unread and will show unread counts <span class="badge unread-posts badge-notification">1</span> if you:</p><ul><li>Created the topic</li><li>Replied to the topic</li><li>Read the topic for more than 5 minutes</li></ul><p>Or if you have explicitly set the topic to Tracked or Watched via the 🔔 in each topic.</p><p>Visit your <a href="%{userPrefsUrl}">preferences</a> to change this.</p>'
new_new: '<p>Your new topics will appear here, and your unread topics will also be displayed. By default, topics are considered new and will show a <span class="badge new-topic badge-notification" style="vertical-align:middle;line-height:inherit;"></span> indicator if they were created in the last 2 days. Unread topics will show unread counts <span class="badge unread-posts badge-notification">1</span> if you: created the topic, replied to the topic, read the topic for more than 5 minutes, or if you have explicitly set the topic to Tracked or Watched via the 🔔 in each topic.</p><p>Visit your <a href="%{userPrefsUrl}">preferences</a> to change this.</p>'
bottom:
latest: "There are no more latest topics."
posted: "There are no more posted topics."