JS: Introuce Icinga.History.replaceCurrentState()

Before, we only had pushCurrentState() to add a new URL to the history
stack. But some actions, e.g. "load more" in history views require to
replace the current state instead of pushing. This is what
replaceCurrentState() supports now.
This commit is contained in:
Eric Lippmann 2020-01-15 09:57:30 +01:00
parent 97006973d8
commit 71b8ab9b68
1 changed files with 20 additions and 0 deletions

View File

@ -114,6 +114,26 @@
}
},
/**
* Replace the current history entry with the current state
*/
replaceCurrentState: function () {
if (! this.enabled) {
return;
}
var state = this.getCurrentState();
if (state.url) {
this.icinga.logger.debug('Replacing current history state');
window.history.replaceState(
this.getBehaviorState(),
null,
state.url
);
}
},
/**
* Push the given url as the new history state, unless the history is disabled
*