Skip to content

Commit

Permalink
js: Do not re-open the detail url if it's the origin of a redirect
Browse files Browse the repository at this point in the history
refs #5600
  • Loading branch information
Johannes Meyer committed Sep 25, 2015
1 parent 086579b commit 67a28a4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions public/js/icinga/loader.js
Expand Up @@ -331,7 +331,7 @@
}
}

this.redirectToUrl(redirect, req.$target, req.getResponseHeader('X-Icinga-Rerender-Layout'));
this.redirectToUrl(redirect, req.$target, req.url, req.getResponseHeader('X-Icinga-Rerender-Layout'));
return true;
},

Expand All @@ -340,9 +340,10 @@
*
* @param {string} url
* @param {object} $target
* @param {string] origin
* @param {boolean} rerenderLayout
*/
redirectToUrl: function (url, $target, rerenderLayout) {
redirectToUrl: function (url, $target, origin, rerenderLayout) {
var icinga = this.icinga;

if (typeof rerenderLayout === 'undefined') {
Expand All @@ -365,7 +366,15 @@
// Retain detail URL if the layout is rerendered
parts = document.location.hash.split('#!').splice(1);
if (parts.length) {
r.loadNext = parts;
r.loadNext = $.grep(parts, function (url) {
if (url !== origin) {
icinga.logger.debug('Retaining detail url ' + url);
return true;
}

icinga.logger.debug('Discarding detail url ' + url + ' as it\'s the origin of the redirect');
return false;
});
}
}
} else {
Expand Down Expand Up @@ -609,7 +618,7 @@

this.processRedirectHeader(req);

if (typeof req.loadNext !== 'undefined') {
if (typeof req.loadNext !== 'undefined' && req.loadNext.length) {
if ($('#col2').length) {
this.loadUrl(req.loadNext[0], $('#col2'));
this.icinga.ui.layout2col();
Expand Down

0 comments on commit 67a28a4

Please sign in to comment.