mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
Updated default icon handling for portal settings
no issue - Adds mapping for default svg icons to keys - Updates custom icon check to not include default icons - Updated settings update to save default icon key on update
This commit is contained in:
parent
4413944d15
commit
b963e3afe5
|
@ -174,15 +174,17 @@
|
||||||
<h4 class="gh-portal-setting-title">Icon</h4>
|
<h4 class="gh-portal-setting-title">Icon</h4>
|
||||||
<GhUploader
|
<GhUploader
|
||||||
@extensions={{this.iconExtensions}}
|
@extensions={{this.iconExtensions}}
|
||||||
@paramsHash={{hash purpose="icon"}}
|
@paramsHash={{hash purpose="image"}}
|
||||||
@onComplete={{action "imageUploaded" "icon"}}
|
@onComplete={{action "imageUploaded" "buttonIcon"}}
|
||||||
as
|
as
|
||||||
|uploader|
|
|uploader|
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-between mt2 br3 ba b--whitegrey bg-white">
|
<div class="flex items-center justify-between mt2 br3 ba b--whitegrey bg-white">
|
||||||
<div class="gh-portal-settings-icons">
|
<div class="gh-portal-settings-icons">
|
||||||
{{#each this.defaultButtonIcons as |imgIcon| }}
|
{{#each this.defaultButtonIcons as |imgIcon| }}
|
||||||
<span class="gh-portal-button-icon {{if (eq this.buttonIcon imgIcon) "selected-icon"}}" onclick={{action "selectDefaultIcon" imgIcon}}>{{svg-jar imgIcon}}</span>
|
<span class="gh-portal-button-icon {{if (eq this.buttonIcon imgIcon.value) "selected-icon"}}" onclick={{action "selectDefaultIcon" imgIcon.value}}>
|
||||||
|
{{svg-jar imgIcon.icon}}
|
||||||
|
</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#if uploader.isUploading}}
|
{{#if uploader.isUploading}}
|
||||||
{{uploader.progressBar}}
|
{{uploader.progressBar}}
|
||||||
|
|
|
@ -8,7 +8,30 @@ import {htmlSafe} from '@ember/string';
|
||||||
import {run} from '@ember/runloop';
|
import {run} from '@ember/runloop';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {task, timeout} from 'ember-concurrency';
|
import {task, timeout} from 'ember-concurrency';
|
||||||
const ICON_EXTENSIONS = ['ico', 'png', 'svg', 'jpg', 'jpeg'];
|
const ICON_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'png', 'svg'];
|
||||||
|
|
||||||
|
const ICON_MAPPING = [
|
||||||
|
{
|
||||||
|
icon: 'user-circle',
|
||||||
|
value: 'icon-1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'ambulance',
|
||||||
|
value: 'icon-2'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'book-open',
|
||||||
|
value: 'icon-3'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'store',
|
||||||
|
value: 'icon-4'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: 'gift',
|
||||||
|
value: 'icon-5'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
export default ModalComponent.extend({
|
export default ModalComponent.extend({
|
||||||
settings: service(),
|
settings: service(),
|
||||||
|
@ -108,17 +131,12 @@ export default ModalComponent.extend({
|
||||||
{name: 'icon-only', label: 'Icon only'},
|
{name: 'icon-only', label: 'Icon only'},
|
||||||
{name: 'text-only', label: 'Text only'}
|
{name: 'text-only', label: 'Text only'}
|
||||||
];
|
];
|
||||||
this.defaultButtonIcons = [
|
this.defaultButtonIcons = ICON_MAPPING;
|
||||||
'user-circle',
|
|
||||||
'ambulance',
|
|
||||||
'book-open',
|
|
||||||
'store',
|
|
||||||
'gift'
|
|
||||||
];
|
|
||||||
this.iconExtensions = ICON_EXTENSIONS;
|
this.iconExtensions = ICON_EXTENSIONS;
|
||||||
const portalButtonIcon = this.settings.get('portalButtonIcon') || '';
|
const portalButtonIcon = this.settings.get('portalButtonIcon') || '';
|
||||||
if (portalButtonIcon && !portalButtonIcon.includes('githubusercontent')) {
|
const defaultIconKeys = this.defaultButtonIcons.map(buttonIcon => buttonIcon.value);
|
||||||
return this.set('customIcon', this.settings.get('portalButtonIcon'));
|
if (portalButtonIcon && !defaultIconKeys.includes(portalButtonIcon)) {
|
||||||
|
this.set('customIcon', this.settings.get('portalButtonIcon'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue