Skip to content

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

FIX: Notifications for upcoming changes not updating filter (#39680)

Martin Brennan079504daac18
diff --git a/frontend/discourse/admin/components/admin-filter-controls.gjs b/frontend/discourse/admin/components/admin-filter-controls.gjs
index 9e0d79a5646..8524fd753fb 100644
--- a/frontend/discourse/admin/components/admin-filter-controls.gjs
+++ b/frontend/discourse/admin/components/admin-filter-controls.gjs
@@ -10,6 +10,7 @@ import DSelect from "discourse/components/d-select";
import FilterInput from "discourse/components/filter-input";
import concatClass from "discourse/helpers/concat-class";
import { isTesting } from "discourse/lib/environment";
+import { resettableTracked } from "discourse/lib/tracked-tools";
import { and, not } from "discourse/truth-helpers";
/**
@@ -38,10 +39,12 @@ import { and, not } from "discourse/truth-helpers";
*/
export default class AdminFilterControls extends Component {
- @tracked textFilter = "";
@tracked dropdownFilter = "all";
@tracked
showFilterDropdowns = this.args.filterDropdownsExpanded ?? isTesting();
+ @resettableTracked
+ textFilter = this.args.initialTextFilter?.replace(/,\s*/g, ", ") || "";
+
dropdownFilters = trackedObject();
constructor() {
@@ -182,10 +185,6 @@ export default class AdminFilterControls extends Component {
@action
setupComponent() {
- if (this.args.initialTextFilter) {
- this.textFilter = this.args.initialTextFilter.replace(/,\s*/g, ", ");
- }
-
if (this.hasMultipleDropdowns) {
Object.keys(this.dropdownOptions).forEach((key) => {
this.dropdownFilters[key] = this.defaultValue(key);
diff --git a/spec/system/admin_upcoming_changes_spec.rb b/spec/system/admin_upcoming_changes_spec.rb
index 8f1f5a49727..d83a2154c7d 100644
--- a/spec/system/admin_upcoming_changes_spec.rb
+++ b/spec/system/admin_upcoming_changes_spec.rb
@@ -263,6 +263,47 @@ describe "Admin upcoming changes" do
upcoming_changes_page.filter_controls.select_all_dropdown_option(dropdown_id: "enabled")
end
+ it "updates the filter when a notification is clicked while already on the page" do
+ user_menu = PageObjects::Components::UserMenu.new
+
+ Fabricate(
+ :notification,
+ user: current_user,
+ notification_type: Notification.types[:upcoming_change_available],
+ data: {
+ upcoming_change_names: ["enable_upload_debug_mode"],
+ upcoming_change_humanized_names: [
+ SiteSettings::LabelFormatter.humanized_name(:enable_upload_debug_mode),
+ ],
+ count: 1,
+ }.to_json,
+ )
+ Fabricate(
+ :notification,
+ user: current_user,
+ notification_type: Notification.types[:upcoming_change_available],
+ data: {
+ upcoming_change_names: ["about_page_extra_groups_show_description"],
+ upcoming_change_humanized_names: [
+ SiteSettings::LabelFormatter.humanized_name(:about_page_extra_groups_show_description),
+ ],
+ count: 1,
+ }.to_json,
+ )
+
+ visit "/"
+
+ user_menu.open.click_notification_with_href("enable_upload_debug_mode")
+
+ expect(upcoming_changes_page).to have_change(:enable_upload_debug_mode)
+ expect(upcoming_changes_page).to have_no_change(:about_page_extra_groups_show_description)
+
+ user_menu.open.click_notification_with_href("about_page_extra_groups_show_description")
+
+ expect(upcoming_changes_page).to have_change(:about_page_extra_groups_show_description)
+ expect(upcoming_changes_page).to have_no_change(:enable_upload_debug_mode)
+ end
+
it "displays a notification dot on the sidebar and clears it when navigating to upcoming changes" do
sidebar = PageObjects::Components::NavigationMenu::Sidebar.new
diff --git a/spec/system/page_objects/components/user_menu.rb b/spec/system/page_objects/components/user_menu.rb
index a37e7c7a266..0fd854c46d1 100644
--- a/spec/system/page_objects/components/user_menu.rb
+++ b/spec/system/page_objects/components/user_menu.rb
@@ -38,6 +38,11 @@ module PageObjects
self
end
+ def click_notification_with_href(href_substring)
+ find(".user-menu .notification a[href*='#{href_substring}']").click
+ self
+ end
+
def sign_out
open
click_profile_tab