mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 01:04:55 +08:00
For historical reasons, Discourse has a customized Ember resolver. This had a much more fuzzy implementation of 'normalize' and 'findTemplate' functions. This leniency meant that our file naming hasn't always matched Ember conventions. Standardizing our naming will make things easier to understand for developers, and will make adoption of newer ecosystem tooling easier (e.g. route-based bundle splitting in Embroider/vite) This commit adds deprecations to the resolver when this leniency is used, and uses a fully bespoke codemod to rename all of the affected routes/controllers/templates in the Discourse core repository. Backwards-compatibility is maintained for anyone looking up the old names in the resolver.
28 lines
822 B
JavaScript
Vendored
28 lines
822 B
JavaScript
Vendored
import { service } from "@ember/service";
|
|
import { ajax } from "discourse/lib/ajax";
|
|
import { sanitize } from "discourse/lib/text";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import AdminPlugin from "admin/models/admin-plugin";
|
|
|
|
export default class AdminPluginsShowRoute extends DiscourseRoute {
|
|
@service router;
|
|
@service adminPluginNavManager;
|
|
|
|
async model(params) {
|
|
const pluginId = sanitize(params.plugin_id).substring(0, 100);
|
|
const pluginAttrs = await ajax(`/admin/plugins/${pluginId}.json`);
|
|
return AdminPlugin.create(pluginAttrs);
|
|
}
|
|
|
|
afterModel(model) {
|
|
this.adminPluginNavManager.currentPlugin = model;
|
|
}
|
|
|
|
deactivate() {
|
|
this.adminPluginNavManager.currentPlugin = null;
|
|
}
|
|
|
|
titleToken() {
|
|
return this.adminPluginNavManager.currentPlugin.nameTitleized;
|
|
}
|
|
}
|