Skip to content

Commit 25d45ff

Browse files
committed
Delegate route.fail handling to app
1 parent 36a6ed1 commit 25d45ff

4 files changed

Lines changed: 27 additions & 6 deletions

File tree

js/ui/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class App extends Component {
5656
*/
5757
handleHistoryNavigate(e) {
5858
this.router_.go(e.token).thenCatch(err => {
59-
this.notifyError(`Routing failure while nagivating to ${e.token}`);
59+
console.warn(`Routing failure while nagivating to ${e.token}`);
6060
});
6161
}
6262

js/ui/history.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class History extends EventTarget {
4545
}
4646

4747
/**
48-
* @param {!events.Event} e
48+
* @param {!events.BrowserEvent} e
4949
*/
5050
handleDocumentClick(e) {
5151
//console.log("history; click!");
@@ -68,7 +68,13 @@ class History extends EventTarget {
6868
return;
6969
}
7070
e.preventDefault();
71-
e.stopPropagation();
71+
// e.stopPropagation();
72+
73+
if (e.ctrlKey) {
74+
const href = anchor.href.replace("/#/", "/");
75+
window.open(href, "_blank");
76+
return;
77+
}
7278
hash = hash.substring(2);
7379
//this.history_.replaceToken(hash);
7480
//this.replaceToken(hash);

js/ui/router.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ class Router extends EventTarget {
4545
* @type {?Route}
4646
*/
4747
this.route_ = null;
48+
49+
/**
50+
* Strict mode means that an existing route that hasn't finished yet will fail a new attempt.
51+
* @private
52+
* @type {boolean}
53+
*/
54+
this.strict_ = true;
4855

4956
}
5057

@@ -56,7 +63,15 @@ class Router extends EventTarget {
5663
getCurrentRoute() {
5764
return this.route_;
5865
}
59-
66+
67+
/**
68+
* Set the strict mode
69+
* @param {boolean} b
70+
*/
71+
setStrict(b) {
72+
this.strict_ = b;
73+
}
74+
6075
/**
6176
* Get a component if registered.
6277
*i
@@ -66,7 +81,7 @@ class Router extends EventTarget {
6681
go(path) {
6782
//console.log('go: ' + path);
6883
asserts.assertString(path, 'Routing path must be a string');
69-
if (this.route_) {
84+
if (this.strict_ && this.route_) {
7085
console.warn(`cannot route to ${path} due to existing route "${this.route_.matchedPath()}" --> "${this.route_.unmatchedPath()}"`);
7186
return Promise_.reject(
7287
'Already routing to ' + this.route_.getPath()

js/ui/select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class Select extends Component {
190190
*/
191191
selectFail(name, route) {
192192
route.fail(this, 'No tab for ' + name + ' in ' + JSON.stringify(this.name2id_));
193-
this.getApp().handle404(route);
193+
// this.getApp().handle404(route);
194194
}
195195

196196
/**

0 commit comments

Comments
 (0)