mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:09:35 +08:00
b120728999
* FEATURE: Ability to add components to all themes This is the first and functional step from that topic https://dev.discourse.org/t/adding-a-theme-component-is-too-much-work/15398/16 The idea here is that when a new component is added, the user can easily assign it to all themes (parents). To achieve that, I needed to change a site-setting component to accept `setDefaultValues` action and `setDefaultValuesLabel` translated label. Also, I needed to add `allowAny` option to disable that for theme selector. I also refactored backend to accept both parent and child ids with one method to avoid duplication (Renamed `add_child_theme!` to more general `add_relative_theme!`) * FIX: Improvement after code review * FIX: Improvement after code review2 * FIX: use mapBy and filterBy directly
283 lines
11 KiB
Handlebars
283 lines
11 KiB
Handlebars
<div class="show-current-style">
|
||
<div class="title">
|
||
{{#if editingName}}
|
||
{{text-field value=model.name autofocus="true"}}
|
||
{{d-button action=(action "finishedEditingName") class="btn-primary submit-edit" icon="check"}}
|
||
{{d-button action=(action "cancelEditingName") class="btn-default cancel-edit" icon="times"}}
|
||
{{else}}
|
||
{{model.name}} <a {{action "startEditingName"}}>{{d-icon "pencil-alt"}}</a>
|
||
{{/if}}
|
||
</div>
|
||
|
||
{{#each model.errors as |error|}}
|
||
<div class="alert alert-error">
|
||
<button class="close" data-dismiss="alert">×</button>
|
||
{{error}}
|
||
</div>
|
||
{{/each}}
|
||
|
||
{{#unless model.supported}}
|
||
<div class="alert alert-error">
|
||
{{i18n "admin.customize.theme.required_version.error"}}
|
||
{{#if model.remote_theme.minimum_discourse_version}}
|
||
{{i18n "admin.customize.theme.required_version.minimum" version=model.remote_theme.minimum_discourse_version}}
|
||
{{/if}}
|
||
{{#if model.remote_theme.maximum_discourse_version}}
|
||
{{i18n "admin.customize.theme.required_version.maximum" version=model.remote_theme.maximum_discourse_version}}
|
||
{{/if}}
|
||
</div>
|
||
{{/unless}}
|
||
|
||
{{#unless model.enabled}}
|
||
<div class="alert alert-error">
|
||
{{#if model.disabled_by}}
|
||
{{i18n "admin.customize.theme.disabled_by"}}
|
||
{{#user-link user=model.disabled_by}}
|
||
{{avatar model.disabled_by imageSize="tiny"}}
|
||
{{model.disabled_by.username}}
|
||
{{/user-link}}
|
||
{{format-date model.disabled_at leaveAgo="true"}}
|
||
{{else}}
|
||
{{i18n "admin.customize.theme.disabled"}}
|
||
{{/if}}
|
||
{{d-button
|
||
class='btn-default'
|
||
action=(action "enableComponent")
|
||
icon="check"
|
||
label="admin.customize.theme.enable"}}
|
||
</div>
|
||
{{/unless}}
|
||
|
||
{{#unless model.component}}
|
||
<div class="control-unit">
|
||
{{inline-edit-checkbox action=(action "applyDefault") labelKey="admin.customize.theme.is_default" checked=model.default}}
|
||
{{inline-edit-checkbox action=(action "applyUserSelectable") labelKey="admin.customize.theme.user_selectable" checked=model.user_selectable}}
|
||
</div>
|
||
{{/unless}}
|
||
|
||
{{#if model.remote_theme}}
|
||
|
||
{{#if model.remote_theme.remote_url}}
|
||
{{#if sourceIsHttp}}
|
||
<a class="remote-url" href="{{model.remote_theme.remote_url}}">{{i18n "admin.customize.theme.source_url"}}{{d-icon "link"}}</a>
|
||
{{else}}
|
||
<div class="remote-url"><code>{{model.remote_theme.remote_url}}</code></div>
|
||
{{/if}}
|
||
{{/if}}
|
||
{{#if model.remote_theme.about_url}}
|
||
<a class="url about-url" href="{{model.remote_theme.about_url}}">{{i18n "admin.customize.theme.about_theme"}}{{d-icon "link"}}</a>
|
||
{{/if}}
|
||
{{#if model.remote_theme.license_url}}
|
||
<a class="url license-url" href="{{model.remote_theme.license_url}}">{{i18n "admin.customize.theme.license"}}{{d-icon "link"}}</a>
|
||
{{/if}}
|
||
|
||
{{#if model.description}}
|
||
<span class="theme-description">{{model.description}}</span>
|
||
{{/if}}
|
||
|
||
<span class="metadata">
|
||
{{#if model.remote_theme.authors}}<span class="authors"><span class="heading">{{i18n "admin.customize.theme.authors"}}</span> {{model.remote_theme.authors}}</span>{{/if}}
|
||
{{#if model.remote_theme.theme_version}}<span class="version"><span class="heading">{{i18n "admin.customize.theme.version"}}</span> {{model.remote_theme.theme_version}}</span>{{/if}}
|
||
</span>
|
||
|
||
<div class="control-unit">
|
||
{{#if model.remote_theme.is_git}}
|
||
|
||
{{#if showRemoteError}}
|
||
<div class="error-message">
|
||
{{d-icon "exclamation-triangle"}} {{I18n "admin.customize.theme.repo_unreachable"}}
|
||
</div>
|
||
<div class="raw-error">
|
||
<code>{{model.remoteError}}</code>
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if model.remote_theme.commits_behind}}
|
||
{{#d-button action=(action "updateToLatest") icon="download" class='btn-primary'}}{{i18n "admin.customize.theme.update_to_latest"}}{{/d-button}}
|
||
{{else}}
|
||
{{#d-button action=(action "checkForThemeUpdates") icon="sync" class="btn-default"}}{{i18n "admin.customize.theme.check_for_updates"}}{{/d-button}}
|
||
{{/if}}
|
||
|
||
<span class='status-message'>
|
||
{{#if updatingRemote}}
|
||
{{i18n 'admin.customize.theme.updating'}}
|
||
{{else}}
|
||
{{#if model.remote_theme.commits_behind}}
|
||
{{i18n 'admin.customize.theme.commits_behind' count=model.remote_theme.commits_behind}}
|
||
{{#if model.remote_theme.github_diff_link}}
|
||
<a href="{{model.remote_theme.github_diff_link}}">
|
||
{{i18n 'admin.customize.theme.compare_commits'}}
|
||
</a>
|
||
{{/if}}
|
||
{{else}}
|
||
{{#unless showRemoteError}}
|
||
{{i18n 'admin.customize.theme.up_to_date'}} {{format-date model.remote_theme.updated_at leaveAgo="true"}}
|
||
{{/unless}}
|
||
{{/if}}
|
||
{{/if}}
|
||
</span>
|
||
{{else}}
|
||
<span class='status-message'>
|
||
{{d-icon "info-circle"}} {{i18n "admin.customize.theme.imported_from_archive"}}
|
||
</span>
|
||
{{/if}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#unless model.component}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.color_scheme"}}</div>
|
||
<div class="description">{{i18n "admin.customize.theme.color_scheme_select"}}</div>
|
||
<div class="control">
|
||
{{color-palettes
|
||
content=colorSchemes
|
||
filterable=true
|
||
forceEscape=true
|
||
value=colorSchemeId
|
||
icon="paint-brush"}}
|
||
|
||
{{#if colorSchemeChanged}}
|
||
{{d-button action=(action "changeScheme") class="btn-primary submit-edit" icon="check"}}
|
||
{{d-button action=(action "cancelChangeScheme") class="btn-default cancel-edit" icon="times"}}
|
||
{{/if}}
|
||
</div>
|
||
{{#link-to 'adminCustomize.colors' class="btn btn-default edit"}}{{i18n 'admin.customize.colors.edit'}}{{/link-to}}
|
||
</div>
|
||
{{/unless}}
|
||
|
||
{{#if parentThemes}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.component_of"}}</div>
|
||
<ul>
|
||
{{#each parentThemes as |theme|}}
|
||
<li>{{#link-to 'adminCustomizeThemes.show' theme replace=true}}{{theme.name}}{{/link-to}}</li>
|
||
{{/each}}
|
||
</ul>
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if model.component }}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.title"}}</div>
|
||
{{#d-section class="form-horizontal theme settings"}}
|
||
<div class="row setting">
|
||
{{theme-setting-relatives-selector setting=relativesSelectorSettings model=model class="theme-setting"}}
|
||
</div>
|
||
{{/d-section}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.css_html"}}</div>
|
||
{{#if model.hasEditedFields}}
|
||
<div class="description">{{i18n "admin.customize.theme.custom_sections"}}</div>
|
||
<ul>
|
||
{{#each editedFieldsFormatted as |field|}}
|
||
<li>{{field}}</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{else}}
|
||
<div class="description">
|
||
{{i18n "admin.customize.theme.edit_css_html_help"}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{d-button
|
||
class="btn-default edit"
|
||
action=(action "editTheme")
|
||
label="admin.customize.theme.edit_css_html"}}
|
||
</div>
|
||
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.uploads"}}</div>
|
||
{{#if model.uploads}}
|
||
<ul class='removable-list'>
|
||
{{#each model.uploads as |upload|}}
|
||
<li>
|
||
<span class='col'>${{upload.name}}: <a href={{upload.url}} target='_blank'>{{upload.filename}}</a></span>
|
||
<span class='col'>
|
||
{{d-button action=(action "removeUpload") actionParam=upload class="second btn-default btn-default cancel-edit" icon="times"}}
|
||
</span>
|
||
</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{else}}
|
||
<div class="description">{{i18n "admin.customize.theme.no_uploads"}}</div>
|
||
{{/if}}
|
||
{{#d-button action=(action "addUploadModal") class="btn-default" icon="plus"}}{{i18n "admin.customize.theme.add"}}{{/d-button}}
|
||
</div>
|
||
|
||
{{#if hasSettings}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.theme_settings"}}</div>
|
||
{{#d-section class="form-horizontal theme settings"}}
|
||
{{#each settings as |setting|}}
|
||
{{theme-setting-editor setting=setting model=model class="theme-setting"}}
|
||
{{/each}}
|
||
{{/d-section}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if hasTranslations}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">{{i18n "admin.customize.theme.theme_translations"}}</div>
|
||
{{#d-section class="form-horizontal theme settings translations"}}
|
||
{{#each translations as |translation|}}
|
||
{{theme-translation translation=translation model=model class="theme-translation"}}
|
||
{{/each}}
|
||
{{/d-section}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
{{#if availableChildThemes}}
|
||
<div class="control-unit">
|
||
<div class="mini-title">
|
||
{{d-icon "puzzle-piece"}}
|
||
{{i18n "admin.customize.theme.theme_components"}}
|
||
</div>
|
||
{{#if model.childThemes.length}}
|
||
<ul class='removable-list'>
|
||
{{#each model.childThemes as |child|}}
|
||
<li class={{unless child.enabled "disabled-child"}}>
|
||
{{#link-to 'adminCustomizeThemes.show' child replace=true class='col child-link'}}
|
||
{{child.name}}
|
||
{{/link-to}}
|
||
|
||
{{d-button action=(action "removeChildTheme") actionParam=child class="btn-default cancel-edit col" icon="times"}}
|
||
</li>
|
||
{{/each}}
|
||
</ul>
|
||
{{/if}}
|
||
{{#if selectableChildThemes}}
|
||
<div class="description">
|
||
{{combo-box forceEscape=true filterable=true content=selectableChildThemes value=selectedChildThemeId none="admin.customize.theme.select_component"}}
|
||
{{#d-button action=(action "addChildTheme") icon="plus" disabled=addButtonDisabled class="btn-default add-component-button"}}{{i18n "admin.customize.theme.add"}}{{/d-button}}
|
||
</div>
|
||
{{/if}}
|
||
</div>
|
||
{{/if}}
|
||
|
||
<a href='{{previewUrl}}' title="{{i18n 'admin.customize.explain_preview'}}" target='_blank' class='btn btn-default'>{{d-icon 'desktop'}}{{i18n 'admin.customize.theme.preview'}}</a>
|
||
<a class="btn btn-default export" target="_blank" href={{downloadUrl}}>{{d-icon "download"}} {{i18n 'admin.export_json.button_text'}}</a>
|
||
|
||
{{d-button action=(action "switchType") label="admin.customize.theme.convert" icon=convertIcon class="btn-default btn-normal" title=convertTooltip}}
|
||
|
||
{{#if model.component}}
|
||
{{#if model.enabled}}
|
||
{{d-button
|
||
class='btn-default'
|
||
action=(action "disableComponent")
|
||
icon="ban"
|
||
label="admin.customize.theme.disable"}}
|
||
{{else}}
|
||
{{d-button
|
||
class='btn-default'
|
||
action=(action "enableComponent")
|
||
icon="check"
|
||
label="admin.customize.theme.enable"}}
|
||
{{/if}}
|
||
{{/if}}
|
||
|
||
{{d-button action=(action "destroy") label="admin.customize.delete" icon="trash-alt" class="btn-danger"}}
|
||
</div>
|