diff --git a/app/assets/javascripts/discourse/app/initializers/inject-objects.js b/app/assets/javascripts/discourse/app/initializers/inject-objects.js index 533e9134af9..b325542587d 100644 --- a/app/assets/javascripts/discourse/app/initializers/inject-objects.js +++ b/app/assets/javascripts/discourse/app/initializers/inject-objects.js @@ -1,9 +1,40 @@ import { setDefaultOwner } from "discourse-common/lib/get-owner"; +import { isLegacyEmber } from "discourse-common/config/environment"; +import User from "discourse/models/user"; +import deprecated from "discourse-common/lib/deprecated"; export default { name: "inject-objects", initialize(container, app) { // This is required for Ember CLI tests to work setDefaultOwner(app.__container__); + + // Backwards compatibility for Discourse.SiteSettings and Discourse.User + if (!isLegacyEmber()) { + Object.defineProperty(app, "SiteSettings", { + get() { + deprecated( + `use injected siteSettings instead of Discourse.SiteSettings`, + { + since: "2.8", + dropFrom: "2.9", + } + ); + return container.lookup("site-settings:main"); + }, + }); + Object.defineProperty(app, "User", { + get() { + deprecated( + `import discourse/models/user instead of using Discourse.User`, + { + since: "2.8", + dropFrom: "2.9", + } + ); + return User; + }, + }); + } }, };