[74342] Issues in work package sharing notification email (#22918)

* Escape sharing info in mail correctly

* Localize the shared permissions in the mail

* Replace custom method with builtin `to_sentence`

* Restructure sentence and use verbs explicitly for better wording in other languages
This commit is contained in:
Henriette Darge
2026-04-30 11:11:41 +02:00
committed by GitHub
parent 823194a1c1
commit ff4bbd9437
3 changed files with 16 additions and 13 deletions
+9 -9
View File
@@ -32,7 +32,7 @@ class SharingMailer < ApplicationMailer
include MailNotificationHelper
helper :mail_notification
def shared_work_package(sharer, membership, group = nil)
def shared_work_package(sharer, membership, group = nil) # rubocop:disable Metrics/AbcSize
@sharer = sharer
@shared_with_user = membership.principal
@invitation_token = @shared_with_user.invited? ? @shared_with_user.invitation_token : nil
@@ -40,8 +40,6 @@ class SharingMailer < ApplicationMailer
@work_package = membership.entity
role = membership.roles.first
@role_rights = derive_role_rights(role)
@allowed_work_package_actions = derive_allowed_work_package_actions(role)
@url = optionally_activated_url(work_package_url(@work_package.id), @invitation_token)
@notification_url = optionally_activated_url(details_notifications_url(@work_package.id, tab: :activity), @invitation_token)
@@ -49,6 +47,8 @@ class SharingMailer < ApplicationMailer
message_id(membership, sharer)
send_localized_mail(@shared_with_user) do
@role_rights = derive_role_rights(role)
@allowed_work_package_actions = derive_allowed_work_package_actions(role)
I18n.t("mail.sharing.work_packages.subject", id: @work_package.id)
end
end
@@ -79,14 +79,14 @@ class SharingMailer < ApplicationMailer
allowed_actions =
case role.builtin
when Role::BUILTIN_WORK_PACKAGE_EDITOR
[I18n.t("work_package.permissions.view"),
I18n.t("work_package.permissions.comment"),
I18n.t("work_package.permissions.edit")]
[I18n.t("work_package.permissions.view_verb"),
I18n.t("work_package.permissions.comment_verb"),
I18n.t("work_package.permissions.edit_verb")]
when Role::BUILTIN_WORK_PACKAGE_COMMENTER
[I18n.t("work_package.permissions.view"),
I18n.t("work_package.permissions.comment")]
[I18n.t("work_package.permissions.view_verb"),
I18n.t("work_package.permissions.comment_verb")]
when Role::BUILTIN_WORK_PACKAGE_VIEWER
[I18n.t("work_package.permissions.view")]
[I18n.t("work_package.permissions.view_verb")]
end
allowed_actions.map(&:downcase)
@@ -36,9 +36,9 @@
<tr>
<td style="<%= placeholder_text_styles %>">
<%
allowed_actions = @allowed_work_package_actions.map do |action|
content_tag(:span, action.downcase, class: "-bold")
end.to_sentence
allowed_actions = to_sentence(
@allowed_work_package_actions.map { |action| content_tag(:span, action, style: "font-weight: bold") }
)
%>
<%= t("mail.sharing.work_packages.allowed_actions_html", allowed_actions:) %>
+4 -1
View File
@@ -4616,7 +4616,7 @@ en:
note: "Note: “%{note}”"
sharing:
work_packages:
allowed_actions_html: "You may %{allowed_actions} this work package. This can change depending on your project role and permissions."
allowed_actions_html: "You have the following permissions on this work package: %{allowed_actions}. This can change depending on your project role and permissions."
create_account: "To access this work package, you will need to create and activate an account on %{instance}."
open_work_package: "Open work package"
subject: "Work package #%{id} was shared with you"
@@ -5970,10 +5970,13 @@ en:
same_as_work: "Set to same value as Work."
permissions:
comment: "Comment"
comment_verb: "comment"
comment_description: "Can view and comment this work package."
edit: "Edit"
edit_verb: "edit"
edit_description: "Can view, comment and edit this work package."
view: "View"
view_verb: "view"
view_description: "Can view this work package."
reminders:
label_remind_at: "Date"