When a user types into a lookup field, we now only match against objects

the user has permission to access. I also included the type of thing it was.
So for instance, if you're typing into cloud credentials, it should validate
against cloud credentials, instead of validating against all credentials.
This commit is contained in:
jaredevantabor
2017-01-20 16:33:50 -08:00
parent 862a2d3c49
commit 6c7c4061d1

View File

@@ -587,6 +587,35 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'JobsHelper'])
basePath = GetBasePath(elm.attr('data-basePath')) || elm.attr('data-basePath');
query = elm.attr('data-query');
query = query.replace(/\:value/, encodeURIComponent(viewValue));
let base = ctrl.$name.split('_name')[0];
if (attrs.watchbasepath !== undefined && scope[attrs.watchbasepath] !== undefined) {
basePath = scope[attrs.watchbasepath];
query += '&role_level=use_role';
query = query.replace('?', '&');
}
else {
switch(base) {
case 'credential':
query += '&kind=ssh&role_level=use_role';
break;
case 'network_credential':
query += '&kind=net&role_level=use_role';
break;
case 'cloud_credential':
query += '&cloud=true&role_level=use_role';
break;
case 'organization':
query += '&role_level=admin_role';
break;
case 'inventory_script':
query += '&role_level=admin_role';
break;
default:
query += '&role_level=use_role';
}
}
Rest.setUrl(`${basePath}${query}`);
// https://github.com/ansible/ansible-tower/issues/3549
// capturing both success/failure conditions in .then() promise