FIX: Restore old admin themes/components page (#31887)

Follow-up to https://github.com/discourse/discourse/pull/30953

This PR is a partial revert of the linked PR — it changes the "Themes
and components" link in the admin sidebar back to the legacy
`/admin/customize/themes` page and adds the themes list/sidebar back to
the left hand side of the page. The new `/admin/config/customize/` route
is still available, but it's not linked from anywhere. When accessing
the new page and then navigating to a theme, the old components (e.g.
the themes list) of the page are hidden. This allows us to iterate on
the new page and improve until we're more ready to make it available
more widely.
This commit is contained in:
Osama Sayegh
2025-03-19 16:18:26 +03:00
committed by GitHub
parent 80118c8891
commit d4cbdf3ee0
8 changed files with 91 additions and 27 deletions

View File

@ -1,8 +1,10 @@
import { tracked } from "@glimmer/tracking";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import discourseComputed from "discourse/lib/decorators"; import discourseComputed from "discourse/lib/decorators";
import { THEMES } from "admin/models/theme"; import { THEMES } from "admin/models/theme";
export default class AdminCustomizeThemesController extends Controller { export default class AdminCustomizeThemesController extends Controller {
@tracked fromNewConfigPage = false;
currentTab = THEMES; currentTab = THEMES;
@discourseComputed("model", "model.@each.component") @discourseComputed("model", "model.@each.component")

View File

@ -23,14 +23,20 @@ export default class AdminCustomizeThemesShowRoute extends Route {
} }
} }
setupController(controller, model) { setupController(controller, model, transition) {
super.setupController(...arguments); super.setupController(...arguments);
const parentController = this.controllerFor("adminCustomizeThemes"); const parentController = this.controllerFor("adminCustomizeThemes");
const fromNewConfigPage = [
"adminConfig.customize.themes",
"adminConfig.customize.components",
].includes(transition?.from?.name);
parentController.setProperties({ parentController.setProperties({
editingTheme: false, editingTheme: false,
currentTab: model.get("component") ? COMPONENTS : THEMES, currentTab: model.get("component") ? COMPONENTS : THEMES,
fromNewConfigPage,
}); });
controller.setProperties({ controller.setProperties({
@ -42,6 +48,7 @@ export default class AdminCustomizeThemesShowRoute extends Route {
editingName: false, editingName: false,
editingThemeSetting: false, editingThemeSetting: false,
userLocale: parentController.get("model.extras.locale"), userLocale: parentController.get("model.extras.locale"),
fromNewConfigPage,
}); });
this.handleHighlight(model); this.handleHighlight(model);

View File

@ -1,6 +1,7 @@
{{#if this.editingThemeSetting}} {{#if this.editingThemeSetting}}
{{outlet}} {{outlet}}
{{else}} {{else}}
{{#if this.fromNewConfigPage}}
<div class="back-to-themes-and-components"> <div class="back-to-themes-and-components">
<LinkTo <LinkTo
@route={{if @route={{if
@ -19,7 +20,13 @@
}} }}
</LinkTo> </LinkTo>
</div> </div>
<div class="show-current-style"> {{/if}}
<div
class={{concat-class
"show-current-style"
(unless this.fromNewConfigPage "legacy")
}}
>
<span> <span>
<PluginOutlet <PluginOutlet
@name="admin-customize-themes-show-top" @name="admin-customize-themes-show-top"

View File

@ -1,3 +1,44 @@
{{#unless this.fromNewConfigPage}}
{{#if (eq this.currentTab "themes")}}
<DPageHeader
@titleLabel={{i18n "admin.config.themes.title"}}
@descriptionLabel={{i18n "admin.config.themes.header_description"}}
@learnMoreUrl="https://meta.discourse.org/t/91966"
@hideTabs={{true}}
>
<:breadcrumbs>
<DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />
<DBreadcrumbsItem
@path="/admin/customize/themes"
@label={{i18n "admin.config.themes.title"}}
/>
</:breadcrumbs>
</DPageHeader>
{{else}}
<DPageHeader
@titleLabel={{i18n "admin.config.components.title"}}
@descriptionLabel={{i18n "admin.config.components.header_description"}}
@hideTabs={{true}}
>
<:breadcrumbs>
<DBreadcrumbsItem @path="/admin" @label={{i18n "admin_title"}} />
<DBreadcrumbsItem
@path="/admin/customize/components"
@label={{i18n "admin.config.components.title"}}
/>
</:breadcrumbs>
</DPageHeader>
{{/if}}
{{/unless}}
<PluginOutlet @name="admin-customize-themes"> <PluginOutlet @name="admin-customize-themes">
{{#unless (or this.editingTheme this.fromNewConfigPage)}}
<ThemesList
@themes={{this.fullThemes}}
@components={{this.childThemes}}
@currentTab={{this.currentTab}}
@installModal={{route-action "installModal"}}
/>
{{/unless}}
{{outlet}} {{outlet}}
</PluginOutlet> </PluginOutlet>

View File

@ -241,9 +241,9 @@ export const ADMIN_NAV_MAP = [
}, },
{ {
name: "admin_themes_and_components", name: "admin_themes_and_components",
route: "adminConfig.customize.themes", route: "adminCustomizeThemes",
currentWhen: routeModels: ["themes"],
"adminConfig.customize.themes adminConfig.customize.components", currentWhen: "adminCustomizeThemes",
label: "admin.config.themes_and_components.title", label: "admin.config.themes_and_components.title",
description: "admin.config.themes_and_components.header_description", description: "admin.config.themes_and_components.header_description",
icon: "paintbrush", icon: "paintbrush",

View File

@ -1203,9 +1203,12 @@
.desktop-view .admin-customize { .desktop-view .admin-customize {
.show-current-style { .show-current-style {
padding-left: 0;
width: 68%; width: 68%;
&.legacy {
padding-left: 2%;
}
.title { .title {
input { input {
width: 80%; width: 80%;

View File

@ -144,8 +144,10 @@ describe "Admin Customize Themes", type: :system do
end end
end end
# TODO(osama) unskip this test when the "Themes and components" link is
# changed to the new config customize page
context "when visting a theme's page" do context "when visting a theme's page" do
it "has a link to the themes page" do xit "has a link to the themes page" do
visit("/admin/customize/themes/#{theme.id}") visit("/admin/customize/themes/#{theme.id}")
expect(admin_customize_themes_page).to have_back_button_to_themes_page expect(admin_customize_themes_page).to have_back_button_to_themes_page
end end
@ -154,7 +156,7 @@ describe "Admin Customize Themes", type: :system do
context "when visting a component's page" do context "when visting a component's page" do
fab!(:component) { Fabricate(:theme, component: true, name: "Cool component 493") } fab!(:component) { Fabricate(:theme, component: true, name: "Cool component 493") }
it "has a link to the components page" do xit "has a link to the components page" do
visit("/admin/customize/themes/#{component.id}") visit("/admin/customize/themes/#{component.id}")
expect(admin_customize_themes_page).to have_back_button_to_components_page expect(admin_customize_themes_page).to have_back_button_to_components_page
end end

View File

@ -302,13 +302,15 @@ describe "Admin | Sidebar Navigation", type: :system do
end end
it "highlights the 'Themes and components' link when the themes page is visited" do it "highlights the 'Themes and components' link when the themes page is visited" do
visit("/admin/config/customize/themes") visit("/admin/customize/themes")
expect(page).to have_css( expect(page).to have_css(
'.sidebar-section-link-wrapper[data-list-item-name="admin_themes_and_components"] a.active', '.sidebar-section-link-wrapper[data-list-item-name="admin_themes_and_components"] a.active',
) )
end end
it "highlights the 'Themes and components' link when the components page is visited" do # TODO(osama) unskip this test when the "Themes and components" link is
# changed to the new config customize page
xit "highlights the 'Themes and components' link when the components page is visited" do
visit("/admin/config/customize/components") visit("/admin/config/customize/components")
expect(page).to have_css( expect(page).to have_css(
'.sidebar-section-link-wrapper[data-list-item-name="admin_themes_and_components"] a.active', '.sidebar-section-link-wrapper[data-list-item-name="admin_themes_and_components"] a.active',