From 66429587067579408c23d6ca2712c7fe6f107a08 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 6 Jun 2023 13:22:12 +0900 Subject: [PATCH] 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. --- .../app/controllers/discovery/topics.js | 9 ++++-- .../tests/acceptance/new-topics-test.js | 31 +++++++++++++++++++ config/locales/client.en.yml | 3 +- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/discourse/tests/acceptance/new-topics-test.js 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."