Skip to content

A platform for community discussion. Free, open, simple.

FIX: Edit color palette button pointing to wrong route (#34318)

Alan Guo Xiang Tan3ce3862b5e0d
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show-index.js b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show-index.js
index c5767c6e223..26a78a93313 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show-index.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-customize-themes-show-index.js
@@ -459,17 +459,4 @@ export default class AdminCustomizeThemesShowIndexController extends Controller
.saveChanges("enabled")
.catch(() => this.model.set("enabled", true));
}
-
- @action
- editLightColorScheme() {
- this.router.transitionTo("adminCustomize.colors.show", this.colorSchemeId);
- }
-
- @action
- editDarkColorScheme() {
- this.router.transitionTo(
- "adminCustomize.colors.show",
- this.darkColorSchemeId
- );
- }
}
diff --git a/app/assets/javascripts/admin/addon/templates/customize-themes-show-index.gjs b/app/assets/javascripts/admin/addon/templates/customize-themes-show-index.gjs
index f4f469892cb..92ef3a1d918 100644
--- a/app/assets/javascripts/admin/addon/templates/customize-themes-show-index.gjs
+++ b/app/assets/javascripts/admin/addon/templates/customize-themes-show-index.gjs
@@ -1,4 +1,5 @@
import { fn, hash } from "@ember/helper";
+import { LinkTo } from "@ember/routing";
import { htmlSafe } from "@ember/template";
import RouteTemplate from "ember-route-template";
import { and, not, or } from "truth-helpers";
@@ -140,18 +141,21 @@ export default RouteTemplate(
)
}}
/>
- {{#if @controller.colorSchemeId}}
- <DButton
- @icon="pencil"
- @action={{@controller.editLightColorScheme}}
- @title="admin.customize.theme.edit_color_scheme"
- />
- {{/if}}
</div>
<div class="desc">{{i18n
"admin.customize.theme.color_scheme_select"
- }}</div>
+ }}
+
+ {{#if @controller.colorSchemeId}}
+ <LinkTo
+ @route="adminCustomize.colors-show"
+ @model={{@controller.colorSchemeId}}
+ >
+ {{i18n "admin.customize.theme.edit_colors"}}
+ </LinkTo>
+ {{/if}}
+ </div>
</div>
<div class="setting-controls">
@@ -191,18 +195,20 @@ export default RouteTemplate(
)
}}
/>
+ </div>
+
+ <div class="desc">
+ {{i18n "admin.customize.theme.dark_color_scheme_select"}}
+
{{#if @controller.darkColorSchemeId}}
- <DButton
- @icon="pencil"
- @action={{@controller.editDarkColorScheme}}
- @title="admin.customize.theme.edit_dark_color_scheme"
- />
+ <LinkTo
+ @route="adminCustomize.colors-show"
+ @model={{@controller.darkColorSchemeId}}
+ >
+ {{i18n "admin.customize.theme.edit_colors"}}
+ </LinkTo>
{{/if}}
</div>
-
- <div class="desc">{{i18n
- "admin.customize.theme.dark_color_scheme_select"
- }}</div>
</div>
<div class="setting-controls">
{{#if @controller.darkColorSchemeChanged}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index a844bc47f68..ec5dfb6dd5b 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -6918,11 +6918,10 @@ en:
auto_update: "Auto update when Discourse is updated"
color_scheme: "Color Palette"
dark_color_scheme: "Dark Color Palette"
- edit_color_scheme: "Edit Color Palette"
- edit_dark_color_scheme: "Edit DarkWColor Palette"
default_light_scheme: "Light (default)"
- color_scheme_select: "Select colors to be used by theme"
- dark_color_scheme_select: "Select colors to be used by theme in dark mode"
+ color_scheme_select: "Select colors to be used by theme."
+ dark_color_scheme_select: "Select colors to be used by theme in dark mode."
+ edit_colors: "Edit colors"
custom_sections: "Custom sections:"
theme_components: "Theme Components"
add_all_themes: "Add all themes"
diff --git a/spec/system/admin_customize_themes_spec.rb b/spec/system/admin_customize_themes_spec.rb
index 6dc7f46812a..cdf8dcdabf7 100644
--- a/spec/system/admin_customize_themes_spec.rb
+++ b/spec/system/admin_customize_themes_spec.rb
@@ -12,7 +12,7 @@ describe "Admin Customize Themes", type: :system do
describe "when visiting the page to customize a single theme" do
it "should allow admin to update the light color scheme of the theme" do
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
color_scheme_settings = find(".theme-settings__light-color-scheme")
@@ -26,10 +26,15 @@ describe "Admin Customize Themes", type: :system do
expect(color_scheme_settings.find(".setting-value")).to have_content(color_scheme.name)
expect(color_scheme_settings).to have_no_css(".submit-light-edit")
expect(color_scheme_settings).to have_no_css(".cancel-light-edit")
+
+ expect(page).to have_link(
+ I18n.t("admin_js.admin.customize.theme.edit_colors"),
+ href: "/admin/customize/colors/#{color_scheme.id}",
+ )
end
it "should allow admin to update the dark color scheme of the theme" do
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
color_scheme_settings = find(".theme-settings__dark-color-scheme")
@@ -43,6 +48,11 @@ describe "Admin Customize Themes", type: :system do
expect(color_scheme_settings.find(".setting-value")).to have_content(color_scheme.name)
expect(color_scheme_settings).not_to have_css(".submit-dark-edit")
expect(color_scheme_settings).not_to have_css(".cancel-dark-edit")
+
+ expect(page).to have_link(
+ I18n.t("admin_js.admin.customize.theme.edit_colors"),
+ href: "/admin/customize/colors/#{color_scheme.id}",
+ )
end
end
@@ -82,7 +92,7 @@ describe "Admin Customize Themes", type: :system do
it "cannot edit js, upload files or delete system themes" do
theme.update_columns(id: -10)
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
expect(page).to have_css(".system-theme-info")
expect(page).to have_css(".title button")
expect(page).to have_no_css(".title button svg")
@@ -105,7 +115,7 @@ describe "Admin Customize Themes", type: :system do
theme.set_field(target: :settings, name: "yaml", value: yaml)
theme.save!
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
expect(page).to have_css(".created-by")
expect(page).to have_css(".export")
expect(page).to have_css(".extra-files")
@@ -117,7 +127,7 @@ describe "Admin Customize Themes", type: :system do
# This avoids needing to update the theme field data to point to a different theme id.
allow_any_instance_of(Theme).to receive(:system?).and_return(true)
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
expect(page).to have_css(".system-theme-info")
expect(page).to have_no_css(".created-by")
expect(page).to have_no_css(".export")
@@ -135,7 +145,7 @@ describe "Admin Customize Themes", type: :system do
theme.save!
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
theme_translations_settings_editor =
PageObjects::Components::AdminThemeTranslationsSettingsEditor.new
@@ -143,7 +153,7 @@ describe "Admin Customize Themes", type: :system do
theme_translations_settings_editor.fill_in("Hello World")
theme_translations_settings_editor.save
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
expect(theme_translations_settings_editor.get_input_value).to have_content("Hello World")
end
@@ -161,7 +171,7 @@ describe "Admin Customize Themes", type: :system do
)
theme.save!
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
theme_translations_settings_editor =
PageObjects::Components::AdminThemeTranslationsSettingsEditor.new
@@ -195,7 +205,7 @@ describe "Admin Customize Themes", type: :system do
)
theme.save!
- visit("/admin/customize/themes/#{theme.id}")
+ theme_page.visit(theme)
theme_translations_settings_editor =
PageObjects::Components::AdminThemeTranslationsSettingsEditor.new
diff --git a/spec/system/page_objects/pages/admin_customize_themes.rb b/spec/system/page_objects/pages/admin_customize_themes.rb
index 223e048ebc4..eec07e9f69c 100644
--- a/spec/system/page_objects/pages/admin_customize_themes.rb
+++ b/spec/system/page_objects/pages/admin_customize_themes.rb
@@ -3,8 +3,10 @@
module PageObjects
module Pages
class AdminCustomizeThemes < PageObjects::Pages::AdminBase
- def visit(id)
- page.visit("/admin/customize/themes/#{id}")
+ def visit(theme_or_theme_id)
+ page.visit(
+ "/admin/customize/themes/#{theme_or_theme_id.is_a?(Theme) ? theme_or_theme_id.id : theme_or_theme_id}",
+ )
end
def has_colors_tab?