DEV: Add backwards-compat for SiteSettings/User globals in ember-cli (#15719)
This commit is contained in:
parent
0b8d0a14d7
commit
fe1e66ba9d
|
@ -1,9 +1,40 @@
|
||||||
import { setDefaultOwner } from "discourse-common/lib/get-owner";
|
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 {
|
export default {
|
||||||
name: "inject-objects",
|
name: "inject-objects",
|
||||||
initialize(container, app) {
|
initialize(container, app) {
|
||||||
// This is required for Ember CLI tests to work
|
// This is required for Ember CLI tests to work
|
||||||
setDefaultOwner(app.__container__);
|
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;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue