Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4946/BZ1093601 - allow org-switcher urls to pass through angular. #4137

Merged
merged 1 commit into from May 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions engines/bastion/app/assets/javascripts/bastion/bastion.module.js
Expand Up @@ -142,16 +142,16 @@ angular.module('Bastion').config(
* @requires gettextCatalog
* @requires currentLocale
* @requires $location
* @requires $sniffer
* @requires $window
* @requires PageTitle
* @requires RootURL
*
* @description
* Set up some common state related functionality and set the current language.
*/
angular.module('Bastion').run(['$rootScope', '$state', '$stateParams', 'gettextCatalog', 'currentLocale', '$location', '$sniffer', 'PageTitle', 'RootURL',
function ($rootScope, $state, $stateParams, gettextCatalog, currentLocale, $location, $sniffer, PageTitle, RootURL) {
var fromState, fromParams;
angular.module('Bastion').run(['$rootScope', '$state', '$stateParams', 'gettextCatalog', 'currentLocale', '$location', '$window', 'PageTitle', 'RootURL',
function ($rootScope, $state, $stateParams, gettextCatalog, currentLocale, $location, $window, PageTitle, RootURL) {
var fromState, fromParams, orgSwitcherRegex;

$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
Expand Down Expand Up @@ -204,5 +204,14 @@ angular.module('Bastion').run(['$rootScope', '$state', '$stateParams', 'gettextC
}
}
);

// Prevent angular from handling org/location switcher URLs
orgSwitcherRegex = new RegExp("/(organizations|locations)/.+/select");
$rootScope.$on('$locationChangeStart', function (event, newUrl) {
if (newUrl.match(orgSwitcherRegex)) {
event.preventDefault();
$window.location.href = newUrl;
}
});
}
]);