A platform for community discussion. Free, open, simple.
FIX: Show empty topic filter in other discovery tabs (not new and unread) (#37099)
Martin Brennan548cc6ddb951
diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 758f76ba973..1d651fce0ac 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3640,6 +3640,7 @@ en:unread: "Nothing left unread... impressive!"new_new: "Nothing new at the moment... check back soon!"new: "Nothing new at the moment... check back soon!"+ generic: "Nothing to see here...check back soon!"topic_bulk_actions:dismiss:diff --git a/frontend/discourse/app/components/discovery/topics.gjs b/frontend/discourse/app/components/discovery/topics.gjsindex 75adedf3897..740cb2279e2 100644--- a/frontend/discourse/app/components/discovery/topics.gjs+++ b/frontend/discourse/app/components/discovery/topics.gjs@@ -132,13 +132,7 @@ export default class DiscoveryTopics extends Component {return false;}- const segments = (this.args.model.get("filter") || "").split("/");- const tab = segments.at(-1);- if (tab === "new" || tab === "unread") {- return true;- }-- return false;+ return true;}get renderNewListHeaderControls() {diff --git a/frontend/discourse/app/components/empty-topic-filter.gjs b/frontend/discourse/app/components/empty-topic-filter.gjsindex 0e1d787471a..6f5312d5bb9 100644--- a/frontend/discourse/app/components/empty-topic-filter.gjs+++ b/frontend/discourse/app/components/empty-topic-filter.gjs@@ -18,6 +18,8 @@ export default class EmptyTopicFilter extends Component {} else {return i18n("topics.none.education.new");}+ } else {+ return i18n("topics.none.education.generic");}}@@ -60,6 +62,15 @@ export default class EmptyTopicFilter extends Component {return "discovery.latest";}+ get tipText() {+ if (this.args.unreadFilter || this.args.newFilter) {+ return i18n("topics.none.education.topic_tracking_preferences", {+ basePath: basePath(),+ });+ }+ return "";+ }+<template><EmptyState@identifier="empty-topic-filter"@@ -68,11 +79,7 @@ export default class EmptyTopicFilter extends Component {@ctaRoute={{this.ctaRoute}}@ctaAction={{this.ctaLabelWithAction.action}}@tipIcon="circle-info"- @tipText={{htmlSafe- (i18n- "topics.none.education.topic_tracking_preferences" basePath=(basePath)- )- }}+ @tipText={{htmlSafe this.tipText}}@svgContent={{SvgDocumentsCheckmark}}/></template>diff --git a/frontend/discourse/tests/integration/components/discovery/topics-test.gjs b/frontend/discourse/tests/integration/components/discovery/topics-test.gjsnew file mode 100644index 00000000000..1aef8f1eaf7--- /dev/null+++ b/frontend/discourse/tests/integration/components/discovery/topics-test.gjs@@ -0,0 +1,72 @@+import EmberObject from "@ember/object";+import { render } from "@ember/test-helpers";+import { module, test } from "qunit";+import DiscoveryTopics from "discourse/components/discovery/topics";+import { setupRenderingTest } from "discourse/tests/helpers/component-test";++function createModel(attrs = {}) {+ return EmberObject.create({+ filter: attrs.filter ?? "latest",+ topics: attrs.topics ?? [],+ more_topics_url: attrs.more_topics_url ?? null,+ params: attrs.params ?? {},+ canLoadMore: attrs.canLoadMore ?? false,+ loadingMore: attrs.loadingMore ?? false,+ sharedDrafts: attrs.sharedDrafts ?? null,+ hideCategory: attrs.hideCategory ?? false,+ loadingBefore: attrs.loadingBefore ?? false,+ });+}++module("Integration | Component | DiscoveryTopics", function (hooks) {+ setupRenderingTest(hooks);++ module("showEmptyFilterEducationInFooter", function () {+ test("shows EmptyTopicFilter when all topics loaded and list is empty", async function (assert) {+ const model = createModel({+ topics: [],+ more_topics_url: null,+ });++ await render(<template><DiscoveryTopics @model={{model}} /></template>);++ assert.dom(".empty-state__container.--empty-topic-filter").exists();+ });++ test("does not show EmptyTopicFilter when there are more topics to load", async function (assert) {+ const model = createModel({+ topics: [],+ more_topics_url: "/latest?page=2",+ });++ await render(<template><DiscoveryTopics @model={{model}} /></template>);++ assert.dom(".empty-state--empty-topic-filter").doesNotExist();+ });++ test("does not show EmptyTopicFilter when topics exist", async function (assert) {+ const model = createModel({+ topics: [EmberObject.create({ id: 1, title: "Test topic" })],+ more_topics_url: null,+ });++ await render(<template><DiscoveryTopics @model={{model}} /></template>);++ assert.dom(".empty-state--empty-topic-filter").doesNotExist();+ });++ test("does not show EmptyTopicFilter for anonymous users", async function (assert) {+ this.owner.unregister("service:current-user");+ this.owner.register("service:current-user", null, { instantiate: false });++ const model = createModel({+ topics: [],+ more_topics_url: null,+ });++ await render(<template><DiscoveryTopics @model={{model}} /></template>);++ assert.dom(".empty-state--empty-topic-filter").doesNotExist();+ });+ });+});diff --git a/frontend/discourse/tests/integration/components/empty-topic-filter.gjs b/frontend/discourse/tests/integration/components/empty-topic-filter.gjsindex a77abccc676..6d89b1f0727 100644--- a/frontend/discourse/tests/integration/components/empty-topic-filter.gjs+++ b/frontend/discourse/tests/integration/components/empty-topic-filter.gjs@@ -4,10 +4,10 @@ import EmptyTopicFilter from "discourse/components/empty-topic-filter";import { setupRenderingTest } from "discourse/tests/helpers/component-test";import { i18n } from "discourse-i18n";-module("Integration | Component | EmptyTopicFilterFilter", function (hooks) {+module("Integration | Component | EmptyTopicFilter", function (hooks) {setupRenderingTest(hooks);- test("renders the correct education text based on unread or new", async function (assert) {+ test("renders new education text when newFilter is true", async function (assert) {await render(<template><EmptyTopicFilter @unreadFilter={{false}} @newFilter={{true}} />@@ -17,8 +17,10 @@ module("Integration | Component | EmptyTopicFilterFilter", function (hooks) {assert.dom(".empty-topic-filter__text").hasText(i18n("topics.none.education.new"));+ });- this.siteSettings.new_new_view_enabled = true;+ test("renders new_new education text when newFilter is true and new_new_view_enabled", async function (assert) {+ this.currentUser.new_new_view_enabled = true;await render(<template>@@ -29,7 +31,9 @@ module("Integration | Component | EmptyTopicFilterFilter", function (hooks) {assert.dom(".empty-topic-filter__text").hasText(i18n("topics.none.education.new_new"));+ });+ test("renders unread education text when unreadFilter is true", async function (assert) {await render(<template><EmptyTopicFilter @unreadFilter={{true}} @newFilter={{false}} />@@ -40,4 +44,16 @@ module("Integration | Component | EmptyTopicFilterFilter", function (hooks) {.dom(".empty-topic-filter__text").hasText(i18n("topics.none.education.unread"));});++ test("renders generic education text when neither newFilter nor unreadFilter is true", async function (assert) {+ await render(+ <template>+ <EmptyTopicFilter @unreadFilter={{false}} @newFilter={{false}} />+ </template>+ );++ assert+ .dom(".empty-topic-filter__text")+ .hasText(i18n("topics.none.education.generic"));+ });});