Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): add automatic credential selection for new nodes #2746

Merged
merged 27 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ea7f6f8
:zap: implemented automatic credential selection in nodes
michael-radency Feb 1, 2022
f253b88
Merge branch 'master' of https://github.com/n8n-io/n8n into enhanceme…
michael-radency Feb 2, 2022
9478cf8
:zap: fixed implementation
michael-radency Feb 2, 2022
2935547
:zap: fixed linter error
michael-radency Feb 2, 2022
9a8c8d8
:hammer: in progress, removed watching for auth type, added check for…
michael-radency Feb 4, 2022
da8fd1f
:hammer: removed console log
michael-radency Feb 4, 2022
a6fe5ef
:hammer: changing auth method for one that have default credential
michael-radency Feb 5, 2022
e7f5ef9
:hammer: credentials will be set only at node creation time
michael-radency Feb 7, 2022
0bd4db6
Merge branch 'master' of https://github.com/n8n-io/n8n into enhanceme…
michael-radency Feb 10, 2022
9df7e53
:hammer: fixed authentication parameter assigment for nodes that does…
michael-radency Feb 10, 2022
2a8657c
Merge branch 'master' of github.com:n8n-io/n8n into enhancement/autom…
mutdmour Feb 17, 2022
c6e978f
:zap: better properties checking
michael-radency Feb 18, 2022
415dd7f
Merge branch 'master' of https://github.com/n8n-io/n8n into enhanceme…
michael-radency Feb 23, 2022
3ec2097
:hammer: improvements
michael-radency Feb 23, 2022
f8f6ce6
Merge branch 'master' of https://github.com/n8n-io/n8n into enhanceme…
michael-radency Mar 2, 2022
5e34bce
:hammer: extracted into function, fix issue with assigning hidden cre…
michael-radency Mar 2, 2022
8d4fdbd
Merge branch 'master' of https://github.com/n8n-io/n8n into enhanceme…
michael-radency Mar 3, 2022
840ddee
merge in master; fix conflicts
mutdmour May 24, 2022
ede3a6c
remove console log
mutdmour May 24, 2022
f6920c2
Merge branch 'master' of github.com:n8n-io/n8n into enhancement/autom…
mutdmour Jul 20, 2022
736b469
fix bug with multiple creds
mutdmour Jul 20, 2022
54fe874
fix conflicts
mutdmour Oct 13, 2022
32eaf8a
fix defaults issue
mutdmour Oct 13, 2022
0eb98f4
remove import
mutdmour Oct 13, 2022
042c9cc
simplify to just auth
mutdmour Oct 13, 2022
8ee18b3
Revert "simplify to just auth"
mutdmour Oct 13, 2022
44b207f
fix get
mutdmour Oct 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/editor-ui/src/components/NodeCredentials.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
</div>

<div :class="issues.length ? $style.hasIssues : $style.input" v-else >
<n8n-select :value="getSelectedId(credentialTypeDescription.name)" @change="(value) => onCredentialSelected(credentialTypeDescription.name, value)" :placeholder="$locale.baseText('nodeCredentials.selectCredential')" size="small">
<n8n-select
:value="getSelectedId(credentialTypeDescription.name)"
@change="(value) => onCredentialSelected(credentialTypeDescription.name, value)"
:placeholder="$locale.baseText('nodeCredentials.selectCredential')"
size="small"
>
<n8n-option
v-for="(item) in credentialOptions[credentialTypeDescription.name]"
:key="item.id"
Expand Down Expand Up @@ -128,6 +133,7 @@ export default mixins(
return this.node.credentials || {};
},
},

methods: {
getSelectedId(type: string) {
if (this.isCredentialExisting(type)) {
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/mixins/nodeBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export const nodeBase = mixins(
},
__addNode (node: INodeUi) {
let nodeTypeData = this.$store.getters.nodeType(node.type, node.typeVersion) as INodeTypeDescription | null;

if (!nodeTypeData) {
// If node type is not know use by default the base.noOp data to display it
nodeTypeData = this.$store.getters.nodeType(NO_OP_NODE_TYPE) as INodeTypeDescription;
Expand Down
22 changes: 22 additions & 0 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,28 @@ export default mixins(
parameters: {},
};

const credentialPerType = nodeTypeData.credentials && nodeTypeData.credentials
mutdmour marked this conversation as resolved.
Show resolved Hide resolved
.map(type => this.$store.getters['credentials/getCredentialsByType'](type.name))
.filter(type => type.length === 1).map( item => item[0]);

if (credentialPerType && credentialPerType.length === 1) {
const defaultCredential = credentialPerType[0];

const selectedCredentials = this.$store.getters['credentials/getCredentialById'](defaultCredential.id);
const selected = { id: selectedCredentials.id, name: selectedCredentials.name };
const credentials = {
[defaultCredential.type]: selected,
};
newNodeData.credentials = credentials;

if (nodeTypeData.credentials){
const authentication = nodeTypeData.credentials.find(type => type.name === defaultCredential.type);
if(authentication!.displayOptions) {
newNodeData.parameters.authentication = authentication!.displayOptions!.show!.authentication![0];
mutdmour marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

// when pulling new connection from node or injecting into a connection
const lastSelectedNode = this.lastSelectedNode;
if (lastSelectedNode) {
Expand Down