Skip to content

Commit 0892aac

Browse files
committed
DEV: remove old themes/components code
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 3689005 commit 0892aac

File tree

9 files changed

+106
-868
lines changed

9 files changed

+106
-868
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);

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 & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,25 @@ export default RouteTemplate(
2626
{{#if @controller.editingThemeSetting}}
2727
{{outlet}}
2828
{{else}}
29-
{{#if @controller.fromNewConfigPage}}
30-
<div class="back-to-themes-and-components">
31-
<LinkTo
32-
@route={{if
29+
<div class="back-to-themes-and-components">
30+
<LinkTo
31+
@route={{if
32+
@controller.model.component
33+
"adminConfig.customize.components"
34+
"adminConfig.customize.themes"
35+
}}
36+
>
37+
{{icon "angle-left"}}
38+
{{i18n
39+
(if
3340
@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-
>
41+
"admin.config_areas.themes_and_components.components.back"
42+
"admin.config_areas.themes_and_components.themes.back"
43+
)
44+
}}
45+
</LinkTo>
46+
</div>
47+
<div class="show-current-style">
5548
<span>
5649
<PluginOutlet
5750
@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.

app/assets/javascripts/discourse/tests/acceptance/admin-install-theme-modal-test.js

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,88 @@ import { i18n } from "discourse-i18n";
55

66
acceptance("Admin - Themes - Install modal", function (needs) {
77
needs.user();
8+
needs.pretender((server, helper) => {
9+
const themes = [
10+
{
11+
id: 42,
12+
name: "discourse-incomplete-theme",
13+
created_at: "2022-01-01T12:00:00.000Z",
14+
updated_at: "2022-01-01T12:00:00.000Z",
15+
component: false,
16+
color_scheme: null,
17+
user_selectable: false,
18+
remote_theme_id: 42,
19+
supported: true,
20+
description: null,
21+
enabled: true,
22+
child_themes: [],
23+
remote_theme: {
24+
id: 42,
25+
remote_url: "git@github.com:discourse/discourse-incomplete-theme.git",
26+
remote_version: null,
27+
local_version: null,
28+
commits_behind: null,
29+
branch: null,
30+
remote_updated_at: null,
31+
updated_at: "2022-01-01T12:00:00.000Z",
32+
last_error_text: null,
33+
is_git: true,
34+
license_url: null,
35+
about_url: null,
36+
authors: null,
37+
theme_version: null,
38+
minimum_discourse_version: null,
39+
maximum_discourse_version: null,
40+
},
41+
},
42+
{
43+
id: 43,
44+
name: "Graceful",
45+
created_at: "2022-01-01T12:00:00.000Z",
46+
updated_at: "2022-01-01T12:00:00.000Z",
47+
component: false,
48+
color_scheme: null,
49+
user_selectable: false,
50+
remote_theme_id: 43,
51+
supported: true,
52+
description: null,
53+
enabled: true,
54+
child_themes: [],
55+
remote_theme: {
56+
id: 43,
57+
remote_url: "https://github.com/discourse/graceful",
58+
remote_version: null,
59+
local_version: null,
60+
commits_behind: null,
61+
branch: null,
62+
remote_updated_at: null,
63+
updated_at: "2022-01-01T12:00:00.000Z",
64+
last_error_text: null,
65+
is_git: true,
66+
license_url: null,
67+
about_url: null,
68+
authors: null,
69+
theme_version: null,
70+
minimum_discourse_version: null,
71+
maximum_discourse_version: null,
72+
},
73+
},
74+
];
75+
76+
server.get("/admin/config/customize/themes", () => {
77+
return helper.response(200, { themes });
78+
});
79+
});
880

981
test("closing the modal resets the modal inputs", async function (assert) {
1082
const urlInput = ".install-theme-content .repo input";
1183
const branchInput = ".install-theme-content .branch input";
1284
const publicKey = ".install-theme-content .public-key textarea";
1385

1486
const themeUrl = "git@github.com:discourse/discourse.git";
15-
await visit("/admin/customize/themes");
87+
await visit("/admin/config/customize/themes");
1688

17-
await click(".create-actions .btn-primary");
89+
await click(".theme-install-card__install-button");
1890
await click("#remote");
1991
await fillIn(urlInput, themeUrl);
2092
await click(".install-theme-content .inputs .advanced-repo");
@@ -25,7 +97,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
2597

2698
await click(".d-modal__footer .d-modal-cancel");
2799

28-
await click(".create-actions .btn-primary");
100+
await click(".theme-install-card__install-button");
29101
await click("#remote");
30102
await click(".install-theme-content .inputs .advanced-repo");
31103
assert.dom(urlInput).hasValue("", "url input is reset");
@@ -42,7 +114,7 @@ acceptance("Admin - Themes - Install modal", function (needs) {
42114
"discourse@discourse.git.backlog.com:/TEST_THEME/test-theme.git";
43115
await visit("/admin/customize/themes");
44116

45-
await click(".create-actions .btn-primary");
117+
await click(".theme-install-card__install-button");
46118
await click("#remote");
47119
await fillIn(urlInput, themeUrl);
48120
await click(".install-theme-content .inputs .advanced-repo");
@@ -74,21 +146,23 @@ acceptance("Admin - Themes - Install modal", function (needs) {
74146
});
75147

76148
test("modal can be auto-opened with the right query params", async function (assert) {
77-
await visit("/admin/customize/themes?repoUrl=testUrl&repoName=testName");
149+
await visit(
150+
"/admin/config/customize/themes?repoUrl=testUrl&repoName=testName"
151+
);
78152
assert.dom(".admin-install-theme-modal").exists("modal is visible");
79153
assert.dom(".install-theme code").hasText("testUrl", "repo url is visible");
80154

81155
await click(".d-modal-cancel");
82156
assert.strictEqual(
83157
currentURL(),
84-
"/admin/customize/themes",
158+
"/admin/config/customize/themes",
85159
"query params are cleared after dismissing the modal"
86160
);
87161
});
88162

89163
test("installed themes are matched with the popular list by URL", async function (assert) {
90-
await visit("/admin/customize/themes");
91-
await click(".create-actions .btn-primary");
164+
await visit("/admin/config/customize/themes");
165+
await click(".theme-install-card__install-button");
92166

93167
assert
94168
.dom(

0 commit comments

Comments
 (0)