DEV: Replace `site:main` with `service:site` (#17766)

This will allow consumers to inject it using `site: service()` in preparation for the removal of implicit injections in Ember 4.0. `site:main` is still available and will print a deprecation notice.
This commit is contained in:
David Taylor 2022-08-03 14:38:35 +01:00 committed by GitHub
parent 062a5f316d
commit 0e6f9ef406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 19 additions and 19 deletions

View File

@ -78,6 +78,11 @@ const DEPRECATED_MODULES = new Map(
since: "2.9.0.beta7",
dropFrom: "3.0.0",
},
"site:main": {
newName: "service:site",
since: "2.9.0.beta7",
dropFrom: "3.0.0",
},
})
);

View File

@ -21,16 +21,11 @@ export default class DiscourseGlimmerComponent extends GlimmerComponent {
@service messageBus;
@service currentUser;
@service session;
@service site;
@cached
get topicTrackingState() {
const applicationInstance = getOwner(this);
return applicationInstance.lookup("topic-tracking-state:main");
}
@cached
get site() {
const applicationInstance = getOwner(this);
return applicationInstance.lookup("site:main");
}
}

View File

@ -22,7 +22,7 @@ export function autoLoadModules(container, registry) {
keyValueStore: container.lookup("service:key-value-store"),
capabilities: container.lookup("capabilities:main"),
currentUser: container.lookup("service:current-user"),
site: container.lookup("site:main"),
site: container.lookup("service:site"),
session: container.lookup("service:session"),
topicTrackingState: container.lookup("topic-tracking-state:main"),
registry,

View File

@ -7,7 +7,7 @@ export default {
initialize(container) {
const banner = EmberObject.create(PreloadStore.get("banner") || {}),
site = container.lookup("site:main");
site = container.lookup("service:site");
site.set("banner", banner);

View File

@ -9,7 +9,7 @@ export default {
initialize(container) {
Mobile.init();
const site = container.lookup("site:main");
const site = container.lookup("service:site");
site.set("mobileView", Mobile.mobileView);
site.set("desktopView", !Mobile.mobileView);

View File

@ -16,7 +16,7 @@ export default {
withPluginApi("0.1", (api) => {
const siteSettings = container.lookup("service:site-settings");
const session = container.lookup("service:session");
const site = container.lookup("site:main");
const site = container.lookup("service:site");
api.decorateCookedElement(
(elem) => {
return highlightSyntax(elem, siteSettings, session);

View File

@ -9,7 +9,7 @@ export default {
return;
}
const site = container.lookup("site:main");
const site = container.lookup("service:site");
messageBus.subscribe("/site/read-only", function (enabled) {
site.set("isReadOnly", enabled);
});

View File

@ -132,7 +132,7 @@ export default {
appEvents.trigger("user-status:changed", data);
});
const site = container.lookup("site:main");
const site = container.lookup("service:site");
const router = container.lookup("router:main");
bus.subscribe("/categories", (data) => {

View File

@ -400,7 +400,7 @@ class PluginApi {
* ```
**/
addPosterIcons(cb) {
const site = this._lookupContainer("site:main");
const site = this._lookupContainer("service:site");
const loc = site && site.mobileView ? "before" : "after";
decorateWidget(`poster-name:${loc}`, (dec) => {

View File

@ -51,7 +51,7 @@ export default {
});
const site = Site.current();
app.register("site:main", site, { instantiate: false });
app.register("service:site", site, { instantiate: false });
const session = Session.current();
app.register("service:session", session, { instantiate: false });
@ -62,7 +62,7 @@ export default {
app.inject(t, "appEvents", "service:app-events");
app.inject(t, "pmTopicTrackingState", "service:pm-topic-tracking-state");
app.inject(t, "store", "service:store");
app.inject(t, "site", "site:main");
app.inject(t, "site", "service:site");
app.inject(t, "searchService", "service:search");
app.inject(t, "session", "service:session");
app.inject(t, "messageBus", "service:message-bus");

View File

@ -140,7 +140,7 @@ export default class Widget {
register.deprecateContainer(this);
this.key = this.buildKey ? this.buildKey(attrs) : null;
this.site = register.lookup("site:main");
this.site = register.lookup("service:site");
this.siteSettings = register.lookup("service:site-settings");
this.currentUser = register.lookup("service:current-user");
this.capabilities = register.lookup("capabilities:main");

View File

@ -8,7 +8,7 @@ import Topic from "discourse/models/topic";
function postStreamTest(name, attrs) {
test(name, async function (assert) {
const site = this.container.lookup("site:main");
const site = this.container.lookup("service:site");
let posts = attrs.posts.call(this);
posts.forEach((p) => p.set("site", site));
this.set("posts", posts);
@ -26,7 +26,7 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
postStreamTest("basics", {
posts() {
const site = this.container.lookup("site:main");
const site = this.container.lookup("service:site");
const topic = Topic.create();
topic.set("details.created_by", { id: 123 });
return [

View File

@ -282,7 +282,7 @@ export default function setupTests(config) {
},
capabilities: {},
get site() {
return app.__container__.lookup("site:main") || Site.current();
return app.__container__.lookup("service:site") || Site.current();
},
registry: app.__registry__,
});