A platform for community discussion. Free, open, simple.
FEATURE: Always show All, Topics, and Replies subtabs for unified new (#35292)
Martin Brennan66179c60cd47
diff --git a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs b/app/assets/javascripts/discourse/app/components/discovery/topics.gjsindex 84d7e137d5b..9dd01c9884c 100644--- a/app/assets/javascripts/discourse/app/components/discovery/topics.gjs+++ b/app/assets/javascripts/discourse/app/components/discovery/topics.gjs@@ -33,7 +33,6 @@ export default class DiscoveryTopics extends Component {@service documentTitle;@service currentUser;@service topicTrackingState;- @service site;@tracked loadingNew;@@ -184,11 +183,7 @@ export default class DiscoveryTopics extends Component {}get renderNewListHeaderControls() {- return (- this.site.mobileView &&- this.showTopicsAndRepliesToggle &&- !this.args.bulkSelectEnabled- );+ return this.showTopicsAndRepliesToggle && !this.args.bulkSelectEnabled;}get expandGloballyPinned() {@@ -327,12 +322,8 @@ export default class DiscoveryTopics extends Component {@topics={{@model.topics}}@discoveryList={{true}}@focusLastVisitedTopic={{true}}- @showTopicsAndRepliesToggle={{this.showTopicsAndRepliesToggle}}- @newListSubset={{@model.params.subset}}- @changeNewListSubset={{@changeNewListSubset}}- @newRepliesCount={{this.newRepliesCount}}- @newTopicsCount={{this.newTopicsCount}}/>+<LoadMore @action={{this.loadMore}} />{{/if}}@@ -413,6 +404,12 @@ export default class DiscoveryTopics extends Component {<EmptyTopicFilter@newFilter={{this.new}}@unreadFilter={{this.unread}}+ @trackingCounts={{hash+ newTopics=this.newTopicsCount+ newReplies=this.newRepliesCount+ }}+ @changeNewListSubset={{@changeNewListSubset}}+ @newListSubset={{@model.params.subset}}/>{{/if}}</:afterMessage>diff --git a/app/assets/javascripts/discourse/app/components/empty-topic-filter.gjs b/app/assets/javascripts/discourse/app/components/empty-topic-filter.gjsindex b87c5e243e5..3394b4c4670 100644--- a/app/assets/javascripts/discourse/app/components/empty-topic-filter.gjs+++ b/app/assets/javascripts/discourse/app/components/empty-topic-filter.gjs@@ -21,12 +21,49 @@ export default class EmptyTopicFilter extends Component {}}+ get ctaLabelWithAction() {+ if (this.currentUser.new_new_view_enabled) {+ if (this.args.newListSubset === "topics") {+ if (this.args.trackingCounts.newReplies > 0) {+ return {+ action: () => this.args.changeNewListSubset("replies"),+ label: i18n("topic.browse_new_replies"),+ };+ } else {+ return { action: null, label: i18n("topic.browse_latest_topics") };+ }+ }++ if (this.args.newListSubset === "replies") {+ if (this.args.trackingCounts.newTopics > 0) {+ return {+ action: () => this.args.changeNewListSubset("topics"),+ label: i18n("topic.browse_new_topics"),+ };+ } else {+ return { action: null, label: i18n("topic.browse_latest_topics") };+ }+ }+ }++ return { action: null, label: i18n("topic.browse_latest_topics") };+ }++ get ctaRoute() {+ if (this.currentUser.new_new_view_enabled && this.args.newListSubset) {+ return;+ }++ return "discovery.latest";+ }+<template><EmptyState@identifier="empty-topic-filter"@title={{this.educationText}}- @ctaLabel={{i18n "topic.browse_latest_topics"}}- @ctaRoute="discovery.latest"+ @ctaLabel={{this.ctaLabelWithAction.label}}+ @ctaRoute={{this.ctaRoute}}+ @ctaAction={{this.ctaLabelWithAction.action}}@tipIcon="circle-info"@tipText={{htmlSafe(i18ndiff --git a/app/assets/javascripts/discourse/app/components/topic-list/header.gjs b/app/assets/javascripts/discourse/app/components/topic-list/header.gjsindex f8879b73f60..24df8a8a6da 100644--- a/app/assets/javascripts/discourse/app/components/topic-list/header.gjs+++ b/app/assets/javascripts/discourse/app/components/topic-list/header.gjs@@ -19,12 +19,7 @@ const Header = <template>@showBulkToggle={{@toggleInTitle}}@canBulkSelect={{@canBulkSelect}}@canDoBulkActions={{@canDoBulkActions}}- @showTopicsAndRepliesToggle={{@showTopicsAndRepliesToggle}}- @newListSubset={{@newListSubset}}- @newRepliesCount={{@newRepliesCount}}- @newTopicsCount={{@newTopicsCount}}@bulkSelectHelper={{@bulkSelectHelper}}- @changeNewListSubset={{@changeNewListSubset}}/>{{/each}}</tr>diff --git a/app/assets/javascripts/discourse/app/components/topic-list/header/sortable-column.gjs b/app/assets/javascripts/discourse/app/components/topic-list/header/sortable-column.gjsindex a98a6afca90..4aa95aeb07b 100644--- a/app/assets/javascripts/discourse/app/components/topic-list/header/sortable-column.gjs+++ b/app/assets/javascripts/discourse/app/components/topic-list/header/sortable-column.gjs@@ -3,7 +3,6 @@ import { on } from "@ember/modifier";import { action } from "@ember/object";import { service } from "@ember/service";import PluginOutlet from "discourse/components/plugin-outlet";-import NewListHeaderControls from "discourse/components/topic-list/new-list-header-controls";import TopicBulkSelectDropdown from "discourse/components/topic-list/topic-bulk-select-dropdown";import concatClass from "discourse/helpers/concat-class";import icon from "discourse/helpers/d-icon";@@ -116,26 +115,17 @@ export default class SortableColumn extends Component {{{/if}}{{#unless @bulkSelectEnabled}}- {{#if @showTopicsAndRepliesToggle}}- <NewListHeaderControls- @current={{@newListSubset}}- @newRepliesCount={{@newRepliesCount}}- @newTopicsCount={{@newTopicsCount}}- @changeNewListSubset={{@changeNewListSubset}}- />+ {{#if @sortable}}+ <button aria-pressed={{this.isSorting}}>+ {{this.localizedName}}+ {{#if this.isSorting}}+ {{icon (if @ascending "chevron-up" "chevron-down")}}+ {{/if}}+ </button>{{else}}- {{#if @sortable}}- <button aria-pressed={{this.isSorting}}>- {{this.localizedName}}- {{#if this.isSorting}}- {{icon (if @ascending "chevron-up" "chevron-down")}}- {{/if}}- </button>- {{else}}- <span class={{if @screenreaderOnly "sr-only"}}>- {{this.localizedName}}- </span>- {{/if}}+ <span class={{if @screenreaderOnly "sr-only"}}>+ {{this.localizedName}}+ </span>{{/if}}{{/unless}}diff --git a/app/assets/javascripts/discourse/app/components/topic-list/header/topic-cell.gjs b/app/assets/javascripts/discourse/app/components/topic-list/header/topic-cell.gjsindex ef804db872e..c0d93833fba 100644--- a/app/assets/javascripts/discourse/app/components/topic-list/header/topic-cell.gjs+++ b/app/assets/javascripts/discourse/app/components/topic-list/header/topic-cell.gjs@@ -12,12 +12,7 @@ const TopicCell = <template>@showBulkToggle={{@showBulkToggle}}@canBulkSelect={{@canBulkSelect}}@canDoBulkActions={{@canDoBulkActions}}- @showTopicsAndRepliesToggle={{@showTopicsAndRepliesToggle}}- @newListSubset={{@newListSubset}}- @newRepliesCount={{@newRepliesCount}}- @newTopicsCount={{@newTopicsCount}}@bulkSelectHelper={{@bulkSelectHelper}}- @changeNewListSubset={{@changeNewListSubset}}/></template>;diff --git a/app/assets/javascripts/discourse/app/components/topic-list/list.gjs b/app/assets/javascripts/discourse/app/components/topic-list/list.gjsindex dbc653fb052..13381da1da7 100644--- a/app/assets/javascripts/discourse/app/components/topic-list/list.gjs+++ b/app/assets/javascripts/discourse/app/components/topic-list/list.gjs@@ -208,11 +208,6 @@ export default class TopicList extends Component {@bulkSelectHelper={{@bulkSelectHelper}}@bulkSelectEnabled={{this.bulkSelectEnabled}}@canDoBulkActions={{this.canDoBulkActions}}- @showTopicsAndRepliesToggle={{@showTopicsAndRepliesToggle}}- @newListSubset={{@newListSubset}}- @newRepliesCount={{@newRepliesCount}}- @newTopicsCount={{@newTopicsCount}}- @changeNewListSubset={{@changeNewListSubset}}/></thead>diff --git a/app/assets/javascripts/discourse/app/components/topic-list/new-list-header-controls.gjs b/app/assets/javascripts/discourse/app/components/topic-list/new-list-header-controls.gjsindex 71d5237110c..82412908a25 100644--- a/app/assets/javascripts/discourse/app/components/topic-list/new-list-header-controls.gjs+++ b/app/assets/javascripts/discourse/app/components/topic-list/new-list-header-controls.gjs@@ -37,57 +37,38 @@ export default class NewListHeaderControls extends Component {}}- get staticLabel() {- if (- this.args.noStaticLabel ||- (this.args.newTopicsCount > 0 && this.args.newRepliesCount > 0)- ) {- return;- }-- if (this.args.newTopicsCount > 0) {- return this.topicsButtonLabel;- } else {- return this.repliesButtonLabel;- }- }-<template>- {{#if this.staticLabel}}- <span class="static-label">{{this.staticLabel}}</span>- {{else}}- <button- {{on "click" (fn @changeNewListSubset null)}}- class={{concatClass- "topics-replies-toggle --all"- (if this.allActive "active")- }}- title={{i18n "filters.new.all_tooltip"}}- >- {{i18n "filters.new.all"}}- </button>+ <button+ {{on "click" (fn @changeNewListSubset null)}}+ class={{concatClass+ "topics-replies-toggle --all"+ (if this.allActive "active")+ }}+ title={{i18n "filters.new.all_tooltip"}}+ >+ {{i18n "filters.new.all"}}+ </button>- <button- {{on "click" (fn @changeNewListSubset "topics")}}- class={{concatClass- "topics-replies-toggle --topics"- (if this.topicsActive "active")- }}- title={{i18n "filters.new.new_topics_tooltip"}}- >- {{this.topicsButtonLabel}}- </button>+ <button+ {{on "click" (fn @changeNewListSubset "topics")}}+ class={{concatClass+ "topics-replies-toggle --topics"+ (if this.topicsActive "active")+ }}+ title={{i18n "filters.new.new_topics_tooltip"}}+ >+ {{this.topicsButtonLabel}}+ </button>- <button- {{on "click" (fn @changeNewListSubset "replies")}}- class={{concatClass- "topics-replies-toggle --replies"- (if this.repliesActive "active")- }}- title={{i18n "filters.new.new_replies_tooltip"}}- >- {{this.repliesButtonLabel}}- </button>- {{/if}}+ <button+ {{on "click" (fn @changeNewListSubset "replies")}}+ class={{concatClass+ "topics-replies-toggle --replies"+ (if this.repliesActive "active")+ }}+ title={{i18n "filters.new.new_replies_tooltip"}}+ >+ {{this.repliesButtonLabel}}+ </button></template>}diff --git a/app/assets/stylesheets/desktop/topic-list.scss b/app/assets/stylesheets/desktop/topic-list.scssindex 673c50faea7..ed2b8c8eb7f 100644--- a/app/assets/stylesheets/desktop/topic-list.scss+++ b/app/assets/stylesheets/desktop/topic-list.scss@@ -77,19 +77,6 @@}}- .topics-replies-toggle {- background: none;- border: none;- line-height: var(--line-height-large);- padding-left: var(--space-2);- padding-right: var(--space-2);- position: relative;-- &.active {- @include nav-active;- }- }-$td-posters-height: 29px; // min-height of td with avatar glow$td-posters-more-lh: $td-posters-height - 4;@@ -291,6 +278,20 @@}}+.topic-replies-toggle-wrapper {+ .topics-replies-toggle {+ background: none;+ border: none;+ line-height: var(--line-height-large);+ padding: var(--space-2);+ position: relative;++ &.active {+ @include nav-active;+ }+ }+}+@include viewport.until(lg) {.nav-pills {> li > a {diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 525d64bed00..d6cc8fcda13 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3701,6 +3701,8 @@ en:browse_all_categories_latest_or_top: "<a href='%{basePath}/categories'>Browse all categories</a>, <a href='%{basePath}/latest'>view latest topics</a> or see top:"browse_all_tags_or_latest: "<a href='%{basePath}/tags'>Browse all tags</a> or <a href='%{basePath}/latest'>view latest topics</a>."browse_latest_topics: "Browse latest topics"+ browse_new_replies: "Browse new replies"+ browse_new_topics: "Browse new topics"suggest_create_topic: Ready to <a href>start a new conversation?</a>jump_reply: "Jump to post's original location"diff --git a/spec/system/page_objects/components/empty_state.rb b/spec/system/page_objects/components/empty_state.rbnew file mode 100644index 00000000000..ecadc5b1caa--- /dev/null+++ b/spec/system/page_objects/components/empty_state.rb@@ -0,0 +1,15 @@+# frozen_string_literal: true++module PageObjects+ module Components+ class EmptyState < PageObjects::Components::Base+ def has_cta_text?(text)+ has_css?(".empty-state__cta", text: text)+ end++ def click_cta+ find(".empty-state__cta").click+ end+ end+ end+enddiff --git a/spec/system/page_objects/components/new_topic_list_toggle.rb b/spec/system/page_objects/components/new_topic_list_toggle.rbindex fd93d0367e7..b71ed47677f 100644--- a/spec/system/page_objects/components/new_topic_list_toggle.rb+++ b/spec/system/page_objects/components/new_topic_list_toggle.rb@@ -13,6 +13,10 @@ module PageObjectshas_no_css?(COMMON_SELECTOR)end+ def rendered?+ has_css?(COMMON_SELECTOR)+ end+def all_tab@all_tab ||= PageObjects::Components::NewTopicListToggleTab.new("all", ALL_SELECTOR)enddiff --git a/spec/system/new_topic_list_spec.rb b/spec/system/unified_new_topic_list_spec.rbsimilarity index 85%rename from spec/system/new_topic_list_spec.rbrename to spec/system/unified_new_topic_list_spec.rbindex 8769fdc7b5b..92dee105f28 100644--- a/spec/system/new_topic_list_spec.rb+++ b/spec/system/unified_new_topic_list_spec.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-describe "New topic list", type: :system do+describe "Unified new topic list", type: :system dofab!(:user)fab!(:group) { Fabricate(:group, users: [user]) }fab!(:category)@@ -26,11 +26,12 @@ describe "New topic list", type: :system dolet(:topic_list) { PageObjects::Components::TopicList.new }let(:tabs_toggle) { PageObjects::Components::NewTopicListToggle.new }+ let(:empty_state) { PageObjects::Components::EmptyState.new }before { sign_in(user) }shared_examples "new list new topics and replies toggle" do- context "when the new new view is enabled" do+ context "when unified new is enabled" dobefore { SiteSetting.experimental_new_new_view_groups = group.name }it "shows all new topics and replies by default" do@@ -302,7 +303,7 @@ describe "New topic list", type: :system doendend- context "when the new new view is not enabled" do+ context "when unified new is not enabled" dobefore { SiteSetting.experimental_new_new_view_groups = "" }it "doesn't show the tabs toggle" do@@ -324,15 +325,23 @@ describe "New topic list", type: :system doendend- it "keeps the Topics tab even when there are no new topics" do+ it "shows All, Topics, and Replies tabs" dovisit("/new")+ expect(tabs_toggle).to be_renderedexpect(tabs_toggle.all_tab).to be_visibleexpect(tabs_toggle.replies_tab).to be_visibleexpect(tabs_toggle.topics_tab).to be_visible+ end- expect(tabs_toggle.replies_tab).to have_count(3)- expect(tabs_toggle.topics_tab).to have_count(0)+ it "shows a CTA to show replies when on the new topics tab" do+ visit("/new?subset=topics")++ expect(empty_state).to have_cta_text(I18n.t("js.topic.browse_new_replies"))+ empty_state.click_cta++ expect(tabs_toggle.replies_tab).to be_active+ expect(page).to have_current_path("/new?subset=replies")endend@@ -345,15 +354,23 @@ describe "New topic list", type: :system doendend- it "keeps the Replies tab even when there are no new replies" do+ it "shows All, Topics, and Replies tabs" dovisit("/new")+ expect(tabs_toggle).to be_renderedexpect(tabs_toggle.all_tab).to be_visibleexpect(tabs_toggle.replies_tab).to be_visibleexpect(tabs_toggle.topics_tab).to be_visible+ end- expect(tabs_toggle.replies_tab).to have_count(0)- expect(tabs_toggle.topics_tab).to have_count(3)+ it "shows a CTA to show topics when on the new replies tab" do+ visit("/new?subset=replies")++ expect(empty_state).to have_cta_text(I18n.t("js.topic.browse_new_topics"))+ empty_state.click_cta++ expect(tabs_toggle.topics_tab).to be_active+ expect(page).to have_current_path("/new?subset=topics")endendend@@ -370,13 +387,23 @@ describe "New topic list", type: :system doendend- it "doesn't render the toggle and only shows a static label for new topics" do+ it "shows All, Topics, and Replies tabs" dovisit("/new")- expect(tabs_toggle).to be_not_rendered- expect(find(".topic-list-header .static-label").text).to eq(- I18n.t("js.filters.new.topics_with_count", count: 3),- )+ expect(tabs_toggle).to be_rendered+ expect(tabs_toggle.all_tab).to be_visible+ expect(tabs_toggle.replies_tab).to be_visible+ expect(tabs_toggle.topics_tab).to be_visible+ end++ it "shows a CTA to show topics when on the new replies tab" do+ visit("/new?subset=replies")++ expect(empty_state).to have_cta_text(I18n.t("js.topic.browse_new_topics"))+ empty_state.click_cta++ expect(tabs_toggle.topics_tab).to be_active+ expect(page).to have_current_path("/new?subset=topics")endend@@ -389,13 +416,23 @@ describe "New topic list", type: :system doendend- it "doesn't render the toggle and only shows a static label for new replies" do+ it "shows All, Topics, and Replies tabs" dovisit("/new")- expect(tabs_toggle).to be_not_rendered- expect(find(".topic-list-header .static-label").text).to eq(- I18n.t("js.filters.new.replies_with_count", count: 3),- )+ expect(tabs_toggle).to be_rendered+ expect(tabs_toggle.all_tab).to be_visible+ expect(tabs_toggle.replies_tab).to be_visible+ expect(tabs_toggle.topics_tab).to be_visible+ end++ it "shows a CTA to show replies when on the new topics tab" do+ visit("/new?subset=topics")++ expect(empty_state).to have_cta_text(I18n.t("js.topic.browse_new_replies"))+ empty_state.click_cta++ expect(tabs_toggle.replies_tab).to be_active+ expect(page).to have_current_path("/new?subset=replies")endendend