Resolve notifications URLs

This commit is contained in:
Jorge Manrubia
2025-04-23 14:29:13 +02:00
parent 2eae58725a
commit 07d3447e7e
2 changed files with 18 additions and 10 deletions
+1 -10
View File
@@ -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",
+17
View File
@@ -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