From 475e2605d4daed13c1ee673e992ebe86f62e1d6a Mon Sep 17 00:00:00 2001 From: mabashian Date: Wed, 11 Dec 2019 16:31:39 -0500 Subject: [PATCH] Changes redirect logic slightly to lean on a global var to store the config response rather than a constant on the awApp module. This should allow us to avoid test changes. --- awx/ui/client/src/app.js | 2 ++ awx/ui/client/src/app.start.js | 2 +- .../shared/load-config/load-config.factory.js | 18 +++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index 071db41067..5ba84826d4 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -3,6 +3,8 @@ global.$AnsibleConfig = null; // Provided via Webpack DefinePlugin in webpack.config.js global.$ENV = {}; +global.$ConfigResponse = {}; + var urlPrefix; if ($basePath) { diff --git a/awx/ui/client/src/app.start.js b/awx/ui/client/src/app.start.js index 026ee0162c..ef0c4a8fd5 100644 --- a/awx/ui/client/src/app.start.js +++ b/awx/ui/client/src/app.start.js @@ -55,7 +55,7 @@ function fetchConfig (callback) { const request = $.ajax('/api/'); request.done(res => { - angular.module('awApp').constant('ConfigSettings', res); + global.$ConfigResponse = res; if (res.login_redirect_override) { if (!document.cookie.split(';').filter((item) => item.includes('userLoggedIn=true')).length && !window.location.href.includes('/#/login')) { window.location.replace(res.login_redirect_override); diff --git a/awx/ui/client/src/shared/load-config/load-config.factory.js b/awx/ui/client/src/shared/load-config/load-config.factory.js index c1adfeee8f..56916cd7a4 100644 --- a/awx/ui/client/src/shared/load-config/load-config.factory.js +++ b/awx/ui/client/src/shared/load-config/load-config.factory.js @@ -1,25 +1,25 @@ export default - function LoadConfig($rootScope, Store, ConfigSettings) { + function LoadConfig($rootScope, Store) { return function() { var configSettings = {}; - if(ConfigSettings.custom_logo) { + if(global.$ConfigResponse.custom_logo) { configSettings.custom_logo = true; - $rootScope.custom_logo = ConfigSettings.custom_logo; + $rootScope.custom_logo = global.$ConfigResponse.custom_logo; } else { configSettings.custom_logo = false; } - if(ConfigSettings.custom_login_info) { - configSettings.custom_login_info = ConfigSettings.custom_login_info; - $rootScope.custom_login_info = ConfigSettings.custom_login_info; + if(global.$ConfigResponse.custom_login_info) { + configSettings.custom_login_info = global.$ConfigResponse.custom_login_info; + $rootScope.custom_login_info = global.$ConfigResponse.custom_login_info; } else { configSettings.custom_login_info = false; } - if (ConfigSettings.login_redirect_override) { - configSettings.login_redirect_override = ConfigSettings.login_redirect_override; + if (global.$ConfigResponse.login_redirect_override) { + configSettings.login_redirect_override = global.$ConfigResponse.login_redirect_override; } // Auto-resolving what used to be found when attempting to load local_setting.json @@ -37,4 +37,4 @@ export default } LoadConfig.$inject = - [ '$rootScope', 'Store', 'ConfigSettings' ]; + [ '$rootScope', 'Store' ];