ui: Adds a Routes()
router DSL dumping function only in dev mode
#9666
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back in #5206 we fixed a URL encoding/decoding issues with URLs for wildcarded routes by extracting our routing configuration to a JSON-like JS pojo, before feeding this in Embers
Route.map
. This meant we could inspect the routing configuration from elsewhere to provide support for URL encoding/decoding. The one downside in doing this was that we were not using Embers Route DSL to code our Routing configuration.At the time we wrote a little
dump
util in order to easily convert the JSON-like configuration back to Ember's Router DSL should we ever need to, but commented it out as we didn't want it ending up in the production source code.We've since discovered
runInDebug
, which lets you specify inline code to be stripped from production builds.This PR uses
runInDebug
to wrap the a utility function calledRoutes()
, which will print out Embers Route DSL in a new tab should we need to. Passing a URL with a%s
marker will pass the Route DSL to the URL, for examplehttp://url.com?routes=%s
, this lets you easily use tools likeember-diagonal
. Additionally we've added aDEBUG_ROUTES_ENDPOINT
development environment variable (set via cookies), so you can set this URL semi-permanently if you always want the DSL passed to a URL instead of opening in a new tab. We named itRoutes()
for now and hung it off ofwindow
for easy usage - we shouldn't have any problems with clashes and its only a development function so we feel this is ok.To call this
Routes()
function, you can either typeRoutes()
into your WebInspector console and hit enter, or make some bookmarklets if you find yourself wanting to do this often - see below for directions:Lastly, there are probably a few other debug/dev functions I sometimes use that I could add in also, so I've added a new section in the README file to document this one and any future debug/dev functions.