diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-02-20 17:18:15 +0200 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-02-27 22:07:50 +0200 |
commit | 77985826d94454514c40b8da926e13b3b3791841 (patch) | |
tree | 00da4c2f5b72001e38b56e9d994cabc278ec0d7c /app/helpers | |
parent | 177f9ca88b4d080e91b6c4ce2bba04d2fba95c07 (diff) | |
download | gitlab-ce-77985826d94454514c40b8da926e13b3b3791841.tar.gz |
Show header and footer system messages in email
* Add email_header_and_footer_enabled flag to appearances table
* Set email_header_and_footer_enabled default value to false
* Add checkbox to appearance to toggle show header and footer in emails
* Add email_header_and_footer_enabled to allowed params in controller
* Add header and footer messages to the html and text email layouts
* Remove the color styling for emails header and footer
* Add empty_mailer layout for emails without layout,
to have the header and footer applied
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/appearances_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/emails_helper.rb | 38 |
2 files changed, 43 insertions, 3 deletions
diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb index 023e44258b7..c0db9910143 100644 --- a/app/helpers/appearances_helper.rb +++ b/app/helpers/appearances_helper.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module AppearancesHelper + include MarkupHelper + def brand_title current_appearance&.title.presence || default_brand_title end @@ -47,7 +49,7 @@ module AppearancesHelper class_names = [] class_names << 'with-performance-bar' if performance_bar_enabled? - render_message(:header_message, class_names) + render_message(:header_message, class_names: class_names) end def footer_message @@ -58,10 +60,10 @@ module AppearancesHelper private - def render_message(field_sym, class_names = []) + def render_message(field_sym, class_names: [], style: message_style) class_names << field_sym.to_s.dasherize - content_tag :div, class: class_names, style: message_style do + content_tag :div, class: class_names, style: style do markdown_field(current_appearance, field_sym) end end diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index dedc58f482b..96471d15aac 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -131,4 +131,42 @@ module EmailsHelper project.id.to_s + "." + project_path_as_domain + "." + Gitlab.config.gitlab.host end + + def html_header_message + return unless show_header? + + render_message(:header_message, style: '') + end + + def html_footer_message + return unless show_footer? + + render_message(:footer_message, style: '') + end + + def text_header_message + return unless show_header? + + strip_tags(render_message(:header_message, style: '')) + end + + def text_footer_message + return unless show_footer? + + strip_tags(render_message(:footer_message, style: '')) + end + + private + + def show_footer? + email_header_and_footer_enabled? && current_appearance&.show_footer? + end + + def show_header? + email_header_and_footer_enabled? && current_appearance&.show_header? + end + + def email_header_and_footer_enabled? + current_appearance&.email_header_and_footer_enabled? + end end |