mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
DEV: Fix ember/no-private-routing-service
(#24009)
This commit is contained in:
parent
cbe772f6fa
commit
d38360b23f
@ -1,3 +1,4 @@
|
||||
/* eslint-disable ember/no-private-routing-service */
|
||||
import { getOwner } from "@ember/application";
|
||||
import { A } from "@ember/array";
|
||||
import Helper from "@ember/component/helper";
|
||||
|
@ -55,16 +55,16 @@ export default {
|
||||
const siteSettings = owner.lookup("service:site-settings");
|
||||
|
||||
const loginError = (errorMsg, className, properties, callback) => {
|
||||
const applicationRouter = owner.lookup("route:application");
|
||||
const applicationRoute = owner.lookup("route:application");
|
||||
const applicationController = owner.lookup(
|
||||
"controller:application"
|
||||
);
|
||||
modal.show(LoginModal, {
|
||||
model: {
|
||||
showNotActivated: (props) =>
|
||||
applicationRouter.send("showNotActivated", props),
|
||||
applicationRoute.send("showNotActivated", props),
|
||||
showCreateAccount: (props) =>
|
||||
applicationRouter.send("showCreateAccount", props),
|
||||
applicationRoute.send("showCreateAccount", props),
|
||||
canSignUp: applicationController.canSignUp,
|
||||
flash: errorMsg,
|
||||
flashType: className || "success",
|
||||
|
@ -37,7 +37,7 @@ export default {
|
||||
after: "inject-objects",
|
||||
|
||||
initialize(owner) {
|
||||
const router = owner.lookup("router:main");
|
||||
const router = owner.lookup("service:router");
|
||||
|
||||
router.on("routeDidChange", (transition) => {
|
||||
if (transition.isAborted) {
|
||||
|
@ -10,6 +10,7 @@ export default {
|
||||
|
||||
initialize(owner) {
|
||||
// Tell our AJAX system to track a page transition
|
||||
// eslint-disable-next-line ember/no-private-routing-service
|
||||
const router = owner.lookup("router:main");
|
||||
router.on("routeWillChange", this.handleRouteWillChange);
|
||||
|
||||
|
@ -30,7 +30,7 @@ export default {
|
||||
this.appEvents = owner.lookup("service:app-events");
|
||||
this.siteSettings = owner.lookup("service:site-settings");
|
||||
this.site = owner.lookup("service:site");
|
||||
this.router = owner.lookup("router:main");
|
||||
this.router = owner.lookup("service:router");
|
||||
|
||||
this.reviewableCountsChannel = `/reviewable_counts/${this.currentUser.id}`;
|
||||
|
||||
|
@ -93,8 +93,7 @@ export function register(user, router, appEvents) {
|
||||
|
||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
||||
if ("url" in event.data) {
|
||||
const url = event.data.url;
|
||||
router.handleURL(url);
|
||||
router.transitionTo(event.data.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable ember/no-private-routing-service */
|
||||
import { setOwner } from "@ember/application";
|
||||
import EmberObject from "@ember/object";
|
||||
import { next, schedule } from "@ember/runloop";
|
||||
|
@ -34,7 +34,9 @@ const Scrolling = Mixin.create({
|
||||
if (!opts.throttle) {
|
||||
opts.throttle = 100;
|
||||
}
|
||||
|
||||
// So we can not call the scrolled event while transitioning. There is no public API for this :'(
|
||||
// eslint-disable-next-line ember/no-private-routing-service
|
||||
const microLib = this.router._router._routerMicrolib;
|
||||
|
||||
let scheduleScrolled = () => {
|
||||
|
@ -10,17 +10,13 @@ export default createWidget("link", {
|
||||
tagName: "a",
|
||||
|
||||
href(attrs) {
|
||||
const route = attrs.route;
|
||||
if (route) {
|
||||
const router = this.register.lookup("router:main");
|
||||
if (router && router._routerMicrolib) {
|
||||
const params = [route];
|
||||
if (attrs.model) {
|
||||
params.push(attrs.model);
|
||||
}
|
||||
return getURL(
|
||||
router._routerMicrolib.generate.apply(router._routerMicrolib, params)
|
||||
);
|
||||
if (attrs.route) {
|
||||
const router = this.register.lookup("service:router");
|
||||
|
||||
if (attrs.model) {
|
||||
return router.urlFor(attrs.route, attrs.model);
|
||||
} else {
|
||||
return router.urlFor(attrs.route);
|
||||
}
|
||||
} else {
|
||||
return getURL(attrs.href);
|
||||
|
@ -51,7 +51,7 @@ acceptance("Auth Complete", function (needs) {
|
||||
withPluginApi("1.11.0", (api) => {
|
||||
api.addBeforeAuthCompleteCallback(() => {
|
||||
api.container
|
||||
.lookup("router:main")
|
||||
.lookup("service:router")
|
||||
.transitionTo("discovery.categories");
|
||||
return false;
|
||||
});
|
||||
|
@ -44,27 +44,6 @@ acceptance(
|
||||
);
|
||||
});
|
||||
|
||||
test("viewing group messages on subfolder setup", async function (assert) {
|
||||
const router = this.container.lookup("router:main");
|
||||
const originalRootURL = router.rootURL;
|
||||
|
||||
try {
|
||||
router.set("rootURL", "/forum/");
|
||||
|
||||
await visit("/forum/u/eviltrout/messages");
|
||||
|
||||
const messagesDropdown = selectKit(".user-nav-messages-dropdown");
|
||||
|
||||
assert.strictEqual(
|
||||
messagesDropdown.header().name(),
|
||||
I18n.t("user.messages.inbox"),
|
||||
"User personal inbox is selected in dropdown"
|
||||
);
|
||||
} finally {
|
||||
router.set("rootURL", originalRootURL);
|
||||
}
|
||||
});
|
||||
|
||||
test("viewing messages of another user", async function (assert) {
|
||||
updateCurrentUser({ id: 5, username: "charlie" });
|
||||
|
||||
|
@ -27,4 +27,13 @@ describe "Viewing user private messages", type: :system do
|
||||
expect(user_private_messages_page).to have_right_inbox_dropdown_value("miXeD_caSE_name")
|
||||
end
|
||||
end
|
||||
|
||||
describe "on subfolder setup" do
|
||||
it "allows the user to view the default messages inbox" do
|
||||
set_subfolder "/forum"
|
||||
|
||||
page.visit "/forum/u/#{user.username}/messages"
|
||||
expect(user_private_messages_page).to have_right_inbox_dropdown_value("Inbox")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user