diff --git a/src/ui/public/chrome/appSwitcher/appSwitcher.js b/src/ui/public/chrome/appSwitcher/appSwitcher.js index af809ed12cef..c84573960a27 100644 --- a/src/ui/public/chrome/appSwitcher/appSwitcher.js +++ b/src/ui/public/chrome/appSwitcher/appSwitcher.js @@ -2,6 +2,7 @@ var parse = require('url').parse; var bindKey = require('lodash').bindKey; require('../appSwitcher/appSwitcher.less'); +var DomLocationProvider = require('ui/domLocation'); require('ui/modules') .get('kibana') @@ -10,7 +11,8 @@ require('ui/modules') restrict: 'E', template: require('./appSwitcher.html'), controllerAs: 'switcher', - controller: function ($scope, $window) { + controller: function ($scope, Private) { + var domLocation = Private(DomLocationProvider); // since we render this in an isolate scope we can't "require: ^chrome", but // rather than remove all helpfull checks we can just check here. @@ -28,13 +30,13 @@ require('ui/modules') } var toParsed = parse(app.url); - var fromParsed = parse($window.location.href); + var fromParsed = parse(domLocation.href); var sameProto = toParsed.protocol === fromParsed.protocol; var sameHost = toParsed.host === fromParsed.host; var samePath = toParsed.path === fromParsed.path; if (sameProto && sameHost && samePath) { - $window.location.reload(); + domLocation.reload(); event.preventDefault(); } }; diff --git a/src/ui/public/domLocation.js b/src/ui/public/domLocation.js new file mode 100644 index 000000000000..f17926fd10a1 --- /dev/null +++ b/src/ui/public/domLocation.js @@ -0,0 +1,15 @@ +module.exports = function DomLocationProvider($window) { + return { + reload: function (forceFetch) { + $window.location.reload(forceFetch); + }, + + get href() { + return $window.location.href; + }, + + set href(val) { + return ($window.location.href = val); + } + }; +};