diff --git a/awx/ui/client/features/credentials/add-edit-credentials.controller.js b/awx/ui/client/features/credentials/add-edit-credentials.controller.js
index d60539218a..64d5c4a93c 100644
--- a/awx/ui/client/features/credentials/add-edit-credentials.controller.js
+++ b/awx/ui/client/features/credentials/add-edit-credentials.controller.js
@@ -21,6 +21,7 @@ function AddEditCredentialsController (
credentialType,
organization,
isOrgEditableByUser,
+ sourceCredentials,
} = models;
const omit = ['user', 'team', 'inputs'];
@@ -131,7 +132,11 @@ function AddEditCredentialsController (
const apiConfig = ConfigService.get();
credentialType.mergeInputProperties();
- const fields = credential.assignInputGroupValues(apiConfig, credentialType);
+ const fields = credential.assignInputGroupValues(
+ apiConfig,
+ credentialType,
+ sourceCredentials
+ );
if (credentialType.get('name') === 'Google Compute Engine') {
fields.splice(2, 0, gceFileInputSchema);
@@ -417,6 +422,11 @@ function AddEditCredentialsController (
if (isExternal) {
data.results = data.results.filter(({ id }) => id !== credential.get('id'));
}
+
+ // only show credentials we can use
+ data.results = data.results
+ .filter(({ summary_fields }) => summary_fields.user_capabilities.use);
+
return data;
};
diff --git a/awx/ui/client/features/credentials/index.js b/awx/ui/client/features/credentials/index.js
index cb9b8147ff..1bdec18f93 100644
--- a/awx/ui/client/features/credentials/index.js
+++ b/awx/ui/client/features/credentials/index.js
@@ -16,7 +16,9 @@ function CredentialsResolve (
CredentialType,
Organization,
ProcessErrors,
- strings
+ strings,
+ Rest,
+ GetBasePath,
) {
const id = $stateParams.credential_id;
@@ -28,6 +30,7 @@ function CredentialsResolve (
promises.credential = new Credential('options');
promises.credentialType = new CredentialType();
promises.organization = new Organization();
+ promises.sourceCredentials = $q.resolve({ data: { count: 0, results: [] } });
return $q.all(promises);
}
@@ -39,10 +42,15 @@ function CredentialsResolve (
const typeId = models.credential.get('credential_type');
const orgId = models.credential.get('organization');
+ Rest.setUrl(GetBasePath('credentials'));
+ const params = { target_input_sources__target_credential: id };
+ const sourceCredentialsPromise = Rest.get({ params });
+
const dependents = {
credentialType: new CredentialType('get', typeId),
organization: new Organization('get', orgId),
- credentialInputSources: models.credential.extend('GET', 'input_sources')
+ credentialInputSources: models.credential.extend('GET', 'input_sources'),
+ sourceCredentials: sourceCredentialsPromise
};
dependents.isOrgCredAdmin = dependents.organization.then((org) => org.search({ role_level: 'credential_admin_role' }));
@@ -51,6 +59,7 @@ function CredentialsResolve (
.then(related => {
models.credentialType = related.credentialType;
models.organization = related.organization;
+ models.sourceCredentials = related.sourceCredentials;
const isOrgAdmin = _.some(models.me.get('related.admin_of_organizations.results'), (org) => org.id === models.organization.get('id'));
const isSuperuser = models.me.get('is_superuser');
@@ -79,7 +88,9 @@ CredentialsResolve.$inject = [
'CredentialTypeModel',
'OrganizationModel',
'ProcessErrors',
- 'CredentialsStrings'
+ 'CredentialsStrings',
+ 'Rest',
+ 'GetBasePath',
];
function CredentialsRun ($stateExtender, legacy, strings) {
diff --git a/awx/ui/client/lib/components/input/secret.partial.html b/awx/ui/client/lib/components/input/secret.partial.html
index 23ef5f6d98..b4c1012862 100644
--- a/awx/ui/client/lib/components/input/secret.partial.html
+++ b/awx/ui/client/lib/components/input/secret.partial.html
@@ -14,11 +14,16 @@