remove favicon preview on appearance page

This commit is contained in:
Alexis Reigel 2018-02-05 15:41:37 +01:00 committed by Alexis Reigel
parent 36d000cb78
commit b4d84c07bc
No known key found for this signature in database
GPG key ID: C728AF10972E97C0
4 changed files with 3 additions and 34 deletions

View file

@ -1,19 +0,0 @@
import {createOverlayIcon} from '~/lib/utils/common_utils';
export default class FaviconAdmin {
constructor() {
const faviconContainer = $('.js-favicons');
const faviconUrl = faviconContainer.data('favicon');
const overlayUrls = faviconContainer.data('status-overlays') || [];
overlayUrls.forEach((statusOverlay) => {
createOverlayIcon(faviconUrl, statusOverlay).then((faviconWithOverlayUrl) => {
const image = $('<img />');
image.addClass('appearance-light-logo-preview');
image.attr('src', faviconWithOverlayUrl);
faviconContainer.append(image);
});
});
}
}

View file

@ -62,12 +62,7 @@
= f.label :favicon, 'Favicon', class: 'control-label'
.col-sm-10
- if @appearance.favicon?
= image_tag @appearance.favicon.favicon_main.url, class: 'appearance-light-logo-preview js-main-favicon'
- if @appearance.favicon?
= f.label :favicon, 'Status icons preview', class: 'control-label'
.col-sm-10
- if @appearance.favicon?
.js-favicons{ data: { favicon: @appearance.favicon.favicon_main.url, status_overlays: Gitlab::Favicon.available_status_overlays } }
= image_tag @appearance.favicon.favicon_main.url, class: 'appearance-light-logo-preview'
- if @appearance.persisted?
%br
= link_to 'Remove favicon', favicon_admin_appearances_path, data: { confirm: "Favicon will be removed. Are you sure?"}, method: :delete, class: "btn btn-inverted btn-remove btn-sm remove-logo"

View file

@ -18,12 +18,6 @@ module Gitlab
ActionController::Base.helpers.image_path(path)
end
def available_status_overlays
available_status_names.map do |status_name|
status_overlay(status_name)
end
end
def available_status_names
@available_status_names ||= begin
Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', '*.png'))

View file

@ -76,15 +76,14 @@ feature 'Admin Appearance' do
expect(page).not_to have_css(header_logo_selector)
end
scenario 'Favicon', :js do
scenario 'Favicon' do
sign_in(create(:admin))
visit admin_appearances_path
attach_file(:appearance_favicon, logo_fixture)
click_button 'Save'
# 11 = 1 original + 10 overlay variations
expect(page).to have_css('.appearance-light-logo-preview', count: 11)
expect(page).to have_css('.appearance-light-logo-preview')
click_link 'Remove favicon'