Skip to content

Commit

Permalink
simplify to just auth
Browse files Browse the repository at this point in the history
  • Loading branch information
mutdmour committed Oct 13, 2022
1 parent 0eb98f4 commit 042c9cc
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,6 @@ export default mixins(
await this.loadNodesProperties([newNodeData].map(node => ({name: node.type, version: node.typeVersion})));
const nodeType = this.$store.getters['nodeTypes/getNodeType'](newNodeData.type, newNodeData.typeVersion) as INodeTypeDescription;
const nodeParameters = NodeHelpers.getNodeParameters(nodeType.properties, {}, true, false, newNodeData);
if (nodeTypeData.credentials) {
const authentication = nodeTypeData.credentials.find(type => type.name === defaultCredential.type);
Expand All @@ -1407,25 +1406,21 @@ export default mixins(
return newNodeData;
}
// ignore complex case when there's multiple dependencies
if (Object.keys(authDisplayOptions).length === 1 && authDisplayOptions['authentication']) {
// ignore complex case when there's multiple dependencies
const authProperty = (nodeType.properties || []).find((property) => property.name === 'authentication');
// ignore complex case when auth has dependencies
if (authProperty?.displayOptions) {
return newNodeData;
}
newNodeData.credentials = credentials;
let parameters: { [key:string]: string } = {};
for (const displayOption of Object.keys(authDisplayOptions)) {
if (nodeParameters && !nodeParameters[displayOption]) {
parameters = {};
newNodeData.credentials = undefined;
break;
}
const optionValue = get(authentication, `displayOptions.show[${displayOption}][0]`);
if (optionValue) {
parameters[displayOption] = optionValue;
}
newNodeData.parameters = {
...newNodeData.parameters,
...parameters,
};
// set authentication parameter value
const optionValue = authDisplayOptions?.authentication[0];
if (optionValue) {
newNodeData.parameters.authentication = optionValue;
}
}
}
Expand Down

0 comments on commit 042c9cc

Please sign in to comment.