From 07d3447e7e62e3ddaecac4da1c2d60c50ea642d0 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 23 Apr 2025 14:29:13 +0200 Subject: [PATCH] Resolve notifications URLs --- app/helpers/notifications_helper.rb | 11 +---------- config/routes.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 3e06682ef..4568ad82a 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -21,7 +21,7 @@ module NotificationsHelper def notification_tag(notification, &) tag.div id: dom_id(notification), class: "notification tray__item border-radius txt-normal" do concat( - link_to(notification_resource_path(notification), + link_to(notification, class: "notification__content border-radius shadow fill-white flex align-start txt-align-start gap flex-item-grow max-width border txt-ink", data: { action: "click->dialog#close", turbo_frame: "_top" }, &) @@ -30,15 +30,6 @@ module NotificationsHelper end end - def notification_resource_path(notification) - if notification.source.action.commented? - card = notification.source.card - collection_card_path(card.collection, card, anchor: "comment_#{notification.source.comment.id}") - else - notification.source.card - end - end - def notification_mark_read_button(notification) button_to read_notification_path(notification), class: "notification__unread_indicator btn borderless", diff --git a/config/routes.rb b/config/routes.rb index 61271338a..5ff480121 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -103,6 +103,23 @@ Rails.application.routes.draw do route_for :collection_card, comment.card.collection, comment.card, options end + resolve "Mention" do |mention, options| + polymorphic_path(mention.source, options) + end + + resolve "Notification" do |notification, options| + source = if notification.source.is_a?(Event) + if notification.source.action.commented? + notification.source.comment + else + notification.source.card + end + else + notification.source + end + + polymorphic_path(source, options) + end get "up", to: "rails/health#show", as: :rails_health_check get "manifest" => "rails/pwa#manifest", as: :pwa_manifest