disable input source lookups when they can't be changed

If a user doesn't have permission to change an input field, we disable
the input field.
This commit is contained in:
Jake McDermott
2019-03-25 15:58:57 -04:00
parent c4a79a778f
commit f0f4f487fb
7 changed files with 65 additions and 12 deletions

View File

@@ -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;
};