A platform for community discussion. Free, open, simple.
FEATURE: Add theme-components route for admin (#24264)
Martin Brennan986fb522be1a
diff --git a/app/assets/javascripts/admin/addon/routes/admin-customize-theme-components.js b/app/assets/javascripts/admin/addon/routes/admin-customize-theme-components.jsnew file mode 100644index 00000000000..8c53f08dba4--- /dev/null+++ b/app/assets/javascripts/admin/addon/routes/admin-customize-theme-components.js@@ -0,0 +1,14 @@+import Route from "@ember/routing/route";+import { inject as service } from "@ember/service";+import { COMPONENTS } from "admin/models/theme";++export default class AdminCustomizeThemeComponents extends Route {+ @service router;++ beforeModel(transition) {+ transition.abort();+ this.router.transitionTo("adminCustomizeThemes", {+ queryParams: { tab: COMPONENTS },+ });+ }+}diff --git a/app/assets/javascripts/admin/addon/routes/admin-customize-themes.js b/app/assets/javascripts/admin/addon/routes/admin-customize-themes.jsindex 9a94480c277..1e4c7b04bc7 100644--- a/app/assets/javascripts/admin/addon/routes/admin-customize-themes.js+++ b/app/assets/javascripts/admin/addon/routes/admin-customize-themes.js@@ -13,6 +13,7 @@ export default class AdminCustomizeThemesRoute extends Route {queryParams = {repoUrl: null,repoName: null,+ tab: null,};model() {@@ -21,7 +22,17 @@ export default class AdminCustomizeThemesRoute extends Route {setupController(controller, model) {super.setupController(controller, model);- controller.set("editingTheme", false);++ if (controller.tab) {+ controller.setProperties({+ editingTheme: false,+ currentTab: controller.tab,++ // this is to get rid of the queryString since we don't want it hanging around+ tab: undefined,+ });+ }+if (controller.repoUrl) {next(() => {this.modal.show(InstallThemeModal, {diff --git a/app/assets/javascripts/admin/addon/routes/admin-route-map.js b/app/assets/javascripts/admin/addon/routes/admin-route-map.jsindex c180f64dab8..d7c1c958a3e 100644--- a/app/assets/javascripts/admin/addon/routes/admin-route-map.js+++ b/app/assets/javascripts/admin/addon/routes/admin-route-map.js@@ -58,6 +58,11 @@ export default function () {});+ this.route("adminCustomizeThemeComponents", {+ path: "theme-components",+ resetNamespace: true,+ });+this.route("adminSiteText",{ path: "/site_texts", resetNamespace: true },diff --git a/config/routes.rb b/config/routes.rbindex f014203b4a5..6f90e17fa90 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -221,6 +221,7 @@ Discourse::Application.routes.draw doget "customize" => "color_schemes#index", :constraints => AdminConstraint.newget "customize/themes" => "themes#index", :constraints => AdminConstraint.new+ get "customize/theme-components" => "themes#index", :constraints => AdminConstraint.newget "customize/colors" => "color_schemes#index", :constraints => AdminConstraint.newget "customize/colors/:id" => "color_schemes#index", :constraints => AdminConstraint.newget "customize/permalinks" => "permalinks#index", :constraints => AdminConstraint.newdiff --git a/spec/system/admin_customize_themes_spec.rb b/spec/system/admin_customize_themes_spec.rbindex a5577b4d9bf..10db0f2ebdd 100644--- a/spec/system/admin_customize_themes_spec.rb+++ b/spec/system/admin_customize_themes_spec.rb@@ -40,9 +40,19 @@ describe "Admin Customize Themes", type: :system doexpect(admin_customize_themes_page).to have_no_inactive_themesend++ it "selects the themes tab by default" do+ visit("/admin/customize/themes")+ expect(find(".themes-list-header")).to have_css(".themes-tab.active")+ end++ it "selects the component tab when visiting the theme-components route" do+ visit("/admin/customize/theme-components")+ expect(find(".themes-list-header")).to have_css(".components-tab.active")+ endend- describe "when visiting the page to customize the theme" do+ describe "when visiting the page to customize a single theme" doit "should allow admin to update the color scheme of the theme" dovisit("/admin/customize/themes/#{theme.id}")