From 04dd4a75afd4b9b7ea63db7ca7ebc77c0b5949ae Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 3 Feb 2021 11:45:25 -0500 Subject: [PATCH] UX: Always show confirmation dialog when converting themes/components (#11953) --- .../admin-customize-themes-show.js | 36 ++++++++++--------- config/locales/client.en.yml | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js index ba3a2d323ce..721da9f7adf 100644 --- a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js +++ b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show.js @@ -369,25 +369,29 @@ export default Controller.extend({ switchType() { const relatives = this.get("model.component") - ? this.parentThemes + ? this.get("model.parentThemes") : this.get("model.childThemes"); + + let message = I18n.t(`${this.convertKey}_alert_generic`); + if (relatives && relatives.length > 0) { - const names = relatives.map((relative) => relative.get("name")); - bootbox.confirm( - I18n.t(`${this.convertKey}_alert`, { - relatives: names.join(", "), - }), - I18n.t("no_value"), - I18n.t("yes_value"), - (result) => { - if (result) { - this.commitSwitchType(); - } - } - ); - } else { - this.commitSwitchType(); + message = I18n.t(`${this.convertKey}_alert`, { + relatives: relatives + .map((relative) => relative.get("name")) + .join(", "), + }); } + + bootbox.confirm( + message, + I18n.t("no_value"), + I18n.t("yes_value"), + (result) => { + if (result) { + this.commitSwitchType(); + } + } + ); }, enableComponent() { diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 6b4b3cfed7e..d764896ab30 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4127,7 +4127,9 @@ en: convert: "Convert" convert_component_alert: "Are you sure you want to convert this component to theme? It will be removed as a component from %{relatives}." convert_component_tooltip: "Convert this component to theme" + convert_component_alert_generic: "Are you sure you want to convert this component to theme?" convert_theme_alert: "Are you sure you want to convert this theme to component? It will be removed as a parent from %{relatives}." + convert_theme_alert_generic: "Are you sure you want to convert this theme to component?" convert_theme_tooltip: "Convert this theme to component" inactive_themes: "Inactive themes:" inactive_components: "Unused components:"