OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Keep filters when switching facets in notifications
Oliver Günther4a6b0370d914
diff --git a/app/components/notifications/index_sub_header_component.html.erb b/app/components/notifications/index_sub_header_component.html.erbindex aa16a09e10d..3554007d2c7 100644--- a/app/components/notifications/index_sub_header_component.html.erb+++ b/app/components/notifications/index_sub_header_component.html.erb@@ -2,12 +2,12 @@subheader.with_filter_component dorender(Primer::Alpha::SegmentedControl.new("aria-label": I18n.t(:label_filter_plural))) do |control|control.with_item(tag: :a,- href: notifications_path(facet: nil),+ href: notifications_path(facet: nil, **current_filters),label: t("notifications.facets.unread"),title: t("notifications.facets.unread_title"),selected: @facet != "all")control.with_item(tag: :a,- href: notifications_path(facet: "all"),+ href: notifications_path(facet: "all", **current_filters),label: t("notifications.facets.all"),title: t("notifications.facets.all_title"),selected: @facet == "all")@@ -15,7 +15,7 @@endsubheader.with_action_button(tag: :a,- href: mark_all_read_notifications_path({ filter: @filter_type, name: @filter_name }.compact),+ href: mark_all_read_notifications_path(**current_filters),data: { method: :post },size: :medium,aria: { label: I18n.t("js.notifications.center.mark_all_read") }) do |button|diff --git a/app/components/notifications/index_sub_header_component.rb b/app/components/notifications/index_sub_header_component.rbindex 7743de89e18..6ee231797e4 100644--- a/app/components/notifications/index_sub_header_component.rb+++ b/app/components/notifications/index_sub_header_component.rb@@ -41,5 +41,9 @@ module Notifications@filter_type = filter_type@filter_name = filter_nameend++ def current_filters+ @current_filters ||= { filter: @filter_type, name: @filter_name }.compact+ endendenddiff --git a/spec/requests/notifications/notifications_spec.rb b/spec/requests/notifications/notifications_spec.rbnew file mode 100644index 00000000000..7bab45f1407--- /dev/null+++ b/spec/requests/notifications/notifications_spec.rb@@ -0,0 +1,51 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"++RSpec.describe "Notifications",+ :skip_csrf,+ type: :rails_request do+ shared_let(:user) { create(:user) }++ before do+ login_as user+ end++ describe "GET /notifications" do+ context "with filters present" do+ it "renders the facet switch with the current filters (Regression #56916)" do+ get notifications_path(filter: "reason", name: "mentioned")++ expect(page).to have_link("Show all") { |link|+ link["href"] == notifications_path(facet: "all", filter: "reason", name: "mentioned")+ }+ end+ end+ end+end