Skip to content

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

Broken component and partial rendering for storages mailer

Andreas Pfohlcbc09b2eeabe
diff --git a/app/components/mailer/label_component.html.erb b/app/components/mailer/label_component.html.erb
new file mode 100644
index 00000000000..67f1f343be6
--- /dev/null
+++ b/app/components/mailer/label_component.html.erb
@@ -0,0 +1,14 @@
+<table <%= placeholder_table_styles %>>
+ <tr>
+ <td style="color: <%= @color %>;
+ background-color: #FFFFFF;
+ white-space: nowrap;
+ padding: 0px 7px;
+ font-size: 12px;
+ line-height: 18px;
+ border: 0.8px <%= @color %> solid;
+ border-radius: 24px;">
+ <%= @text %>
+ </td>
+ </tr>
+</table>
diff --git a/app/components/mailer/label_component.rb b/app/components/mailer/label_component.rb
new file mode 100644
index 00000000000..bfe254a3703
--- /dev/null
+++ b/app/components/mailer/label_component.rb
@@ -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
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
index 6ae1aa2361b..1b73fb1f389 100644
--- a/app/views/layouts/mailer.html.erb
+++ b/app/views/layouts/mailer.html.erb
@@ -106,7 +106,7 @@ 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>
@@ -114,7 +114,7 @@ See COPYRIGHT and LICENSE files for more details.
</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>
diff --git a/app/views/mailer/_border_table.html.erb b/app/views/mailer/_border_table.html.erb
index ee7c2bcd488..3da9ec802c8 100644
--- a/app/views/mailer/_border_table.html.erb
+++ b/app/views/mailer/_border_table.html.erb
@@ -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>
diff --git a/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.html.erb b/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.html.erb
new file mode 100644
index 00000000000..6dd45aa992a
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.html.erb
@@ -0,0 +1,5 @@
+<a style="text-decoration: none;display: block;" href="/" target="_blank">
+ <%= render 'mailer/border_table' do %>
+ <tr><td>Foo</td></tr>
+ <% end %>
+</a>
diff --git a/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.rb b/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.rb
new file mode 100644
index 00000000000..17aa593a8af
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/mailer/health_status_notification_component.rb
@@ -0,0 +1,38 @@
+# 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 Storages::Admin
+ module Mailer
+ class HealthStatusNotificationComponent < ViewComponent::Base
+ include MailLayoutHelper
+ end
+ end
+end
diff --git a/modules/storages/app/mailers/storages/storages_mailer.rb b/modules/storages/app/mailers/storages/storages_mailer.rb
index e7f0fc00b55..9433b93cbb3 100644
--- a/modules/storages/app/mailers/storages/storages_mailer.rb
+++ b/modules/storages/app/mailers/storages/storages_mailer.rb
@@ -30,9 +30,13 @@
module Storages
class StoragesMailer < ApplicationMailer
+ layout 'mailer'
+
include MessagesHelper
+ include MailNotificationHelper
helper_method :message_url
+ helper :mail_notification
def notify_unhealthy(admin, storage)
@admin = admin
diff --git a/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.html.erb b/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.html.erb
index 265681960e9..38744817ed7 100644
--- a/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.html.erb
+++ b/modules/storages/app/views/storages/storages_mailer/notify_unhealthy.html.erb
@@ -27,30 +27,20 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<table>
- <tr>
- <%= placeholder_cell('20px', vertical: false) %>
- </tr>
-</table>
-
<table <%= placeholder_table_styles(width: '100%', style: 'width:100%;max-width:700px') %>>
<tr>
- <%= placeholder_cell('12px', vertical: true) %>
<td>
- <%= render partial: 'mailer/mailer_header',
+ <%= render(partial: 'mailer/mailer_header',
locals: {
user: @admin,
summary: I18n.t("mail.storages.health.unhealthy.summary", storage_name: @storage.name),
button_href: @url,
- button_text: I18n.t(:'mail.storages.health.see_storage_settings'),
- } %>
-
- <table>
- <tr>
- <%= placeholder_cell('40px', vertical: false) %>
- </tr>
- </table>
+ button_text: I18n.t(:'mail.storages.health.see_storage_settings')
+ }) %>
+
+ <div>Foo</div>
+
+ <%= render(Storages::Admin::Mailer::HealthStatusNotificationComponent.new) %>
</td>
- <%= placeholder_cell('12px', vertical: true) %>
</tr>
</table>