Commit 1f1de7f7 authored by Tiago Botelho's avatar Tiago Botelho Committed by André Luís

Ports every change to EE folder

parent b66a26b6
class Admin::AppearancesController < Admin::ApplicationController
prepend EE::Admin::AppearancesController
before_action :set_appearance, except: :create
def show
......@@ -50,7 +52,11 @@ class Admin::AppearancesController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through.
def appearance_params
params.require(:appearance).permit(%i(
params.require(:appearance).permit(appearance_params_attributes)
end
def appearance_params_attributes
%i[
title
description
logo
......@@ -59,10 +65,6 @@ class Admin::AppearancesController < Admin::ApplicationController
header_logo_cache
new_project_guidelines
updated_by
header_message
footer_message
background_color
font_color
))
]
end
end
module AppearancesHelper
def header_message(appearance)
return unless appearance.header_message.present?
appearance_message(appearance, :header_message)
end
def footer_message(appearance)
return unless appearance.footer_message.present?
appearance_message(appearance, :footer_message)
end
def appearance_message(appearance, field_sym)
class_names = [field_sym.to_s.dasherize]
class_names << 'with-performance-bar' if performance_bar_enabled?
content_tag :div, class: class_names, style: message_style(appearance) do
icon('bullhorn') << ' ' << render_message(appearance, field_sym)
end
end
def message_style(appearance)
style = ''
if appearance.background_color.present?
style << "background-color: #{appearance.background_color}"
style << '; ' if appearance.font_color.present?
end
if appearance.font_color.present?
style << "color: #{appearance.font_color}"
end
style
end
def render_message(appearance, field)
Banzai.render_field(appearance, field).html_safe
end
prepend EE::AppearancesHelper
def brand_title
brand_item&.title.presence || 'GitLab Enterprise Edition'
......
......@@ -3,21 +3,16 @@ class Appearance < ActiveRecord::Base
include AfterCommitQueue
include ObjectStorage::BackgroundMove
prepend EE::Appearance
cache_markdown_field :description
cache_markdown_field :new_project_guidelines
cache_markdown_field :header_message
cache_markdown_field :footer_message
validates :background_color, allow_blank: true, color: true
validates :font_color, allow_blank: true, color: true
validates :logo, file_size: { maximum: 1.megabyte }
validates :header_logo, file_size: { maximum: 1.megabyte }
validate :single_appearance_row, on: :create
default_value_for :background_color, '#E75E40'
default_value_for :font_color, '#FFFFFF'
mount_uploader :logo, AttachmentUploader
mount_uploader :header_logo, AttachmentUploader
......
......@@ -18,28 +18,7 @@
.hint
Maximum file size is 1MB. Pages are optimized for a 28px tall header logo
%fieldset.system_header_footer
%legend
System header and footer:
.form-group
= f.label :header_message, 'Header message', class: 'control-label'
.col-sm-10
= f.text_area :header_message, placeholder: 'State your message to activate', class: "form-control js-autosize"
.form-group
= f.label :footer_message, 'Footer message', class: 'control-label'
.col-sm-10
= f.text_area :footer_message, placeholder: 'State your message to activate', class: "form-control js-autosize"
.form-group.js-toggle-colors-container
.col-sm-10.col-sm-offset-2
= link_to 'Customize colors', '#', class: 'js-toggle-colors-link'
.form-group.js-toggle-colors-container.hide
= f.label :background_color, "Background Color", class: 'control-label'
.col-sm-10
= f.color_field :background_color, class: "form-control"
.form-group.js-toggle-colors-container.hide
= f.label :font_color, "Font Color", class: 'control-label'
.col-sm-10
= f.color_field :font_color, class: "form-control"
= render partial: 'admin/appearances/ee/form', locals: { form: f }
%fieldset.sign-in
%legend
......
......@@ -4,9 +4,9 @@
%body{ class: "#{user_application_theme} #{@body_class}", data: { page: body_data_page, project: "#{@project.path if @project}", group: "#{@group.path if @group}", find_file: find_file_path } }
= render "layouts/init_auto_complete" if @gfm_form
= render 'peek/bar'
= render "layouts/header_message"
= render "admin/appearances/ee/header_message"
= render "layouts/header/default"
= render 'layouts/page', sidebar: sidebar, nav: nav
= render "layouts/footer_message"
= render "admin/appearances/ee/footer_message"
= yield :scripts_body
module EE
module Admin
module AppearancesController
def appearance_params_attributes
super + appearance_params_ee
end
private
def appearance_params_ee
%i[
header_message
footer_message
background_color
font_color
]
end
end
end
end
module EE
module AppearancesHelper
def header_message(appearance)
return unless appearance&.header_message.present?
class_names = []
class_names << 'with-performance-bar' if performance_bar_enabled?
appearance_message(appearance, :header_message, class_names)
end
def footer_message(appearance)
return unless appearance&.footer_message.present?
appearance_message(appearance, :footer_message)
end
private
def appearance_message(appearance, field_sym, class_names = [])
class_names << field_sym.to_s.dasherize
content_tag :div, class: class_names, style: message_style(appearance) do
render_message(appearance, field_sym)
end
end
def message_style(appearance)
style = ''
style << "background-color: #{appearance.background_color};"
style << "color: #{appearance.font_color}"
style
end
def render_message(appearance, field)
::Banzai.render_field(appearance, field).html_safe
end
end
end
module EE
module Appearance
extend ActiveSupport::Concern
prepended do
cache_markdown_field :header_message
cache_markdown_field :footer_message
validates :background_color, allow_blank: true, color: true
validates :font_color, allow_blank: true, color: true
default_value_for :background_color, '#E75E40'
default_value_for :font_color, '#FFFFFF'
end
end
end
- form = local_assigns.fetch(:form)
%fieldset.system_header_footer
%legend
System header and footer:
.form-group
= form.label :header_message, 'Header message', class: 'control-label'
.col-sm-10
= form.text_area :header_message, placeholder: 'State your message to activate', class: "form-control js-autosize"
.form-group
= form.label :footer_message, 'Footer message', class: 'control-label'
.col-sm-10
= form.text_area :footer_message, placeholder: 'State your message to activate', class: "form-control js-autosize"
.form-group.js-toggle-colors-container
.col-sm-10.col-sm-offset-2
= link_to 'Customize colors', '#', class: 'js-toggle-colors-link'
.form-group.js-toggle-colors-container.hide
= form.label :background_color, "Background Color", class: 'control-label'
.col-sm-10
= form.color_field :background_color, class: "form-control"
.form-group.js-toggle-colors-container.hide
= form.label :font_color, "Font Color", class: 'control-label'
.col-sm-10
= form.color_field :font_color, class: "form-control"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment