mirror of
https://github.com/discourse/discourse.git
synced 2025-04-10 05:20:48 +08:00
FEATURE: Add theme-components route for admin (#24264)
This commit adds an /admin/customize/theme-components route, that opens the theme page with the components tab pre-selected, so people can navigate to that directly.
This commit is contained in:
parent
0ef3836e0a
commit
986fb522be
@ -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 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ export default class AdminCustomizeThemesRoute extends Route {
|
|||||||
queryParams = {
|
queryParams = {
|
||||||
repoUrl: null,
|
repoUrl: null,
|
||||||
repoName: null,
|
repoName: null,
|
||||||
|
tab: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
@ -21,7 +22,17 @@ export default class AdminCustomizeThemesRoute extends Route {
|
|||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
super.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) {
|
if (controller.repoUrl) {
|
||||||
next(() => {
|
next(() => {
|
||||||
this.modal.show(InstallThemeModal, {
|
this.modal.show(InstallThemeModal, {
|
||||||
|
@ -58,6 +58,11 @@ export default function () {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.route("adminCustomizeThemeComponents", {
|
||||||
|
path: "theme-components",
|
||||||
|
resetNamespace: true,
|
||||||
|
});
|
||||||
|
|
||||||
this.route(
|
this.route(
|
||||||
"adminSiteText",
|
"adminSiteText",
|
||||||
{ path: "/site_texts", resetNamespace: true },
|
{ path: "/site_texts", resetNamespace: true },
|
||||||
|
@ -221,6 +221,7 @@ Discourse::Application.routes.draw do
|
|||||||
|
|
||||||
get "customize" => "color_schemes#index", :constraints => AdminConstraint.new
|
get "customize" => "color_schemes#index", :constraints => AdminConstraint.new
|
||||||
get "customize/themes" => "themes#index", :constraints => AdminConstraint.new
|
get "customize/themes" => "themes#index", :constraints => AdminConstraint.new
|
||||||
|
get "customize/theme-components" => "themes#index", :constraints => AdminConstraint.new
|
||||||
get "customize/colors" => "color_schemes#index", :constraints => AdminConstraint.new
|
get "customize/colors" => "color_schemes#index", :constraints => AdminConstraint.new
|
||||||
get "customize/colors/:id" => "color_schemes#index", :constraints => AdminConstraint.new
|
get "customize/colors/:id" => "color_schemes#index", :constraints => AdminConstraint.new
|
||||||
get "customize/permalinks" => "permalinks#index", :constraints => AdminConstraint.new
|
get "customize/permalinks" => "permalinks#index", :constraints => AdminConstraint.new
|
||||||
|
@ -40,9 +40,19 @@ describe "Admin Customize Themes", type: :system do
|
|||||||
|
|
||||||
expect(admin_customize_themes_page).to have_no_inactive_themes
|
expect(admin_customize_themes_page).to have_no_inactive_themes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "selects the themes tab by default" do
|
||||||
|
visit("/admin/customize/themes")
|
||||||
|
expect(find(".themes-list-header")).to have_css(".themes-tab.active")
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when visiting the page to customize the theme" do
|
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")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when visiting the page to customize a single theme" do
|
||||||
it "should allow admin to update the color scheme of the theme" do
|
it "should allow admin to update the color scheme of the theme" do
|
||||||
visit("/admin/customize/themes/#{theme.id}")
|
visit("/admin/customize/themes/#{theme.id}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user