Commit c435af50 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rs-issue-2356' into 'master'

Show "Remove logo" buttons only when Appearance settings are persisted

This also adds the CarrierWave cache fields to the form as recommended by https://github.com/carrierwaveuploader/carrierwave#making-uploads-work-across-form-redisplays so that uploaded files aren't lost between form submits (i.e., when there are errors on the form).

See gitlab/gitlabhq#2356

See merge request !410
parents 3963d310 d1bca53b
......@@ -51,7 +51,9 @@ class Admin::AppearancesController < Admin::ApplicationController
# Only allow a trusted parameter "white list" through.
def appearance_params
params.require(:appearance).permit(:title, :description, :logo,
:dark_logo, :light_logo, :updated_by)
params.require(:appearance).permit(
:title, :description, :logo, :logo_cache, :light_logo, :light_logo_cache,
:updated_by
)
end
end
......@@ -21,10 +21,12 @@
= f.label :logo, class: 'control-label'
.col-sm-10
- if @appearance.logo?
= image_tag @appearance.logo, class: 'appearance-logo-preview'
%br
= link_to 'Remove logo', logo_admin_appearances_path, data: { confirm: "Logo will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-logo"
= image_tag @appearance.logo_url, class: 'appearance-logo-preview'
- if @appearance.persisted?
%br
= link_to 'Remove logo', logo_admin_appearances_path, data: { confirm: "Logo will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-logo"
%hr
= f.hidden_field :logo_cache
= f.file_field :logo, class: ""
.hint
Maximum logo size is 1MB, page optimized for logo size 640x360px
......@@ -36,14 +38,15 @@
= f.label :light_logo, 'Header logo', class: 'control-label'
.col-sm-10
- if @appearance.light_logo?
= image_tag @appearance.light_logo, class: 'appearance-light-logo-preview'
= image_tag @appearance.light_logo_url, class: 'appearance-light-logo-preview'
- if @appearance.persisted?
%br
= link_to 'Remove header logo', header_logos_admin_appearances_path, data: { confirm: "Header logo will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-logo"
%hr
= f.hidden_field :light_logo_cache
= f.file_field :light_logo, class: ""
.hint
Maximum size is 1MB, page optimized for logo size 72x72px
-if @appearance.light_logo?
%br
= link_to 'Remove header logo', header_logos_admin_appearances_path, data: { confirm: "Header logos will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-logo"
.form-actions
= f.submit 'Save', class: 'btn btn-save'
......
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