discourse/app/assets/javascripts/admin/addon/routes/admin-customize-themes.js
Jarek Radosz c3fd91670e
DEV: Update linting setup and fix issues (#17345)
Re-lands #16119 and #17298

* Update eslint-config-discourse
* Update linting workflow
* Prettier-ignore stuff
* Update template-lint config
* Auto-fix template issues
* Fix various template issues
  Mostly incorrect attributes and unused templates
* Prettier js files
* Fix template auto-fix regressions
* Small css tweak

Co-authored-by: Peter Wagenet <peter.wagenet@gmail.com>
2022-07-06 10:37:54 +02:00

61 lines
1.5 KiB
JavaScript

import Route from "@ember/routing/route";
import showModal from "discourse/lib/show-modal";
import { next } from "@ember/runloop";
import { showUnassignedComponentWarning } from "admin/routes/admin-customize-themes-show";
export default Route.extend({
queryParams: {
repoUrl: null,
repoName: null,
},
model() {
return this.store.findAll("theme");
},
setupController(controller, model) {
this._super(controller, model);
controller.set("editingTheme", false);
if (controller.repoUrl) {
next(() => {
showModal("admin-install-theme", {
admin: true,
}).setProperties({
uploadUrl: controller.repoUrl,
uploadName: controller.repoName,
selection: "directRepoInstall",
});
});
}
},
actions: {
installModal() {
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 });
}
},
addTheme(theme) {
this.refresh();
theme.setProperties({ recentlyInstalled: true });
this.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
queryParams: {
repoName: null,
repoUrl: null,
},
});
},
},
});