From bfcbc4d2d679a4ddc45cdbf6cab164707bd4ff5e Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Thu, 21 Mar 2019 16:54:55 +0300 Subject: [PATCH] FIX: discourse client should know about Logster (#7232) --- .../discourse/routes/app-route-map.js.es6 | 4 ++++ .../discourse/routes/logster.js.es6 | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/assets/javascripts/discourse/routes/logster.js.es6 diff --git a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 index b9fc992d74b..743141426b8 100644 --- a/app/assets/javascripts/discourse/routes/app-route-map.js.es6 +++ b/app/assets/javascripts/discourse/routes/app-route-map.js.es6 @@ -3,6 +3,10 @@ export default function() { this.route("exception", { path: "/exception" }); this.route("exception-unknown", { path: "/404" }); + this.route("logster", { path: "/logs" }, function() { + this.route("logster-routes", { path: "*path" }); + }); + this.route("about", { path: "/about", resetNamespace: true }); this.route("post", { path: "/p/:id" }); diff --git a/app/assets/javascripts/discourse/routes/logster.js.es6 b/app/assets/javascripts/discourse/routes/logster.js.es6 new file mode 100644 index 00000000000..ea71938dd0a --- /dev/null +++ b/app/assets/javascripts/discourse/routes/logster.js.es6 @@ -0,0 +1,18 @@ +import getURL from "discourse-common/lib/get-url"; +import { getOwner } from "discourse-common/lib/get-owner"; + +export default Discourse.Route.extend({ + beforeModel(transition) { + const router = getOwner(this).lookup("router:main"); + const currentURL = router.get("currentURL"); + transition.abort(); + + // hack due to Ember bug https://github.com/emberjs/ember.js/issues/5210 + // aborting the transition should revert the address bar to the + // previous route's url, otherwise we will end up with a broken + // back button + // workaround is to update the address bar ourselves + router.location.setURL(router.url); + window.location.href = getURL(currentURL); + } +});