diff --git a/app/assets/javascripts/discourse/app/controllers/discovery/topics.js b/app/assets/javascripts/discourse/app/controllers/discovery/topics.js index e1b7dc2c4cd..2b2f5e1c71e 100644 --- a/app/assets/javascripts/discourse/app/controllers/discovery/topics.js +++ b/app/assets/javascripts/discourse/app/controllers/discovery/topics.js @@ -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` ), }); }, diff --git a/app/assets/javascripts/discourse/tests/acceptance/new-topics-test.js b/app/assets/javascripts/discourse/tests/acceptance/new-topics-test.js new file mode 100644 index 00000000000..bba685b047b --- /dev/null +++ b/app/assets/javascripts/discourse/tests/acceptance/new-topics-test.js @@ -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); + }); +}); diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 712e48ee540..939e47ffe9e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -2907,7 +2907,8 @@ en: filter: "There are no topics." educate: new: '
Your new topics will appear here. By default, topics are considered new and will show a indicator if they were created in the last 2 days.
Visit your preferences to change this.
' - unread: 'Your unread topics appear here.
By default, topics are considered unread and will show unread counts 1 if you:
Or if you have explicitly set the topic to Tracked or Watched via the 🔔 in each topic.
Visit your preferences to change this.
' + unread: 'Your unread topics appear here.
By default, topics are considered unread and will show unread counts 1 if you:
Or if you have explicitly set the topic to Tracked or Watched via the 🔔 in each topic.
Visit your preferences to change this.
' + new_new: 'Your new topics will appear here, and your unread topics will also be displayed. By default, topics are considered new and will show a indicator if they were created in the last 2 days. Unread topics will show unread counts 1 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.
Visit your preferences to change this.
' bottom: latest: "There are no more latest topics." posted: "There are no more posted topics."