fix: 🐛 Remove json_object from payload for non-json credentials (#1576)

* fix: 🐛 Remove json_object from payload for non-json credentials

* refactor: 💡 update new route logic for type specific attributes

* test: 💍 remove typeIn and use fillIn for json credential test
This commit is contained in:
Cameron Perera authored and GitHub committed 2023-01-12 16:28:43 -06:00
1 parent f7c80c8869
commit b02dc0aa43
4 files changed
+92 -6

No files matched your search

@@ -29,23 +29,28 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialsNewRou
'scopes.scope.credential-stores.credential-store'
);
let name, description;
/**
* this sets the credential attribute json_object to a string that
* replicates an empty json blob as CodeMirror expects a string
*/
const json_object = '{}';
if (this.currentModel?.isNew) {
({ name, description } = this.currentModel);
this.currentModel.rollbackAttributes();
}
/**
* this sets the credential attribute json_object to a string that
* replicates an empty json blob as CodeMirror expects a string
*/
const typeSpecificAttrs = {};
switch (type) {
case 'json':
typeSpecificAttrs.json_object = '{}';
}
return this.store.createRecord('credential', {
type,
credential_store_id,
name,
description,
json_object,
...typeSpecificAttrs,
});
}