diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-28 19:16:30 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-02-28 19:16:30 +0300 |
commit | 790a51a42778b3aa3fb5c8c5afe687ef06dd4433 (patch) | |
tree | df21d214bbc24e4f74af90427e5b8b1116057855 /app/helpers | |
parent | 4df6460b4e3a5b1d2f383a37c9121bfbd59ea807 (diff) | |
parent | 77985826d94454514c40b8da926e13b3b3791841 (diff) |
Merge branch '56863-system-messages-in-email' into 'master'
Show header and footer system messages in email
Closes #56863
See merge request gitlab-org/gitlab-ce!25474
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 |