Skip to content

Commit c4ff6bd

Browse files
authored
DEV: remove old themes/components code (#32875)
Recently, themes page was rebranded and put `/admin/config/customize/themes`. In this PR, old `/admin/customize/themes` was removed. In addition, when an admin visits an old URL, they are redirected to the new one.
1 parent 7a297a5 commit c4ff6bd

File tree

11 files changed

+107
-1370
lines changed

11 files changed

+107
-1370
lines changed

app/assets/javascripts/admin/addon/components/themes-list.gjs

Lines changed: 0 additions & 418 deletions
This file was deleted.

app/assets/javascripts/admin/addon/controllers/admin-customize-themes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { tracked } from "@glimmer/tracking";
21
import Controller from "@ember/controller";
32
import discourseComputed from "discourse/lib/decorators";
43
import { THEMES } from "admin/models/theme";
54

65
export default class AdminCustomizeThemesController extends Controller {
7-
@tracked fromNewConfigPage = false;
86
currentTab = THEMES;
97

108
@discourseComputed("model", "model.@each.component")
Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
import Route from "@ember/routing/route";
2-
import { emojiUrlFor } from "discourse/lib/text";
3-
4-
const externalResources = [
5-
{
6-
key: "admin.customize.theme.beginners_guide_title",
7-
link: "https://meta.discourse.org/t/91966",
8-
icon: "book",
9-
},
10-
{
11-
key: "admin.customize.theme.developers_guide_title",
12-
link: "https://meta.discourse.org/t/93648",
13-
icon: "book",
14-
},
15-
{
16-
key: "admin.customize.theme.browse_themes",
17-
link: "https://meta.discourse.org/c/theme",
18-
icon: "paintbrush",
19-
},
20-
];
2+
import { service } from "@ember/service";
213

224
export default class AdminCustomizeThemesIndexRoute extends Route {
23-
setupController(controller) {
24-
super.setupController(...arguments);
25-
this.controllerFor("adminCustomizeThemes").set("editingTheme", false);
26-
controller.setProperties({
27-
externalResources,
28-
womanArtistEmojiURL: emojiUrlFor("woman_artist:t5"),
29-
});
5+
@service router;
6+
7+
beforeModel() {
8+
this.router.transitionTo("adminConfig.customize.themes");
309
}
3110
}

app/assets/javascripts/admin/addon/routes/admin-customize-themes-show.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,14 @@ export default class AdminCustomizeThemesShowRoute extends Route {
2323
}
2424
}
2525

26-
setupController(controller, model, transition) {
26+
setupController(controller, model) {
2727
super.setupController(...arguments);
2828

2929
const parentController = this.controllerFor("adminCustomizeThemes");
3030

31-
const fromNewConfigPage =
32-
!transition.from ||
33-
[
34-
"adminConfig.customize.themes",
35-
"adminConfig.customize.components",
36-
].includes(transition.from.name);
37-
3831
parentController.setProperties({
3932
editingTheme: false,
4033
currentTab: model.get("component") ? COMPONENTS : THEMES,
41-
fromNewConfigPage,
4234
});
4335

4436
controller.setProperties({
@@ -50,7 +42,6 @@ export default class AdminCustomizeThemesShowRoute extends Route {
5042
editingName: false,
5143
editingThemeSetting: false,
5244
userLocale: parentController.get("model.extras.locale"),
53-
fromNewConfigPage,
5445
});
5546

5647
this.handleHighlight(model);
Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,13 @@
11
import { action } from "@ember/object";
22
import Route from "@ember/routing/route";
3-
import { next } from "@ember/runloop";
4-
import { service } from "@ember/service";
5-
import { i18n } from "discourse-i18n";
6-
import InstallThemeModal from "../components/modal/install-theme";
73

84
export default class AdminCustomizeThemesRoute extends Route {
9-
@service dialog;
10-
@service router;
11-
@service modal;
12-
13-
queryParams = {
14-
repoUrl: null,
15-
repoName: null,
16-
};
17-
18-
model(params) {
19-
this.currentTab = params.type;
5+
model() {
206
return this.store.findAll("theme");
217
}
228

23-
setupController(controller, model) {
24-
super.setupController(controller, model);
25-
26-
if (this.currentTab) {
27-
controller.setProperties({
28-
editingTheme: false,
29-
currentTab: this.currentTab,
30-
});
31-
}
32-
33-
if (controller.repoUrl) {
34-
next(() => {
35-
this.modal.show(InstallThemeModal, {
36-
model: {
37-
uploadUrl: controller.repoUrl,
38-
uploadName: controller.repoName,
39-
selection: "directRepoInstall",
40-
clearParams: this.clearParams,
41-
...this.installThemeOptions(model),
42-
},
43-
});
44-
});
45-
}
46-
}
47-
48-
installThemeOptions(model) {
49-
return {
50-
selectedType: this.controller.currentTab,
51-
userId: model.userId,
52-
content: model.content,
53-
installedThemes: this.controller.installedThemes,
54-
addTheme: this.addTheme,
55-
updateSelectedType: this.updateSelectedType,
56-
};
57-
}
58-
599
@action
6010
routeRefreshModel() {
6111
this.refresh();
6212
}
63-
64-
@action
65-
installModal() {
66-
const currentTheme = this.modelFor("adminCustomizeThemes");
67-
if (this.currentModel?.warnUnassignedComponent) {
68-
this.dialog.yesNoConfirm({
69-
message: i18n("admin.customize.theme.unsaved_parent_themes"),
70-
didConfirm: () => {
71-
currentTheme.set("recentlyInstalled", false);
72-
this.modal.show(InstallThemeModal, {
73-
model: { ...this.installThemeOptions(currentTheme) },
74-
});
75-
},
76-
});
77-
} else {
78-
this.modal.show(InstallThemeModal, {
79-
model: { ...this.installThemeOptions(currentTheme) },
80-
});
81-
}
82-
}
83-
84-
@action
85-
updateSelectedType(type) {
86-
this.controller.set("currentTab", type);
87-
}
88-
89-
@action
90-
clearParams() {
91-
this.controller.setProperties({
92-
repoUrl: null,
93-
repoName: null,
94-
});
95-
}
96-
97-
@action
98-
addTheme(theme) {
99-
this.refresh();
100-
theme.setProperties({ recentlyInstalled: true });
101-
this.router.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
102-
queryParams: {
103-
repoName: null,
104-
repoUrl: null,
105-
},
106-
});
107-
}
10813
}

app/assets/javascripts/admin/addon/templates/customize-themes-index.gjs

Lines changed: 0 additions & 37 deletions
This file was deleted.

app/assets/javascripts/admin/addon/templates/customize-themes-show.gjs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import PluginOutlet from "discourse/components/plugin-outlet";
77
import TextField from "discourse/components/text-field";
88
import UserLink from "discourse/components/user-link";
99
import avatar from "discourse/helpers/avatar";
10-
import concatClass from "discourse/helpers/concat-class";
1110
import icon from "discourse/helpers/d-icon";
1211
import formatDate from "discourse/helpers/format-date";
1312
import formatUsername from "discourse/helpers/format-username";
@@ -26,32 +25,25 @@ export default RouteTemplate(
2625
{{#if @controller.editingThemeSetting}}
2726
{{outlet}}
2827
{{else}}
29-
{{#if @controller.fromNewConfigPage}}
30-
<div class="back-to-themes-and-components">
31-
<LinkTo
32-
@route={{if
28+
<div class="back-to-themes-and-components">
29+
<LinkTo
30+
@route={{if
31+
@controller.model.component
32+
"adminConfig.customize.components"
33+
"adminConfig.customize.themes"
34+
}}
35+
>
36+
{{icon "angle-left"}}
37+
{{i18n
38+
(if
3339
@controller.model.component
34-
"adminConfig.customize.components"
35-
"adminConfig.customize.themes"
36-
}}
37-
>
38-
{{icon "angle-left"}}
39-
{{i18n
40-
(if
41-
@controller.model.component
42-
"admin.config_areas.themes_and_components.components.back"
43-
"admin.config_areas.themes_and_components.themes.back"
44-
)
45-
}}
46-
</LinkTo>
47-
</div>
48-
{{/if}}
49-
<div
50-
class={{concatClass
51-
"show-current-style"
52-
(unless @controller.fromNewConfigPage "legacy")
53-
}}
54-
>
40+
"admin.config_areas.themes_and_components.components.back"
41+
"admin.config_areas.themes_and_components.themes.back"
42+
)
43+
}}
44+
</LinkTo>
45+
</div>
46+
<div class="show-current-style">
5547
<span>
5648
<PluginOutlet
5749
@name="admin-customize-themes-show-top"

app/assets/javascripts/admin/addon/templates/customize-themes.gjs

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)