Skip to content

Commit 59a59e0

Browse files
feat(editor): Display Credential-Selector after Authentication Type-Selector (#3461)
* ⚡ Implemented automatic position detection for credential fields. * ✨ Updating automatic credentials position logic (removing `getParameterResolveOrder`call and fixing input spacing). * 🔨 Using crednetial fileds displayOptions to determine the position relative to authentication fields. * 👌 Handling credentials position detection edge-cases (no node type, no credentials)
1 parent ca92ff7 commit 59a59e0

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

packages/editor-ui/src/components/NodeCredentials.vue

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ export default mixins(
315315
<style lang="scss" module>
316316
.container {
317317
margin-top: var(--spacing-xs);
318+
319+
& > div:not(:first-child) {
320+
margin-top: var(--spacing-xs);
321+
}
318322
}
319323
320324
.warning {

packages/editor-ui/src/components/ParameterInputList.vue

+26-3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
import {
8989
INodeParameters,
9090
INodeProperties,
91+
INodeType,
92+
INodeTypeDescription,
9193
NodeParameterValue,
9294
} from 'n8n-workflow';
9395
@@ -101,7 +103,6 @@ import ParameterInputFull from '@/components/ParameterInputFull.vue';
101103
import { get, set } from 'lodash';
102104
103105
import mixins from 'vue-typed-mixins';
104-
import { WEBHOOK_NODE_TYPE } from '@/constants';
105106
106107
export default mixins(
107108
genericHelpers,
@@ -131,12 +132,34 @@ export default mixins(
131132
return this.$store.getters.activeNode;
132133
},
133134
indexToShowSlotAt (): number {
134-
if (this.node.type === WEBHOOK_NODE_TYPE) return 1;
135+
let index = 0;
136+
const credentialsDependencies = this.getCredentialsDependencies();
135137
136-
return 0;
138+
this.filteredParameters.forEach((prop, propIndex) => {
139+
if (credentialsDependencies.has(prop.name)) {
140+
index = propIndex + 1;
141+
}
142+
});
143+
144+
return index < this.filteredParameters.length ?
145+
index : this.filteredParameters.length - 1;
137146
},
138147
},
139148
methods: {
149+
getCredentialsDependencies() {
150+
const dependencies = new Set();
151+
const nodeType = this.$store.getters.nodeType(this.node.type, this.node.typeVersion) as INodeTypeDescription | undefined;
152+
153+
// Get names of all fields that credentials rendering depends on (using displayOptions > show)
154+
if(nodeType && nodeType.credentials) {
155+
for(const cred of nodeType.credentials) {
156+
if(cred.displayOptions && cred.displayOptions.show) {
157+
Object.keys(cred.displayOptions.show).forEach(fieldName => dependencies.add(fieldName));
158+
}
159+
}
160+
}
161+
return dependencies;
162+
},
140163
multipleValues (parameter: INodeProperties): boolean {
141164
if (this.getArgument('multipleValues', parameter) === true) {
142165
return true;

0 commit comments

Comments
 (0)