diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index be7f14e5e5..d64ad4d091 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -495,19 +495,26 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'JobsHelper']) } function _doAutoPopulate() { - let query = ''; + let query = '?role_level=use_role'; if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) { basePath = scope[attrs.watchbasepath]; + query = '&role_level=use_role'; } else { basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath'); switch(modelName) { case 'credential': - query = '?kind=ssh'; + query = '?kind=ssh&role_level=use_role'; break; case 'network_credential': - query = '?kind=net'; + query = '?kind=net&role_level=use_role'; + break; + case 'organization': + query = '?role_level=admin_role'; + break; + case 'inventory_script': + query = '?role_level=admin_role'; break; } @@ -517,11 +524,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'JobsHelper']) Rest.get() .success(function (data) { if (data.count === 1) { - if(data.results[0].summary_fields.user_capabilities.edit === true){ - scope[modelKey] = data.results[0].name; - scope[modelName] = data.results[0].id; - } - + scope[modelKey] = data.results[0].name; + scope[modelName] = data.results[0].id; } }); } diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 9b59e9db81..bfaa383ea4 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1368,8 +1368,8 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += `data-basePath="${field.basePath}"`; html += `data-source="${field.sourceModel}"`; html += `data-query="?${field.sourceField}__iexact=:value"`; - html += (field.autopopulateLookup !== undefined) ? ` autopopulateLookup=${field.autopopulateLookup} ` : ""; - html += (field.watchBasePath !== undefined) ? ` watchBasePath=${field.watchBasePath} ` : ""; + html += (field.autopopulateLookup !== undefined) ? ` autopopulateLookup=${field.autopopulateLookup} ` : ""; + html += (field.watchBasePath !== undefined) ? ` watchBasePath=${field.watchBasePath} ` : ""; html += `ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 300, 'blur': 0 } }"`; html += " awlookup >\n"; html += "\n"; diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index 0d13e4ed7f..db3969d760 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -643,7 +643,10 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat }, params: { [field.sourceModel + '_search']: { - value: { page_size: '5' } + value: { + page_size: '5', + role_level: 'use_role' + } } }, ncyBreadcrumb: { @@ -683,6 +686,11 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat interpolator = $interpolate(list.basePath); path = interpolator({ $rootScope: $rootScope, $stateParams: $stateParams }); } + // Need to delete the role_level here b/c organizations and inventory scripts + // don't have a "use_role", only "admin_role" and "read_role" + if(list.iterator === "organization" || list.iterator === "inventory_script"){ + delete $stateParams[`${list.iterator}_search`].role_level; + } return qs.search(path, $stateParams[`${list.iterator}_search`]); } ]