-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[tests/functional] opt out of getting started on navigation #11881
Changes from 1 commit
263b2b6
1b77840
207a00c
9561233
a890065
01fef54
f88c940
b82612a
abf58a7
274ba24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import _ from 'lodash'; | ||
|
||
module.exports = class RouteSetupManager { | ||
export const WAIT_FOR_URL_CHANGE_TOKEN = new Error('WAIT_FOR_URL_CHANGE_TOKEN'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I were coming across this code, I'd end up here, where this token is defined, to try to understand why and how to use it. Maybe just leave a comment here, explaining its role? // Throw this inside of an Angular route resolver after calling `kbnUrl.change` so that the $router can
// observe the $location update. Otherwise, the location won't be updated.
export const WAIT_FOR_URL_CHANGE_TOKEN = new Error('WAIT_FOR_URL_CHANGE_TOKEN'); |
||
|
||
export class RouteSetupManager { | ||
constructor() { | ||
this.setupWork = []; | ||
this.onSetupComplete = []; | ||
|
@@ -71,9 +73,18 @@ module.exports = class RouteSetupManager { | |
|
||
return defer.promise.then(() => Promise.all(userWork.doWork())); | ||
}) | ||
.catch(error => { | ||
if (error !== WAIT_FOR_URL_CHANGE_TOKEN) { | ||
throw error; | ||
} | ||
|
||
// prevent moving forward, return a promise that never resolves | ||
// so that the $router can observe the $location update | ||
return Promise.halt(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super minor nit, but this seems more like the "early exit" exception, and throwing the error seems more like the default flow, so I'd suggest swapping the two: if (error === WAIT_FOR_URL_CHANGE_TOKEN) {
// prevent moving forward, return a promise that never resolves
// so that the $router can observe the $location update
return Promise.halt();
}
throw error; |
||
}) | ||
.then( | ||
() => invokeEach(this.onWorkComplete), | ||
err => callErrorHandlers(this.onWorkError, err) | ||
); | ||
} | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ import RouteManager from './route_manager'; | |
import 'angular-route/angular-route'; | ||
import { uiModules } from 'ui/modules'; | ||
const defaultRouteManager = new RouteManager(); | ||
import { ABORT_SETUP_WORK_TOKEN } from './route_setup_manager'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean this to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops |
||
|
||
module.exports = { | ||
...defaultRouteManager, | ||
ABORT_SETUP_WORK_TOKEN, | ||
enable() { | ||
uiModules | ||
.get('kibana', ['ngRoute']) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ycombinator I tried a different approach, throwing this token from within a route setup work function will halt the setup work, allowing it to wait for
kbnUrl
to change. What do you think?/cc @cjcenizal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spalger Do you think this throw should just become part of the
kbnUrl.change
function? It seems to me the two would always want to travel together, no?