2024-07-25 21:09:06 +08:00
|
|
|
import { service } from "@ember/service";
|
2024-03-13 11:15:12 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
import { sanitize } from "discourse/lib/text";
|
2024-09-10 13:16:16 +08:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2024-03-13 11:15:12 +08:00
|
|
|
import AdminPlugin from "admin/models/admin-plugin";
|
|
|
|
|
2024-09-10 13:16:16 +08:00
|
|
|
export default class AdminPluginsShowRoute extends DiscourseRoute {
|
2024-03-13 11:15:12 +08:00
|
|
|
@service router;
|
2024-03-21 11:42:06 +08:00
|
|
|
@service adminPluginNavManager;
|
2024-03-13 11:15:12 +08:00
|
|
|
|
2024-07-06 04:25:42 +08:00
|
|
|
async model(params) {
|
2024-03-13 11:15:12 +08:00
|
|
|
const pluginId = sanitize(params.plugin_id).substring(0, 100);
|
2024-07-06 04:25:42 +08:00
|
|
|
const pluginAttrs = await ajax(`/admin/plugins/${pluginId}.json`);
|
|
|
|
return AdminPlugin.create(pluginAttrs);
|
2024-03-13 11:15:12 +08:00
|
|
|
}
|
2024-03-21 11:42:06 +08:00
|
|
|
|
|
|
|
afterModel(model) {
|
|
|
|
this.adminPluginNavManager.currentPlugin = model;
|
|
|
|
}
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
this.adminPluginNavManager.currentPlugin = null;
|
|
|
|
}
|
2024-09-10 13:16:16 +08:00
|
|
|
|
|
|
|
titleToken() {
|
|
|
|
return this.adminPluginNavManager.currentPlugin.nameTitleized;
|
|
|
|
}
|
2024-03-13 11:15:12 +08:00
|
|
|
}
|