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:
parent
062a5f316d
commit
0e6f9ef406
|
@ -78,6 +78,11 @@ const DEPRECATED_MODULES = new Map(
|
||||||
since: "2.9.0.beta7",
|
since: "2.9.0.beta7",
|
||||||
dropFrom: "3.0.0",
|
dropFrom: "3.0.0",
|
||||||
},
|
},
|
||||||
|
"site:main": {
|
||||||
|
newName: "service:site",
|
||||||
|
since: "2.9.0.beta7",
|
||||||
|
dropFrom: "3.0.0",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -21,16 +21,11 @@ export default class DiscourseGlimmerComponent extends GlimmerComponent {
|
||||||
@service messageBus;
|
@service messageBus;
|
||||||
@service currentUser;
|
@service currentUser;
|
||||||
@service session;
|
@service session;
|
||||||
|
@service site;
|
||||||
|
|
||||||
@cached
|
@cached
|
||||||
get topicTrackingState() {
|
get topicTrackingState() {
|
||||||
const applicationInstance = getOwner(this);
|
const applicationInstance = getOwner(this);
|
||||||
return applicationInstance.lookup("topic-tracking-state:main");
|
return applicationInstance.lookup("topic-tracking-state:main");
|
||||||
}
|
}
|
||||||
|
|
||||||
@cached
|
|
||||||
get site() {
|
|
||||||
const applicationInstance = getOwner(this);
|
|
||||||
return applicationInstance.lookup("site:main");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function autoLoadModules(container, registry) {
|
||||||
keyValueStore: container.lookup("service:key-value-store"),
|
keyValueStore: container.lookup("service:key-value-store"),
|
||||||
capabilities: container.lookup("capabilities:main"),
|
capabilities: container.lookup("capabilities:main"),
|
||||||
currentUser: container.lookup("service:current-user"),
|
currentUser: container.lookup("service:current-user"),
|
||||||
site: container.lookup("site:main"),
|
site: container.lookup("service:site"),
|
||||||
session: container.lookup("service:session"),
|
session: container.lookup("service:session"),
|
||||||
topicTrackingState: container.lookup("topic-tracking-state:main"),
|
topicTrackingState: container.lookup("topic-tracking-state:main"),
|
||||||
registry,
|
registry,
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default {
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const banner = EmberObject.create(PreloadStore.get("banner") || {}),
|
const banner = EmberObject.create(PreloadStore.get("banner") || {}),
|
||||||
site = container.lookup("site:main");
|
site = container.lookup("service:site");
|
||||||
|
|
||||||
site.set("banner", banner);
|
site.set("banner", banner);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default {
|
||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
Mobile.init();
|
Mobile.init();
|
||||||
const site = container.lookup("site:main");
|
const site = container.lookup("service:site");
|
||||||
|
|
||||||
site.set("mobileView", Mobile.mobileView);
|
site.set("mobileView", Mobile.mobileView);
|
||||||
site.set("desktopView", !Mobile.mobileView);
|
site.set("desktopView", !Mobile.mobileView);
|
||||||
|
|
|
@ -16,7 +16,7 @@ export default {
|
||||||
withPluginApi("0.1", (api) => {
|
withPluginApi("0.1", (api) => {
|
||||||
const siteSettings = container.lookup("service:site-settings");
|
const siteSettings = container.lookup("service:site-settings");
|
||||||
const session = container.lookup("service:session");
|
const session = container.lookup("service:session");
|
||||||
const site = container.lookup("site:main");
|
const site = container.lookup("service:site");
|
||||||
api.decorateCookedElement(
|
api.decorateCookedElement(
|
||||||
(elem) => {
|
(elem) => {
|
||||||
return highlightSyntax(elem, siteSettings, session);
|
return highlightSyntax(elem, siteSettings, session);
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const site = container.lookup("site:main");
|
const site = container.lookup("service:site");
|
||||||
messageBus.subscribe("/site/read-only", function (enabled) {
|
messageBus.subscribe("/site/read-only", function (enabled) {
|
||||||
site.set("isReadOnly", enabled);
|
site.set("isReadOnly", enabled);
|
||||||
});
|
});
|
||||||
|
|
|
@ -132,7 +132,7 @@ export default {
|
||||||
appEvents.trigger("user-status:changed", data);
|
appEvents.trigger("user-status:changed", data);
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = container.lookup("site:main");
|
const site = container.lookup("service:site");
|
||||||
const router = container.lookup("router:main");
|
const router = container.lookup("router:main");
|
||||||
|
|
||||||
bus.subscribe("/categories", (data) => {
|
bus.subscribe("/categories", (data) => {
|
||||||
|
|
|
@ -400,7 +400,7 @@ class PluginApi {
|
||||||
* ```
|
* ```
|
||||||
**/
|
**/
|
||||||
addPosterIcons(cb) {
|
addPosterIcons(cb) {
|
||||||
const site = this._lookupContainer("site:main");
|
const site = this._lookupContainer("service:site");
|
||||||
const loc = site && site.mobileView ? "before" : "after";
|
const loc = site && site.mobileView ? "before" : "after";
|
||||||
|
|
||||||
decorateWidget(`poster-name:${loc}`, (dec) => {
|
decorateWidget(`poster-name:${loc}`, (dec) => {
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
const site = Site.current();
|
const site = Site.current();
|
||||||
app.register("site:main", site, { instantiate: false });
|
app.register("service:site", site, { instantiate: false });
|
||||||
|
|
||||||
const session = Session.current();
|
const session = Session.current();
|
||||||
app.register("service:session", session, { instantiate: false });
|
app.register("service:session", session, { instantiate: false });
|
||||||
|
@ -62,7 +62,7 @@ export default {
|
||||||
app.inject(t, "appEvents", "service:app-events");
|
app.inject(t, "appEvents", "service:app-events");
|
||||||
app.inject(t, "pmTopicTrackingState", "service:pm-topic-tracking-state");
|
app.inject(t, "pmTopicTrackingState", "service:pm-topic-tracking-state");
|
||||||
app.inject(t, "store", "service:store");
|
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, "searchService", "service:search");
|
||||||
app.inject(t, "session", "service:session");
|
app.inject(t, "session", "service:session");
|
||||||
app.inject(t, "messageBus", "service:message-bus");
|
app.inject(t, "messageBus", "service:message-bus");
|
||||||
|
|
|
@ -140,7 +140,7 @@ export default class Widget {
|
||||||
register.deprecateContainer(this);
|
register.deprecateContainer(this);
|
||||||
|
|
||||||
this.key = this.buildKey ? this.buildKey(attrs) : null;
|
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.siteSettings = register.lookup("service:site-settings");
|
||||||
this.currentUser = register.lookup("service:current-user");
|
this.currentUser = register.lookup("service:current-user");
|
||||||
this.capabilities = register.lookup("capabilities:main");
|
this.capabilities = register.lookup("capabilities:main");
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
function postStreamTest(name, attrs) {
|
function postStreamTest(name, attrs) {
|
||||||
test(name, async function (assert) {
|
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);
|
let posts = attrs.posts.call(this);
|
||||||
posts.forEach((p) => p.set("site", site));
|
posts.forEach((p) => p.set("site", site));
|
||||||
this.set("posts", posts);
|
this.set("posts", posts);
|
||||||
|
@ -26,7 +26,7 @@ module("Integration | Component | Widget | post-stream", function (hooks) {
|
||||||
|
|
||||||
postStreamTest("basics", {
|
postStreamTest("basics", {
|
||||||
posts() {
|
posts() {
|
||||||
const site = this.container.lookup("site:main");
|
const site = this.container.lookup("service:site");
|
||||||
const topic = Topic.create();
|
const topic = Topic.create();
|
||||||
topic.set("details.created_by", { id: 123 });
|
topic.set("details.created_by", { id: 123 });
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -282,7 +282,7 @@ export default function setupTests(config) {
|
||||||
},
|
},
|
||||||
capabilities: {},
|
capabilities: {},
|
||||||
get site() {
|
get site() {
|
||||||
return app.__container__.lookup("site:main") || Site.current();
|
return app.__container__.lookup("service:site") || Site.current();
|
||||||
},
|
},
|
||||||
registry: app.__registry__,
|
registry: app.__registry__,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue