Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass unresolved route promises in route-debug #1445

Merged
merged 6 commits into from
Feb 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions ember_debug/route-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export default EmberObject.extend(PortMixin, {
},
});

/**
*
* @param {*} routeTree
* @param {*} route
* @return {Void}
*/
function buildSubTree(routeTree, route) {
let handlers = route.handlers;
let owner = this.get('namespace.owner');
Expand Down Expand Up @@ -168,13 +174,23 @@ function buildSubTree(routeTree, route) {
// Ember < 3.9.0
routeHandler = routerLib.getHandler(handler);
}
controllerName =
routeHandler.get('controllerName') || routeHandler.get('routeName');
controllerFactory = owner.factoryFor
? owner.factoryFor(`controller:${controllerName}`)
: owner._lookupFactory(`controller:${controllerName}`);
controllerClassName = this.getClassName(controllerName, 'controller');
templateName = this.getClassName(handler, 'template');

// Skip when route is an unresolved promise
if (typeof routeHandler?.then === 'function') {
// ensure we rebuild the route tree when this route is resolved
routeHandler.then(() => this.notifyPropertyChange('routeTree'));
controllerName = '(unresolved)';
controllerClassName = '(unresolved)';
templateName = '(unresolved)';
} else {
controllerName =
routeHandler.get('controllerName') || routeHandler.get('routeName');
controllerFactory = owner.factoryFor
? owner.factoryFor(`controller:${controllerName}`)
: owner._lookupFactory(`controller:${controllerName}`);
controllerClassName = this.getClassName(controllerName, 'controller');
templateName = this.getClassName(handler, 'template');
}

subTree[handler] = {
value: {
Expand Down Expand Up @@ -227,6 +243,12 @@ function arrayizeChildren(routeTree) {
return obj;
}

/**
*
* @param {*} container
* @param {*} segments
* @return {String}
*/
function getURL(container, segments) {
const locationImplementation = container.lookup('router:main').location;
let url = [];
Expand Down Expand Up @@ -263,6 +285,12 @@ function getURL(container, segments) {
return url;
}

/**
*
* @param {String} owner
* @param {String} name
* @return {Void}
*/
function routeHasBeenDefined(owner, name) {
return (
owner.hasRegistration(`template:${name}`) ||
Expand Down