diff --git a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6 b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6 index a7308865cea..b9712761e5b 100644 --- a/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6 +++ b/app/assets/javascripts/admin/controllers/admin-customize-themes-show.js.es6 @@ -23,7 +23,13 @@ export default Controller.extend({ editRouteName: "adminCustomizeThemes.edit", parentThemesNames: mapBy("model.parentThemes", "name"), availableParentThemes: filterBy("allThemes", "component", false), + availableActiveParentThemes: filterBy("availableParentThemes", "isActive"), availableThemesNames: mapBy("availableParentThemes", "name"), + availableActiveThemesNames: mapBy("availableActiveParentThemes", "name"), + availableActiveChildThemes: filterBy("availableChildThemes", "hasParents"), + availableComponentsNames: mapBy("availableChildThemes", "name"), + availableActiveComponentsNames: mapBy("availableActiveChildThemes", "name"), + childThemesNames: mapBy("model.childThemes", "name"), @discourseComputed("model.editedFields") editedFieldsFormatted() { @@ -60,7 +66,7 @@ export default Controller.extend({ }, @discourseComputed("model.parentThemes.[]") - relativesSelectorSettings() { + relativesSelectorSettingsForComponent() { return Ember.Object.create({ list_type: "compact", type: "list", @@ -71,12 +77,30 @@ export default Controller.extend({ choices: this.availableThemesNames, default: this.parentThemesNames.join("|"), value: this.parentThemesNames.join("|"), - defaultValues: this.availableThemesNames.join("|"), + defaultValues: this.availableActiveThemesNames.join("|"), allThemes: this.allThemes, setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all_themes") }); }, + @discourseComputed("model.parentThemes.[]") + relativesSelectorSettingsForTheme() { + return Ember.Object.create({ + list_type: "compact", + type: "list", + preview: null, + anyValue: false, + setting: "child_theme_ids", + label: I18n.t("admin.customize.theme.included_components"), + choices: this.availableComponentsNames, + default: this.childThemesNames.join("|"), + value: this.childThemesNames.join("|"), + defaultValues: this.availableActiveComponentsNames.join("|"), + allThemes: this.allThemes, + setDefaultValuesLabel: I18n.t("admin.customize.theme.add_all") + }); + }, + @discourseComputed("allThemes", "model.component", "model") availableChildThemes(allThemes) { if (!this.get("model.component")) { diff --git a/app/assets/javascripts/admin/mixins/setting-component.js.es6 b/app/assets/javascripts/admin/mixins/setting-component.js.es6 index 9cec8194049..63fa9bcf4b2 100644 --- a/app/assets/javascripts/admin/mixins/setting-component.js.es6 +++ b/app/assets/javascripts/admin/mixins/setting-component.js.es6 @@ -100,6 +100,28 @@ export default Mixin.create({ return settingDefault !== bufferedValue; }, + @discourseComputed("buffered.value") + bufferedValues(bufferedValuesString) { + return ( + bufferedValuesString && bufferedValuesString.split("|").filter(Boolean) + ); + }, + + @discourseComputed("setting.defaultValues") + defaultValues(defaultValuesString) { + return ( + defaultValuesString && defaultValuesString.split("|").filter(Boolean) + ); + }, + + @discourseComputed("defaultValues", "bufferedValues") + defaultIsAvailable(defaultValues, bufferedValues) { + return ( + defaultValues && + !defaultValues.every(value => bufferedValues.includes(value)) + ); + }, + _watchEnterKey: on("didInsertElement", function() { $(this.element).on("keydown.setting-enter", ".input-setting-string", e => { if (e.keyCode === 13) { @@ -216,7 +238,13 @@ export default Mixin.create({ }, setDefaultValues() { - this.set("buffered.value", this.get("setting.defaultValues")); + this.set( + "buffered.value", + this.bufferedValues + .concat(this.defaultValues) + .uniq() + .join("|") + ); } } }); diff --git a/app/assets/javascripts/admin/models/theme.js.es6 b/app/assets/javascripts/admin/models/theme.js.es6 index fb00497c257..d1528bcd06a 100644 --- a/app/assets/javascripts/admin/models/theme.js.es6 +++ b/app/assets/javascripts/admin/models/theme.js.es6 @@ -19,6 +19,7 @@ const Theme = RestModel.extend({ isActive: or("default", "user_selectable"), isPendingUpdates: gt("remote_theme.commits_behind", 0), hasEditedFields: gt("editedFields.length", 0), + hasParents: gt("parent_themes.length", 0), @discourseComputed("theme_fields.[]") targets() { diff --git a/app/assets/javascripts/admin/templates/components/site-setting.hbs b/app/assets/javascripts/admin/templates/components/site-setting.hbs index 888a132a26c..e67af557517 100644 --- a/app/assets/javascripts/admin/templates/components/site-setting.hbs +++ b/app/assets/javascripts/admin/templates/components/site-setting.hbs @@ -1,6 +1,6 @@

{{unbound settingName}}

- {{#if setting.defaultValues }} + {{#if defaultIsAvailable}} {{setting.setDefaultValuesLabel}} {{/if}}
diff --git a/app/assets/javascripts/admin/templates/customize-themes-show.hbs b/app/assets/javascripts/admin/templates/customize-themes-show.hbs index c90e73e7a52..b2039850562 100644 --- a/app/assets/javascripts/admin/templates/customize-themes-show.hbs +++ b/app/assets/javascripts/admin/templates/customize-themes-show.hbs @@ -99,23 +99,23 @@ {{/if}} - {{#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}} - - {{i18n 'admin.customize.theme.compare_commits'}} - - {{/if}} - {{else}} - {{#unless showRemoteError}} - {{i18n 'admin.customize.theme.up_to_date'}} {{format-date model.remote_theme.updated_at leaveAgo="true"}} - {{/unless}} + {{#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}} + + {{i18n 'admin.customize.theme.compare_commits'}} + {{/if}} + {{else}} + {{#unless showRemoteError}} + {{i18n 'admin.customize.theme.up_to_date'}} {{format-date model.remote_theme.updated_at leaveAgo="true"}} + {{/unless}} {{/if}} - + {{/if}} + {{else}} {{d-icon "info-circle"}} {{i18n "admin.customize.theme.imported_from_archive"}} @@ -125,24 +125,29 @@ {{/if}} {{#unless model.component}} -
-
{{i18n "admin.customize.theme.color_scheme"}}
-
{{i18n "admin.customize.theme.color_scheme_select"}}
-
- {{color-palettes - content=colorSchemes - filterable=true - forceEscape=true - value=colorSchemeId - icon="paint-brush"}} + {{#d-section class="form-horizontal theme settings"}} +
+
+ {{i18n "admin.customize.theme.color_scheme"}} +
+
+ {{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}} +
{{i18n "admin.customize.theme.color_scheme_select"}}
+
+
+ {{#if colorSchemeChanged}} + {{d-button action=(action "changeScheme") class="ok submit-edit" icon="check"}} + {{d-button action=(action "cancelChangeScheme") class="cancel cancel-edit" icon="times"}} + {{/if}} +
- {{#link-to 'adminCustomize.colors' class="btn btn-default edit"}}{{i18n 'admin.customize.colors.edit'}}{{/link-to}} -
+ {{/d-section}} {{/unless}} {{#if parentThemes}} @@ -156,15 +161,18 @@
{{/if}} - {{#if model.component }} -
-
{{i18n "admin.customize.theme.title"}}
- {{#d-section class="form-horizontal theme settings"}} -
- {{theme-setting-relatives-selector setting=relativesSelectorSettings model=model class="theme-setting"}} -
- {{/d-section}} -
+ {{#if model.component}} + {{#d-section class="form-horizontal theme settings"}} +
+ {{theme-setting-relatives-selector setting=relativesSelectorSettingsForComponent model=model class="theme-setting"}} +
+ {{/d-section}} + {{else}} + {{#d-section class="form-horizontal theme settings"}} +
+ {{theme-setting-relatives-selector setting=relativesSelectorSettingsForTheme model=model class="theme-setting"}} +
+ {{/d-section}} {{/if}}
@@ -193,12 +201,12 @@ {{#if model.uploads}} {{else}} @@ -229,34 +237,6 @@
{{/if}} - {{#if availableChildThemes}} -
-
- {{d-icon "puzzle-piece"}} - {{i18n "admin.customize.theme.theme_components"}} -
- {{#if model.childThemes.length}} - - {{/if}} - {{#if selectableChildThemes}} -
- {{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}} -
- {{/if}} -
- {{/if}} - {{d-icon 'desktop'}}{{i18n 'admin.customize.theme.preview'}} {{d-icon "download"}} {{i18n 'admin.export_json.button_text'}} @@ -275,8 +255,8 @@ action=(action "enableComponent") icon="check" label="admin.customize.theme.enable"}} + {{/if}} {{/if}} - {{/if}} - {{d-button action=(action "destroy") label="admin.customize.delete" icon="trash-alt" class="btn-danger"}} + {{d-button action=(action "destroy") label="admin.customize.delete" icon="trash-alt" class="btn-danger"}} diff --git a/app/assets/stylesheets/common/admin/customize.scss b/app/assets/stylesheets/common/admin/customize.scss index d626ba2c8b6..e96f6cf9032 100644 --- a/app/assets/stylesheets/common/admin/customize.scss +++ b/app/assets/stylesheets/common/admin/customize.scss @@ -319,7 +319,9 @@ } .theme.settings { - .theme-setting, + .theme-setting { + min-height: 35px; + } .theme-translation { padding-bottom: 0; margin-top: 18px; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 477d7c86c93..a7ce0e80b9a 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3624,6 +3624,8 @@ en: edit_css_html_help: "You have not edited any CSS or HTML" delete_upload_confirm: "Delete this upload? (Theme CSS may stop working!)" component_on_themes: "Include component on these themes" + included_components: "Included components" + add_all: "Add all" import_web_tip: "Repository containing theme" import_web_advanced: "Advanced..." import_file_tip: ".tar.gz, .zip, or .dcstyle.json file containing theme"