2019-10-24 00:39:32 +08:00
|
|
|
import Route from "@ember/routing/route";
|
2017-04-12 22:52:52 +08:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2021-02-19 01:51:44 +08:00
|
|
|
import { next } from "@ember/runloop";
|
2021-01-11 23:29:12 +08:00
|
|
|
import { showUnassignedComponentWarning } from "admin/routes/admin-customize-themes-show";
|
2017-04-12 22:52:52 +08:00
|
|
|
|
2019-10-24 00:39:32 +08:00
|
|
|
export default Route.extend({
|
2021-02-19 01:51:44 +08:00
|
|
|
queryParams: {
|
|
|
|
repoUrl: null,
|
|
|
|
repoName: null,
|
|
|
|
},
|
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
model() {
|
|
|
|
return this.store.findAll("theme");
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
this._super(controller, model);
|
|
|
|
controller.set("editingTheme", false);
|
2021-02-19 01:51:44 +08:00
|
|
|
|
|
|
|
if (controller.repoUrl) {
|
|
|
|
next(() => {
|
|
|
|
showModal("admin-install-theme", {
|
|
|
|
admin: true,
|
|
|
|
}).setProperties({
|
|
|
|
uploadUrl: controller.repoUrl,
|
|
|
|
uploadName: controller.repoName,
|
|
|
|
selection: "directRepoInstall",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2019-02-21 03:58:31 +08:00
|
|
|
installModal() {
|
2021-01-11 23:29:12 +08:00
|
|
|
const currentTheme = this.controllerFor("adminCustomizeThemes.show")
|
|
|
|
.model;
|
|
|
|
if (currentTheme && currentTheme.warnUnassignedComponent) {
|
|
|
|
showUnassignedComponentWarning(currentTheme, (result) => {
|
|
|
|
if (!result) {
|
|
|
|
showModal("admin-install-theme", { admin: true });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
showModal("admin-install-theme", { admin: true });
|
|
|
|
}
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
addTheme(theme) {
|
2019-02-01 03:29:09 +08:00
|
|
|
this.refresh();
|
2019-12-10 05:43:26 +08:00
|
|
|
theme.setProperties({ recentlyInstalled: true });
|
2021-02-19 01:51:44 +08:00
|
|
|
this.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
|
|
|
|
queryParams: {
|
|
|
|
repoName: null,
|
|
|
|
repoUrl: null,
|
|
|
|
},
|
|
|
|
});
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|