From 11bd5570cfb614f619f3e9dc3c81f8642e86e2e5 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 20 Jun 2016 11:37:27 -0700 Subject: [PATCH] fix for setup menu route resolve --- awx/ui/client/src/setup-menu/setup.route.js | 47 ++++++++++++--------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/awx/ui/client/src/setup-menu/setup.route.js b/awx/ui/client/src/setup-menu/setup.route.js index dd92b86be6..aac58a64cb 100644 --- a/awx/ui/client/src/setup-menu/setup.route.js +++ b/awx/ui/client/src/setup-menu/setup.route.js @@ -7,29 +7,38 @@ export default { label: "SETTINGS" }, templateUrl: templateUrl('setup-menu/setup-menu'), + controller: function(orgAdmin, $scope){ + $scope.orgAdmin = orgAdmin; + }, resolve: { - org_admin: + orgAdmin: ['$rootScope', 'ProcessErrors', 'Rest', function($rootScope, ProcessErrors, Rest){ - $rootScope.loginConfig.promise.then(function () { - if($rootScope.current_user.related.admin_of_organizations){ - $rootScope.orgAdmin = false; - if ($rootScope.current_user.is_superuser) { - $rootScope.orgAdmin = true; - } else { - Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); - return Rest.get().then(function(data){ - $rootScope.orgAdmin = (data.data.count) ? true : false; - }) - .catch(function (data, status) { - ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status }); - }); + + return $rootScope.loginConfig.promise.then(function () { + if($rootScope.current_user.related.admin_of_organizations){ + $rootScope.orgAdmin = false; + if ($rootScope.current_user.is_superuser) { + return true; + } else { + Rest.setUrl(`/api/v1/users/${$rootScope.current_user.id}/admin_of_organizations`); + return Rest.get().then(function(data){ + if(data.data.count){ + return true; + } + else{ + return false; + } + }) + .catch(function (data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status }); + }); + } } - } - else{ - return; - } - }); + else{ + return false; + } + }); }] } };