diff options
author | Sean McGivern <sean@gitlab.com> | 2019-02-22 13:46:00 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-02-22 13:46:00 +0300 |
commit | 695df38fce2893becfd858d9e96f2f4d648af2f2 (patch) | |
tree | 9f695eba7dbf063b1aa8e7e594fd0211e8a0ed8f /app/helpers | |
parent | 6fa88ed77e1693cda845efe49bf2c9a77aed2e4f (diff) | |
parent | 28e1739a3fd8c93e4805fe0053faf820cec4e1bc (diff) |
Merge branch '55057-system-message-to-core' into 'master'
Port EE System Header And Footer feature to CE
Closes #55057
See merge request gitlab-org/gitlab-ce!25241
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/appearances_helper.rb | 32 | ||||
-rw-r--r-- | app/helpers/application_helper.rb | 17 |
2 files changed, 47 insertions, 2 deletions
diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb index 7fbbbb04154..023e44258b7 100644 --- a/app/helpers/appearances_helper.rb +++ b/app/helpers/appearances_helper.rb @@ -40,4 +40,36 @@ module AppearancesHelper render 'shared/logo_type.svg' end end + + def header_message + return unless current_appearance&.show_header? + + class_names = [] + class_names << 'with-performance-bar' if performance_bar_enabled? + + render_message(:header_message, class_names) + end + + def footer_message + return unless current_appearance&.show_footer? + + render_message(:footer_message) + end + + private + + def render_message(field_sym, class_names = []) + class_names << field_sym.to_s.dasherize + + content_tag :div, class: class_names, style: message_style do + markdown_field(current_appearance, field_sym) + end + end + + def message_style + style = [] + style << "background-color: #{current_appearance.message_background_color};" + style << "color: #{current_appearance.message_font_color}" + style.join + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9efa84b02f0..ffa5719fefb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -214,12 +214,19 @@ module ApplicationHelper class_names = [] class_names << 'issue-boards-page' if current_controller?(:boards) class_names << 'with-performance-bar' if performance_bar_enabled? - + class_names << system_message_class class_names end - # EE feature: System header and footer, unavailable in CE def system_message_class + class_names = [] + + return class_names unless appearance + + class_names << 'with-system-header' if appearance.show_header? + class_names << 'with-system-footer' if appearance.show_footer? + + class_names end # Returns active css class when condition returns true @@ -292,4 +299,10 @@ module ApplicationHelper snippets: snippets_project_autocomplete_sources_path(object) } end + + private + + def appearance + ::Appearance.current + end end |