From 3115dd4feed1474e2bd18b0d694cac0716ab77b5 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Fri, 17 Jun 2016 13:43:02 -0700 Subject: [PATCH] hiding notifcation templates on setup menu for non org admins --- .../src/setup-menu/setup-menu.partial.html | 3 ++- awx/ui/client/src/setup-menu/setup.route.js | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/setup-menu/setup-menu.partial.html b/awx/ui/client/src/setup-menu/setup-menu.partial.html index f03ae05d08..ae1cdb0ee2 100644 --- a/awx/ui/client/src/setup-menu/setup-menu.partial.html +++ b/awx/ui/client/src/setup-menu/setup-menu.partial.html @@ -36,7 +36,8 @@ Create and edit scripts to dynamically load hosts from any source.

- +

Notifications

Create templates for sending notifications with Email, HipChat, Slack, and SMS. diff --git a/awx/ui/client/src/setup-menu/setup.route.js b/awx/ui/client/src/setup-menu/setup.route.js index fc080251ba..4a1d199018 100644 --- a/awx/ui/client/src/setup-menu/setup.route.js +++ b/awx/ui/client/src/setup-menu/setup.route.js @@ -6,5 +6,30 @@ export default { ncyBreadcrumb: { label: "SETTINGS" }, - templateUrl: templateUrl('setup-menu/setup-menu') + templateUrl: templateUrl('setup-menu/setup-menu'), + resolve: { + org_admin: + ['$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`); + Rest.get() + .success(function(data) { + $rootScope.orgAdmin = (data.count) ? true : false; + }).error(function (data, status) { + ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', msg: 'Failed to find if users is admin of org' + status }); + }); + } + } + else{ + return; + } + }); + }] + } };