From cf9f00ab864d0cb36d3cc6e660f5072163a8907f Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 10 Jan 2020 11:32:01 -0500 Subject: [PATCH] Use summary `object_roles` to lookup admin role id To find the id of an org's admin role, use the `object_role` names in the organization's summary_fields instead of filtering on potentially translated role names. --- .../organizations/linkout/addUsers/addUsers.controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js index 7e12d4b9b8..ebd3906186 100644 --- a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js +++ b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js @@ -26,11 +26,9 @@ function($scope, $rootScope, ProcessErrors, GetBasePath, generateList, let notAdminAlreadyParams = {}; if ($scope.addType === 'Administrators') { - Rest.setUrl(GetBasePath('organizations') + `${$state.params.organization_id}/object_roles`); + Rest.setUrl(GetBasePath('organizations') + `${$state.params.organization_id}`); Rest.get().then(({data}) => { - notAdminAlreadyParams.not__roles = data.results - .filter(({name}) => name === i18n._('Admin')) - .map(({id}) => id)[0]; + notAdminAlreadyParams.not__roles = data.summary_fields.object_roles.admin_role.id; init(); }); } else {