Skip to content

Commit

Permalink
Merge pull request #14879 from opf/implementation/50915-send-an-email…
Browse files Browse the repository at this point in the history
…-with-the-information-and-how-to-fix-it

Implementation/50915 send an email with the information and how to fix it
  • Loading branch information
apfohl authored Mar 27, 2024
2 parents f9dc741 + 38bba33 commit b0206c0
Show file tree
Hide file tree
Showing 31 changed files with 878 additions and 127 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ end
group :development do
gem "listen", "~> 3.9.0" # Use for event-based reloaders

gem "letter_opener"
gem 'letter_opener_web'

gem "spring"
gem "spring-commands-rspec"
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ GEM
color_conversion (0.1.1)
colored2 (4.0.0)
commonmarker (1.0.4)
rb_sys (~> 0.9)
compare-xml (0.66)
nokogiri (~> 1.8)
concurrent-ruby (1.2.3)
Expand Down Expand Up @@ -681,6 +680,10 @@ GEM
lefthook (1.6.7)
letter_opener (1.0.0)
launchy (>= 2.0.4)
letter_opener_web (1.4.1)
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -725,7 +728,6 @@ GEM
mime-types-data (3.2024.0305)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.22.3)
msgpack (1.7.2)
multi_json (1.15.0)
Expand All @@ -748,7 +750,6 @@ GEM
net-protocol
nio4r (2.7.0)
nokogiri (1.16.3)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oj (3.16.3)
bigdecimal (>= 3.0)
Expand Down Expand Up @@ -917,7 +918,6 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rb_sys (0.9.90)
rbtree3 (0.7.1)
rdoc (6.6.3.1)
psych (>= 4.0.0)
Expand Down Expand Up @@ -1230,7 +1230,7 @@ DEPENDENCIES
ladle
launchy (~> 3.0.0)
lefthook
letter_opener
letter_opener_web
listen (~> 3.9.0)
lograge (~> 0.14.0)
lookbook (~> 2.2.1)
Expand Down
44 changes: 44 additions & 0 deletions app/components/mailer/label_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 2012-2024 the OpenProject GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See COPYRIGHT and LICENSE files for more details.
++#%>

<table <%= placeholder_table_styles %>>
<tr>
<td style="color: <%= @color %>;
background-color: #FFFFFF;
white-space: nowrap;
padding: 0 7px;
font-size: 12px;
font-weight: 600;
line-height: 18px;
border: 0.8px <%= @color %> solid;
border-radius: 24px;">
<%= @text %>
</td>
</tr>
</table>
55 changes: 55 additions & 0 deletions app/components/mailer/label_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++

module Mailer
LABEL_SCHEME_COLORS = {
default: 'rgb(208, 215, 222)',
primary: 'rgb(110, 119, 129)',
secondary: 'rgb(208, 215, 222)',
accent: 'rgb(9, 105, 218)',
success: 'rgb(31, 136, 61)',
attention: 'rgb(154, 103, 0)',
danger: 'rgb(207, 34, 46)',
severe: 'rgb(188, 76, 0)',
done: 'rgb(130, 80, 223)',
sponsor: 'rgb(191, 57, 137)'
}.freeze

class LabelComponent < ViewComponent::Base
include MailLayoutHelper

def initialize(scheme:, text:)
super

@color = LABEL_SCHEME_COLORS[scheme]
@text = text
end
end
end
6 changes: 5 additions & 1 deletion app/views/announcement_mailer/announce.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,9 @@
</tr>
</table>

<%= render partial: 'mailer/notification_settings_table' %>
<%= render partial: 'mailer/notification_settings_table',
locals: {
button_url: my_reminders_url,
button_text: I18n.t(:'mail.notification.settings')
} %>
<% end %>
8 changes: 6 additions & 2 deletions app/views/digest_mailer/work_packages.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</tr>
</table>

<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;max-width:700px;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;max-width:700px;') %>>
<tr>
<%= placeholder_cell('12px', vertical: true) %>
<td>
Expand Down Expand Up @@ -40,7 +40,11 @@
<% end %>
<% end %>

<%= render layout: 'mailer/notification_settings_table' do %>
<%= render layout: 'mailer/notification_settings_table',
locals: {
button_url: my_reminders_url,
button_text: I18n.t(:'mail.notification.settings')
} do %>
<% if @aggregated_notifications.length > DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
<table>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ See COPYRIGHT and LICENSE files for more details.
</td>
</tr>
</table>
<%= call_hook(:view_layouts_mailer_html_before_content, self.assigns) %>
<%= call_hook(:view_layouts_mailer_html_before_content, assigns) %>
<table class="body">
<tr>
<td>
<%= yield %>
</td>
</tr>
</table>
<%= call_hook(:view_layouts_mailer_html_after_content, self.assigns) %>
<%= call_hook(:view_layouts_mailer_html_after_content, assigns) %>
<table class="footer">
<tr>
<td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/mailer/_border_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<table <%= placeholder_table_styles(width:'100%',style: "width:100%;border-width:1px;border-color:#E0E0E0;border-style:solid;border-radius:10px") %>>
<table <%= placeholder_table_styles(width: '100%', style: "width:100%;border-width:1px;border-color:#E0E0E0;border-style:solid;border-radius:10px") %>>
<tr>
<%= placeholder_cell('12px', vertical: false) %>
</tr>
<tr>
<td>
<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;font-size:14px;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;font-size:14px;') %>>
<%= yield %>
</table>
</td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mailer/_mailer_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<% end %>
<% if local_assigns[:bottom_spacing] != false %>
<tr>
<%= placeholder_cell('40px', vertical: false) %>
<%= placeholder_cell('16px', vertical: false) %>
</tr>
<% end %>
</table>
Expand Down
4 changes: 2 additions & 2 deletions app/views/mailer/_notification_settings_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<table <%= placeholder_table_styles %>>
<tr>
<td style="padding: 8px 12px; border: 1px solid #878787; border-radius: 16px; overflow: hidden; text-overflow: ellipsis;white-space: nowrap;">
<a href="<%= my_reminders_url %>"
<a href="<%= url %>"
target="_blank"
style="color: #333333; text-decoration: none; font-size: 14px;white-space: nowrap;">
<%= I18n.t(:'mail.notification.settings') %>
<%= text %>
</a>
</td>
</tr>
Expand Down
7 changes: 5 additions & 2 deletions app/views/mailer/_notification_settings_table.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<table <%= placeholder_table_styles(style: 'font-size:14px;') %>>
<tr>
<td>
<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;') %>>
<tr>
<td>
<%= yield %>
Expand All @@ -11,7 +11,10 @@
</td>
<%= placeholder_cell('10px', vertical: true) %>
<td>
<%= render partial: 'mailer/notification_settings_button' %>
<%= render partial: 'mailer/notification_settings_button', locals: {
url: button_url,
text: button_text
} %>
</td>
</tr>
</table>
12 changes: 8 additions & 4 deletions app/views/sharing_mailer/shared_work_package.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
notification_url: @url,
open_in_browser_path: @url
} do %>
<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;') %>>
<tr>
<td style="<%= placeholder_text_styles %>">
<%
Expand All @@ -47,15 +47,19 @@
</table>
<% end %>

<%= render partial: 'mailer/notification_settings_table' %>
<%= render partial: 'mailer/notification_settings_table',
locals: {
button_url: my_reminders_url,
button_text: I18n.t(:'mail.notification.settings')
} %>

<% if @shared_with_user.invited? %>
<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;') %>>
<tr>
<%= placeholder_cell('20px', vertical: false) %>
</tr>
<tr>
<td style="color: #333333;font-size: 16px;">
<td style="color: #333333; font-size: 16px;">
<%= t('mail.sharing.work_packages.create_account', instance: Setting.app_title) %>
</td>
</tr>
Expand Down
10 changes: 7 additions & 3 deletions app/views/work_package_mailer/mentioned.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</tr>
</table>

<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;max-width:700px;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;max-width:700px;') %>>
<tr>
<%= placeholder_cell('12px', vertical: true) %>
<td>
Expand All @@ -23,7 +23,7 @@
show_count: false,
user: @user
} do %>
<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;') %>>
<tr>
<td style="<%= placeholder_text_styles %>">
<%= format_text @journal.notes, only_path: false %>
Expand All @@ -32,7 +32,11 @@
</table>
<% end %>

<%= render partial: 'mailer/notification_settings_table' %>
<%= render partial: 'mailer/notification_settings_table',
locals: {
button_url: my_reminders_url,
button_text: I18n.t(:'mail.notification.settings')
} %>

<table>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
config.action_controller.raise_on_missing_callback_actions = true

# Send mails to browser window
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.delivery_method = :letter_opener_web

# Set email preview locations to rspec
config.action_mailer.preview_paths << Rails.root.join('spec/mailers/previews')
Expand Down
29 changes: 29 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2447,6 +2447,35 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
summary:
user: "%{user} shared a work package with you with %{role_rights} rights"
group: "%{user} shared a work package with the group %{group} you are a member of"
storages:
health:
plaintext:
storage: "Storage"
healthy:
summary: "Good news! The status of your storage, %{storage_name}, is currently displaying as \"Healthy\"."
error-solved-on: "Solved On"
recommendation: "We will continue monitoring the system to ensure it remains in good health. In case of any discrepancies, we will notify you."
details: "For more details or to make any necessary amendments, you can visit your storage configuration"
unhealthy:
summary: "The status of your storage, %{storage_name}, is currently displaying as \"Error\". We've detected an issue that might require your attention."
error-details: "Error Details"
error-message: "Error Message"
error-occurred-on: "Occurred On"
recommendation: "We recommend heading over to the storage configuration page to address this issue"
unsubscribe: "If you would no longer like to receive these notifications, you can unsubscribe at any time. To unsubscribe, please follow the instructions on this page"
email_notification_settings: "Storage email notification settings"
see_storage_settings: "See storage settings"
healthy:
subject: "Storage \"%{name}\" is now healthy!"
solved_at: "solved at"
summary: "The problem with your %{storage_name} storage integration is now solved"
unhealthy:
subject: "Storage \"%{name}\" is unhealthy!"
since: "since"
summary: "There is a problem with your %{storage_name} storage integration"
troubleshooting:
text: "For more information, check file storages"
link_text: "troubleshooting documentation"

mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
mail_body_account_information: "Your account information"
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@
end

if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
mount GoodJob::Engine => "good_job"
end
end
3 changes: 3 additions & 0 deletions lib/open_project/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ module Events
PROJECT_STORAGE_UPDATED = "project_storage_updated".freeze
PROJECT_STORAGE_DESTROYED = "project_storage_destroyed".freeze

STORAGE_TURNED_UNHEALTHY = "storage_turned_unhealthy".freeze
STORAGE_TURNED_HEALTHY = "storage_turned_healthy".freeze

ROLE_UPDATED = "role_updated".freeze
ROLE_DESTROYED = "role_destroyed".freeze

Expand Down
Loading

0 comments on commit b0206c0

Please sign in to comment.