replace unlinked fields before updating input sources

With credential type changes for linked credentials disabled, we can
update the unlinked credential fields first. If an error occurs when
updating the unlinked fields, no input sources will be changed.
This commit is contained in:
Jake McDermott
2019-03-29 15:53:08 -04:00
parent 6f43f223b2
commit 5d11400f6c

View File

@@ -72,6 +72,10 @@ function AddEditCredentialsController (
vm.form.credential_type._displayValue = credentialType.get('name');
vm.isTestable = (isEditable && credentialType.get('kind') === 'external');
if (credential.get('related.input_sources.results.length' > 0)) {
vm.form.credential_type._disabled = true;
}
$scope.$watch('$state.current.name', (value) => {
if (/credentials.edit($|\.organization$|\.credentialType$)/.test(value)) {
vm.tab.details._active = true;
@@ -548,8 +552,8 @@ function AddEditCredentialsController (
filteredInputs = _.omit(filteredInputs, updatedLinkedFieldNames);
data.inputs = filteredInputs;
return Promise.all(sourcesToDisassociate.map(deleteInputSource))
.then(() => credential.request('put', { data }))
return credential.request('put', { data })
.then(() => Promise.all(sourcesToDisassociate.map(deleteInputSource)))
.then(() => Promise.all(sourcesToAssociate.map(createInputSource)));
}