FIX: dismiss new button for tags on top (#12628)

FIX: dismiss new button for tags on top (#12628)

Currently, new topics for specific tags can be dismissed with the button at the bottom of the page.

When there is more than 15 new topics, we should display the same button at the top as well. It already works in the same manner for categories.

diff --git a/app/assets/javascripts/discourse/app/controllers/tag-show.js b/app/assets/javascripts/discourse/app/controllers/tag-show.js
index f3544c5..0bf4cec 100644
--- a/app/assets/javascripts/discourse/app/controllers/tag-show.js
+++ b/app/assets/javascripts/discourse/app/controllers/tag-show.js
@@ -110,6 +110,15 @@ export default Controller.extend(BulkTopicSelection, FilterModeMixin, {
     return this.isFilterPage(filter, "new") && topicsLength > 0;
   },
 
+  @discourseComputed("list.filter", "list.topics.length")
+  showDismissAtTop(filter, topicsLength) {
+    return (
+      (this.isFilterPage(filter, "new") ||
+        this.isFilterPage(filter, "unread")) &&
+      topicsLength >= 15
+    );
+  },
+
   actions: {
     dismissReadPosts() {
       showModal("dismiss-read", { title: "topics.bulk.dismiss_read" });
diff --git a/app/assets/javascripts/discourse/app/templates/tags/show.hbs b/app/assets/javascripts/discourse/app/templates/tags/show.hbs
index ebd7b75..0837c85 100644
--- a/app/assets/javascripts/discourse/app/templates/tags/show.hbs
+++ b/app/assets/javascripts/discourse/app/templates/tags/show.hbs
@@ -2,7 +2,6 @@
   <div class="container">
     {{discourse-banner user=currentUser banner=site.banner}}
   </div>
-
   <div class="list-controls">
     <div class="container">
       <section class="navigation-container tag-navigation">
@@ -32,6 +31,28 @@
 
   {{plugin-outlet name="discovery-list-container-top" args=(hash category=category)}}
 
+  {{#if showDismissAtTop}}
+    <div class="row dismiss-container-top">
+      {{#if showDismissRead}}
+        {{d-button
+          class="btn-default dismiss-read"
+          id="dismiss-topics"
+          action=(action "dismissReadPosts")
+          title="topics.bulk.dismiss_tooltip"
+          label="topics.bulk.dismiss_button"}}
+        {{/if}}
+
+        {{#if showResetNew}}
+          {{d-button
+            class="btn-default dismiss-read"
+            action=(action "resetNew")
+            id="dismiss-new"
+            icon="check"
+            label="topics.bulk.dismiss_new"}}
+        {{/if}}
+    </div>
+  {{/if}}
+
   <div class="container list-container">
     <div class="row">
       <div class="full-width">

GitHub sha: 8b735e6f

This commit appears in #12628 which was approved by CvX. It was merged by lis2.