Skip to content

A platform for community discussion. Free, open, simple.

FIX: Unify dismiss new topics code path and toggle off bulk select (#38835)

Régis Hanol9707c5430da3
diff --git a/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs b/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
index cf190c5b079..9a271b82606 100644
--- a/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
+++ b/frontend/discourse/app/components/bulk-select-topics-dropdown.gjs
@@ -7,7 +7,6 @@ import DropdownMenu from "discourse/components/dropdown-menu";
import BulkTopicActions, {
addBulkDropdownAction,
} from "discourse/components/modal/bulk-topic-actions";
-import DismissNew from "discourse/components/modal/dismiss-new";
import DismissReadModal from "discourse/components/modal/dismiss-read";
import DMenu from "discourse/float-kit/components/d-menu";
import concatClass from "discourse/helpers/concat-class";
@@ -238,12 +237,7 @@ export default class BulkSelectTopicsDropdown extends Component {
});
break;
case "dismiss-new":
- this.modal.show(DismissNew, {
- model: {
- selectedTopics: this.args.bulkSelectHelper.selected,
- dismissCallback: (dismissTopics) => this.dismissRead(dismissTopics),
- },
- });
+ this.args.bulkSelectHelper.onResetNew?.();
break;
case "update-category":
this.showBulkTopicActionsModal(actionId, "change_category", {
diff --git a/frontend/discourse/app/controllers/discovery/list.js b/frontend/discourse/app/controllers/discovery/list.js
index 268d8a90732..7e611c1eeff 100644
--- a/frontend/discourse/app/controllers/discovery/list.js
+++ b/frontend/discourse/app/controllers/discovery/list.js
@@ -65,6 +65,8 @@ export default class DiscoveryListController extends Controller {
for (const [name, info] of Object.entries(queryParams)) {
defineTrackedProperty(this, name, info.default);
}
+
+ this.bulkSelectHelper.onResetNew = () => this.resetNew();
}
// NOTE: (martin) Please keep this in tact for now, will remove once we have
@@ -156,6 +158,8 @@ export default class DiscoveryListController extends Controller {
if (result.topic_ids) {
this.topicTrackingState.removeTopics(result.topic_ids);
}
+ this.bulkSelectHelper.bulkSelectEnabled = false;
+ this.bulkSelectHelper.clear();
this.router.refresh();
}
diff --git a/frontend/discourse/app/lib/bulk-select-helper.js b/frontend/discourse/app/lib/bulk-select-helper.js
index 83fbfe50a1a..a5dec19f304 100644
--- a/frontend/discourse/app/lib/bulk-select-helper.js
+++ b/frontend/discourse/app/lib/bulk-select-helper.js
@@ -50,6 +50,14 @@ export default class BulkSelectHelper {
this._onBulkSelectToggle = callback;
}
+ get onResetNew() {
+ return this._onResetNew;
+ }
+
+ set onResetNew(callback) {
+ this._onResetNew = callback;
+ }
+
get selectedCategoryIds() {
return uniqueItemsFromArray(this.selected.map((item) => item.category_id));
}
diff --git a/spec/system/topic_bulk_select_spec.rb b/spec/system/topic_bulk_select_spec.rb
index b51411e5d30..10c437a5c5f 100644
--- a/spec/system/topic_bulk_select_spec.rb
+++ b/spec/system/topic_bulk_select_spec.rb
@@ -69,43 +69,75 @@ describe "Topic bulk select" do
end
context "when dismissing new topics" do
- fab!(:topic) { Fabricate(:topic, user: user) }
- fab!(:post1) { create_post(user: user, topic: topic) }
+ fab!(:topic) { Fabricate(:topic, user:) }
+ fab!(:post1) { create_post(user:, topic:) }
- it "removes the topics from the list" do
- sign_in(admin)
- visit("/new")
+ let(:topic_list_controls) { PageObjects::Components::TopicListControls.new }
- topic_list_header.click_bulk_select_button
- expect(topic_list).to have_topic_checkbox(topic)
+ context "with the bulk actions dropdown" do
+ it "removes the topics from the list" do
+ sign_in(admin)
+ visit("/new")
- topic_list.click_topic_checkbox(topic)
+ topic_list_header.click_bulk_select_button
+ expect(topic_list).to have_topic_checkbox(topic)
- topic_list_header.click_bulk_select_topics_dropdown
- topic_list_header.click_bulk_button("dismiss-new")
+ topic_list.click_topic_checkbox(topic)
- topic_bulk_actions_modal.click_dismiss_confirm
+ topic_list_header.click_bulk_select_topics_dropdown
+ topic_list_header.click_bulk_button("dismiss-new")
+
+ expect(page).to have_text(I18n.t("js.topics.none.education.new"))
+ end
+
+ it "turns off bulk select after dismissing" do
+ other_topic = Fabricate(:topic, user:)
+ create_post(user:, topic: other_topic)
+
+ sign_in(admin)
+ visit("/new")
+
+ topic_list_header.click_bulk_select_button
+ topic_list.click_topic_checkbox(topic)
+
+ topic_list_header.click_bulk_select_topics_dropdown
+ topic_list_header.click_bulk_button("dismiss-new")
- expect(page).to have_text(I18n.t("js.topics.none.education.new"))
+ expect(topic_list).to have_topic(other_topic)
+ expect(topic_list).to have_no_topic_checkbox(other_topic)
+ end
end
- it "turns off bulk select after dismissing" do
- other_topic = Fabricate(:topic, user: user)
- create_post(user: user, topic: other_topic)
+ context "with the dismiss new button" do
+ it "removes the topics from the list" do
+ sign_in(admin)
+ visit("/new")
- sign_in(admin)
- visit("/new")
+ topic_list_header.click_bulk_select_button
+ expect(topic_list).to have_topic_checkbox(topic)
- topic_list_header.click_bulk_select_button
- topic_list.click_topic_checkbox(topic)
+ topic_list.click_topic_checkbox(topic)
- topic_list_header.click_bulk_select_topics_dropdown
- topic_list_header.click_bulk_button("dismiss-new")
+ topic_list_controls.dismiss_new
- topic_bulk_actions_modal.click_dismiss_confirm
+ expect(page).to have_text(I18n.t("js.topics.none.education.new"))
+ end
- expect(topic_list).to have_topic(other_topic)
- expect(topic_list).to have_no_topic_checkbox(other_topic)
+ it "turns off bulk select after dismissing" do
+ other_topic = Fabricate(:topic, user:)
+ create_post(user:, topic: other_topic)
+
+ sign_in(admin)
+ visit("/new")
+
+ topic_list_header.click_bulk_select_button
+ topic_list.click_topic_checkbox(topic)
+
+ topic_list_controls.dismiss_new
+
+ expect(topic_list).to have_topic(other_topic)
+ expect(topic_list).to have_no_topic_checkbox(other_topic)
+ end
end
end