2019-10-23 12:39:32 -04:00
|
|
|
import Route from "@ember/routing/route";
|
2017-04-12 10:52:52 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2021-02-18 12:51:44 -05:00
|
|
|
import { next } from "@ember/runloop";
|
2021-01-11 10:29:12 -05:00
|
|
|
import { showUnassignedComponentWarning } from "admin/routes/admin-customize-themes-show";
|
2017-04-12 10:52:52 -04:00
|
|
|
|
2019-10-23 12:39:32 -04:00
|
|
|
export default Route.extend({
|
2021-02-18 12:51:44 -05:00
|
|
|
queryParams: {
|
|
|
|
repoUrl: null,
|
|
|
|
repoName: null,
|
|
|
|
},
|
|
|
|
|
2017-04-12 10:52:52 -04:00
|
|
|
model() {
|
|
|
|
return this.store.findAll("theme");
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
this._super(controller, model);
|
|
|
|
controller.set("editingTheme", false);
|
2021-02-18 12:51:44 -05:00
|
|
|
|
|
|
|
if (controller.repoUrl) {
|
|
|
|
next(() => {
|
|
|
|
showModal("admin-install-theme", {
|
|
|
|
admin: true,
|
|
|
|
}).setProperties({
|
|
|
|
uploadUrl: controller.repoUrl,
|
|
|
|
uploadName: controller.repoName,
|
|
|
|
selection: "directRepoInstall",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2019-02-20 14:58:31 -05:00
|
|
|
installModal() {
|
2021-01-11 10:29:12 -05: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 10:52:52 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
addTheme(theme) {
|
2019-01-31 14:29:09 -05:00
|
|
|
this.refresh();
|
2019-12-09 16:43:26 -05:00
|
|
|
theme.setProperties({ recentlyInstalled: true });
|
2021-02-18 12:51:44 -05:00
|
|
|
this.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
|
|
|
|
queryParams: {
|
|
|
|
repoName: null,
|
|
|
|
repoUrl: null,
|
|
|
|
},
|
|
|
|
});
|
2017-04-12 10:52:52 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|