From e096ddc999dc4e262420df90d8fce79e03d3b414 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Tue, 9 May 2023 22:51:40 +0200 Subject: [PATCH] Prevent links from notifications from being opened in the dropdown frame --- app/helpers/user_helper.rb | 6 +++--- app/views/notifications/type/_answer.html.haml | 2 +- app/views/notifications/type/_comment.html.haml | 6 +++--- app/views/notifications/type/_dataexport.html.haml | 2 +- app/views/notifications/type/_follow.html.haml | 2 +- app/views/notifications/type/_reaction.html.haml | 4 ++-- app/views/notifications/type/_webpushsubscription.html.haml | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index a494a4d1..5d487409 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -12,7 +12,7 @@ module UserHelper if url return user_path(user) if link_only - return profile_link(user) + return profile_link(user, "_top") end user.profile.safe_name.strip end @@ -23,8 +23,8 @@ module UserHelper private - def profile_link(user) - link_to(user.profile.safe_name, user_path(user), class: ("user--banned" if user.banned?).to_s) + def profile_link(user, target = nil) + link_to(user.profile.safe_name, user_path(user), class: ("user--banned" if user.banned?).to_s, target:) end def should_unmask?(author_identifier) diff --git a/app/views/notifications/type/_answer.html.haml b/app/views/notifications/type/_answer.html.haml index bef0030a..ff2cc2a9 100644 --- a/app/views/notifications/type/_answer.html.haml +++ b/app/views/notifications/type/_answer.html.haml @@ -6,7 +6,7 @@ %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small), loading: :lazy } = t(".heading_html", user: user_screen_name(notification.target.user), - question: link_to(t(".link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.id)), + question: link_to(t(".link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.id), target: "_top"), time: time_tooltip(notification.target)) .list-group .list-group-item diff --git a/app/views/notifications/type/_comment.html.haml b/app/views/notifications/type/_comment.html.haml index 26cb55cd..325ceb61 100644 --- a/app/views/notifications/type/_comment.html.haml +++ b/app/views/notifications/type/_comment.html.haml @@ -7,17 +7,17 @@ - if notification.target.answer.user == current_user = t(".heading_html", user: user_screen_name(notification.target.user), - answer: link_to(t(".active.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + answer: link_to(t(".active.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), target: "_top"), time: time_tooltip(notification.target)) - elsif notification.target.user == notification.target.answer.user = t(".heading_html", user: user_screen_name(notification.target.user), - answer: link_to(t(".passive.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + answer: link_to(t(".passive.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), target: "_top"), time: time_tooltip(notification.target)) - else = t(".heading_html", user: user_screen_name(notification.target.user), - answer: link_to(t(".other.link_text_html", user: user_screen_name(notification.target.answer.user, url: false)), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + answer: link_to(t(".other.link_text_html", user: user_screen_name(notification.target.answer.user, url: false)), answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), target: "_top"), time: time_tooltip(notification.target)) .list-group .list-group-item diff --git a/app/views/notifications/type/_dataexport.html.haml b/app/views/notifications/type/_dataexport.html.haml index 3da53c4c..eeffef10 100644 --- a/app/views/notifications/type/_dataexport.html.haml +++ b/app/views/notifications/type/_dataexport.html.haml @@ -5,4 +5,4 @@ %h6.notification__user = t(".heading") .notification__text - = t(".text_html", settings_export: link_to(t(".settings_export"), settings_export_path)) + = t(".text_html", settings_export: link_to(t(".settings_export"), settings_export_path, target: "_top")) diff --git a/app/views/notifications/type/_follow.html.haml b/app/views/notifications/type/_follow.html.haml index ec44fc56..0994b6de 100644 --- a/app/views/notifications/type/_follow.html.haml +++ b/app/views/notifications/type/_follow.html.haml @@ -5,4 +5,4 @@ %h6.notification__user = user_screen_name notification.target.source .notification__text - = t(".heading_html", time: time_ago_in_words(notification.target.created_at)) + = t(".heading_html", time: time_ago_in_words(notification.target.created_at), target: "_top") diff --git a/app/views/notifications/type/_reaction.html.haml b/app/views/notifications/type/_reaction.html.haml index 8462dd88..08716738 100644 --- a/app/views/notifications/type/_reaction.html.haml +++ b/app/views/notifications/type/_reaction.html.haml @@ -7,12 +7,12 @@ - if notification.target.parent_type == 'Answer' = t(".heading_html", user: user_screen_name(notification.target.user), - type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.parent.id)), + type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.parent.id), target: "_top"), time: time_tooltip(notification.target)) - elsif notification.target.parent_type == 'Comment' = t(".heading_html", user: user_screen_name(notification.target.user), - type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.parent.answer.id)), + type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), answer_path(username: notification.target.user.screen_name, id: notification.target.parent.answer.id), target: "_top"), time: time_tooltip(notification.target)) .list-group .list-group-item diff --git a/app/views/notifications/type/_webpushsubscription.html.haml b/app/views/notifications/type/_webpushsubscription.html.haml index b077f489..599130ce 100644 --- a/app/views/notifications/type/_webpushsubscription.html.haml +++ b/app/views/notifications/type/_webpushsubscription.html.haml @@ -7,4 +7,4 @@ %h6.notification__user = t(".heading") .notification__text - = t(".text_html", settings_push: link_to(t(".settings_push"), settings_push_notifications_path)) + = t(".text_html", settings_push: link_to(t(".settings_push"), settings_push_notifications_path, target: "_top"))