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
Create shared_work_package mail body
Aaron Contrerasbbbbf1b7aeab
diff --git a/app/helpers/mail_notification_helper.rb b/app/helpers/mail_notification_helper.rbindex 1af12cab37b..a81c2c0ae77 100644--- a/app/helpers/mail_notification_helper.rb+++ b/app/helpers/mail_notification_helper.rb@@ -39,6 +39,10 @@ module MailNotificationHelpernotifications_center_url(['details', id, 'activity'])end+ def shared_work_package_path(id)+ work_package_url(id)+ end+def type_color(type, default_fallback)color_id = selected_color(type)if color_iddiff --git a/app/mailers/sharing_mailer.rb b/app/mailers/sharing_mailer.rbindex b4eddad3a26..27bf0aa7d13 100644--- a/app/mailers/sharing_mailer.rb+++ b/app/mailers/sharing_mailer.rb@@ -3,8 +3,14 @@class SharingMailer < ApplicationMailerhelper :mail_notification- def shared_work_package(_sharer, membership)+ def shared_work_package(sharer, membership)+ @sharer = sharer@work_package = membership.entity++ role = membership.roles.first+ @role_rights = derive_role_rights(role)+ @allowed_work_package_actions = derive_allowed_work_package_actions(role)+recipient = membership.principalwith_locale_for(recipient) do@@ -13,4 +19,37 @@ class SharingMailer < ApplicationMailerid: @work_package.id)endend++ private++ def derive_role_rights(role)+ case role.builtin+ when Role::BUILTIN_WORK_PACKAGE_EDITOR+ I18n.t('work_package.sharing.permissions.edit')+ when Role::BUILTIN_WORK_PACKAGE_COMMENTER+ I18n.t('work_package.sharing.permissions.comment')+ when Role::BUILTIN_WORK_PACKAGE_VIEWER+ I18n.t('work_package.sharing.permissions.view')+ end+ end++ def derive_allowed_work_package_actions(role)+ allowed_actions = case role.builtin+ when Role::BUILTIN_WORK_PACKAGE_EDITOR+ [I18n.t('work_package.sharing.permissions.view'),+ I18n.t('work_package.sharing.permissions.comment'),+ I18n.t('work_package.sharing.permissions.edit')]+ when Role::BUILTIN_WORK_PACKAGE_COMMENTER+ [I18n.t('work_package.sharing.permissions.view'),+ I18n.t('work_package.sharing.permissions.comment')]+ when Role::BUILTIN_WORK_PACKAGE_VIEWER+ [I18n.t('work_package.sharing.permissions.view')]+ end++ allowed_actions = allowed_actions.map do |action|+ "<span style=\"font-weight:bold;\">#{action.downcase}</span>"+ end++ allowed_actions.to_sentence+ endenddiff --git a/app/views/sharing_mailer/_notification_mailer_body.html.erb b/app/views/sharing_mailer/_notification_mailer_body.html.erbnew file mode 100644index 00000000000..48823e63d3d--- /dev/null+++ b/app/views/sharing_mailer/_notification_mailer_body.html.erb@@ -0,0 +1,75 @@+<table <%= placeholder_table_styles(width:'100%', style: "width:100%;min-width:100%") %>>+ <tr>+ <td>+ <table <%= placeholder_table_styles(width:'100%', style: "width:100%;min-width:100%") %>>+ <tr>+ <td>+ <span>+ <%= salutation %>+ </span>+ </td>+ </tr>++ <tr>+ <%= placeholder_cell('40px', vertical: false) %>+ </tr>++ <tr>+ <td>+ <span style="color: #1A67A3;">+ <%= sharer.name %>+ </span>+ <span>+ <%= t('mail.sharing.work_packages.reason', role_rights: role_rights) %>+ </span>+ </td>+ </tr>++ </table>+ </td>+ </tr>+ <tr>+ <%= placeholder_cell('16px', vertical: false) %>+ </tr>+ <tr>+ <td>+ <%= render layout: 'sharing_mailer/notification_row',+ locals: {+ work_package: work_package,+ unique_reasons: [nil],+ show_count: false,+ } do %>+ <table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>+ <tr>+ <td style="<%= placeholder_text_styles %>">+ <%= t('mail.sharing.work_packages.allowed_actions', allowed_actions: allowed_work_package_actions).html_safe %>+ </td>+ </tr>+ </table>+ <% end %>+ </td>+ </tr>+ <tr>+ <%= placeholder_cell('24px', vertical: false) %>+ </tr>++ <tr>+ <td>+ <span>+ <%= t('mail.sharing.work_packages.support_text', contact_us_link: '<a style="color: #1A67A3;text-decoration: none;" href="mailto:[email protected]" target="_blank">contact us</a>').html_safe %>+ </span>+ </td>+ </tr>++ <tr>+ <%= placeholder_cell('36px', vertical: false) %>+ </tr>++ <tr>+ <td>+ <span>+ <%= t('mail.sharing.work_packages.signature').html_safe %>+ </span>+ </td>+ </tr>+</table>diff --git a/app/views/sharing_mailer/_notification_mailer_header.html.erb b/app/views/sharing_mailer/_notification_mailer_header.html.erbindex 880fe97da2f..d127b1b0cfc 100644--- a/app/views/sharing_mailer/_notification_mailer_header.html.erb+++ b/app/views/sharing_mailer/_notification_mailer_header.html.erb@@ -1,15 +1,10 @@-<!-- TODO: Remove development background set below -->-<table <%= placeholder_table_styles(width:'100%',style: "background-color:green;width:100%;min-width:100%") %>>+<table <%= placeholder_table_styles(width:'100%', style: "width:100%;min-width:100%") %>><tr><td>- <!-- TODO: Remove development background set below -->- <table <%= placeholder_table_styles(style: 'background-color:lightblue;') %>>+ <table <%= placeholder_table_styles %>><tr><td>- <!-- Content -->- <!--Start headline -->- <!-- TODO: Remove development background set below -->- <table <%= placeholder_table_styles(width:'100%',style: "width:100%;background-color:orange;") %>>+ <table <%= placeholder_table_styles(width:'100%',style: "width:100%;") %>><tr><td><table <%= placeholder_table_styles(style: 'font-size:24px;font-weight:bold') %>>@@ -39,22 +34,19 @@</span></td></tr>- <tr>- <%= placeholder_cell('40px', vertical: false) %>- </tr></table>- <!-- End headline --></td>- <!-- Logo --><td>- <%= image_tag 'icon_logo.png', style: 'height: 48px;' %>+ <%= image_tag 'icon_logo.png',+ size: '48x48',+ style: 'width:48px;height:48px;' %></td>-- <!-- End logo -->- <%= placeholder_cell('16px', vertical: true) %></tr></table></td></tr>+ <tr>+ <%= placeholder_cell('40px', vertical: false) %>+ </tr></table>diff --git a/app/views/sharing_mailer/_notification_row.html.erb b/app/views/sharing_mailer/_notification_row.html.erbnew file mode 100644index 00000000000..9999912bf71--- /dev/null+++ b/app/views/sharing_mailer/_notification_row.html.erb@@ -0,0 +1,118 @@+<%= render layout: 'mailer/border_table' do %>+ <tr>+ <td>+ <table <%= placeholder_table_styles(width:'100%',style: 'width:100%;font-size:14px;') %>>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <td>+ <table <%= placeholder_table_styles %>>+ <tr>+ <td>+ <table <%= placeholder_table_styles %>>+ <tr>+ <td style="color: #333333;+ background-color: #FFFFFF;+ <%= status_colors(work_package.status) %>+ white-space: nowrap;+ padding: 2px 12px;+ height: 18px;+ border-radius:2px;">+ <%= work_package.status %>+ </td>+ </tr>+ </table>+ </td>+ <%= placeholder_cell('8px', vertical: true) %>+ <td width="100%" style="color: #878787;">+ #<%= work_package.id %> - <%= work_package.project %>+ <%= ' - ' unless unique_reasons.length === 1 && unique_reasons.first.nil? %>+ <% unique_reasons.each_with_index do |reason, index| %>+ <%= I18n.t(+ :"mail.work_packages.reason.#{reason || :unknown}",+ default: '') %><%= ', ' unless unique_reasons.size-1 == index %>+ <% end %>+ </td>+ <td>+ <table <%= placeholder_table_styles %>>+ <tr>+ <% if show_count %>+ <td style="background-color: #00A3FF;+ color: white;+ border-radius: 10px;+ padding: 2px 8px;+ font-size: 14px;+ height: 18px;+ line-height: 18px;">+ <%= count %>+ </td>+ <% end %>+ </tr>+ </table>+ </td>+ </tr>+ </table>+ </td>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <%= placeholder_cell('16px', vertical: false) %>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <td>+ <table <%= placeholder_table_styles(style: 'font-size:16px;font-weight:bold') %>>+ <tr>+ <td style="color: <%= type_color(work_package.type, '#333333') %>;white-space: nowrap;">+ <%= work_package.type.to_s.upcase %>+ </td>+ <%= placeholder_cell('4px', vertical: true) %>+ <td width="100%" style="color: #333333;">+ <%= work_package.subject %>+ </td>+ </tr>+ </table>+ </td>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <%= placeholder_cell('12px', vertical: false) %>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <td><%= yield %></td>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ </table>+ </td>+ </tr>+<% end %>++<table>+ <tr>+ <%= placeholder_cell('12px', vertical: false) %>+ </tr>+</table>++<table>+ <tr>+ <td>+ <table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>+ <tr>+ <%= placeholder_cell('0px', vertical: false) %>+ </tr>+ </table>+ </td>++ <td>+ <a style="text-decoration:none;padding:8px 12px;color:#333333;border-width:1px;border-color:#878787;border-style:solid;border-radius:16px;white-space:nowrap;"+ href="<%= shared_work_package_path(work_package.id) %>"+ target="_blank">+ <%= I18n.t('mail.sharing.work_packages.open_work_package') %>+ </a>+ </td>+ </tr>+</table>diff --git a/app/views/sharing_mailer/shared_work_package.html.erb b/app/views/sharing_mailer/shared_work_package.html.erbindex fe34a7826e9..e3cf935e105 100644--- a/app/views/sharing_mailer/shared_work_package.html.erb+++ b/app/views/sharing_mailer/shared_work_package.html.erb@@ -1,5 +1,5 @@<table>- <tr style="background-color: orange;">+ <tr><%= placeholder_cell('20px', vertical: false) %></tr></table>@@ -17,4 +17,21 @@</td><%= placeholder_cell('12px', vertical: true) %></tr>+ <tr>+ <%= placeholder_cell('12px', vertical: true) %>+ <td>+ <%= render partial: 'sharing_mailer/notification_mailer_body',+ locals: {+ sharer: @sharer,+ salutation: I18n.t('mail.sharing.work_packages.salutation'),+ role_rights: @role_rights,+ work_package: @work_package,+ allowed_work_package_actions: @allowed_work_package_actions+ } %>+ </td>+ <%= placeholder_cell('12px', vertical: true) %>+ </tr>+ <tr>+ <%= placeholder_cell('72px', vertical: false) %>+ </tr></table>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex ac37f0b4638..4c0e0085924 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2259,6 +2259,12 @@ en:subject: 'You have been shared work package #%{id}'headline: 'Invitation to'summary: 'This work package has been shared with you'+ salutation: 'Hello,'+ reason: 'shared the following work package with you with %{role_rights} rights:'+ allowed_actions: 'You may %{allowed_actions} this work package. This can change depending on your project role and permissions.'+ open_work_package: 'Open work package'+ support_text: 'If you have any questions, please %{contact_us_link}. We are always ready to help.'+ signature: 'Sincerely<br/>The OpenProject Team'mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"diff --git a/spec/mailers/sharing_mailer_spec.rb b/spec/mailers/sharing_mailer_spec.rbindex dac11990628..508268458c5 100644--- a/spec/mailers/sharing_mailer_spec.rb+++ b/spec/mailers/sharing_mailer_spec.rb@@ -32,7 +32,11 @@ require 'spec_helper'RSpec.describe SharingMailer dolet(:project) { build_stubbed(:project) }- let(:work_package) { build_stubbed(:work_package, project:) }+ let(:work_package) do+ build_stubbed(:work_package,+ type: build_stubbed(:type_standard),+ project:)+ endlet(:shared_with_user) { build_stubbed(:user) }let(:roles) { [build_stubbed(:comment_work_package_role)] }let(:work_package_member) do