From 344aed432d82933956695ffa7a96f821d438716c Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 22 Sep 2015 15:33:45 -0700 Subject: [PATCH] [appSwitcher] check for chrome on $scope --- src/ui/public/chrome/appSwitcher/appSwitcher.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/public/chrome/appSwitcher/appSwitcher.js b/src/ui/public/chrome/appSwitcher/appSwitcher.js index 7ba5b29488b1..55ce82fe5b09 100644 --- a/src/ui/public/chrome/appSwitcher/appSwitcher.js +++ b/src/ui/public/chrome/appSwitcher/appSwitcher.js @@ -1,4 +1,5 @@ var parse = require('url').parse; +var bindKey = require('lodash').bindKey; require('../appSwitcher/appSwitcher.less'); @@ -9,7 +10,15 @@ require('ui/modules') restrict: 'E', template: require('./appSwitcher.html'), controllerAs: 'switcher', - controller: function () { + controller: function ($scope, $window) { + + // 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. + if (!$scope.chrome || !$scope.chrome.getNavLinks) { + throw new TypeError('appSwitcher directive requires the "chrome" config-object'); + } + + this.getNavLinks = bindKey($scope.chrome, 'getNavLinks'); // links don't cause full-navigation events in certain scenarios // so we force them when needed