From d1824b9dd0714f78f35fd4fdc3a741a98e5927bf Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Sat, 9 Oct 2021 20:42:30 +0200 Subject: [PATCH] :bug: Fix error when opening ftp/sftp credentials (#2298) * n8n-2513 fix error when opening credentials * clean up validation logic --- .../CredentialEdit/CredentialEdit.vue | 22 ++++++++++++------- .../src/components/ParameterInputExpanded.vue | 16 +++++++++++++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue index 4fba543573..9532ad4073 100644 --- a/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue +++ b/packages/editor-ui/src/components/CredentialEdit/CredentialEdit.vue @@ -208,14 +208,16 @@ export default mixins(showMessage, nodeHelpers).extend({ activeNode: this.$store.getters.activeNode, }); - if (this.credentialId) { - if (!this.requiredPropertiesFilled) { - this.showValidationWarning = true; + setTimeout(() => { + if (this.credentialId) { + if (!this.requiredPropertiesFilled) { + this.showValidationWarning = true; + } + else { + this.retestCredential(); + } } - else { - this.retestCredential(); - } - } + }, 0); this.loading = false; }, @@ -329,7 +331,11 @@ export default mixins(showMessage, nodeHelpers).extend({ continue; } - if (!this.credentialData[property.name]) { + if (property.type === 'string' && !this.credentialData[property.name]) { + return false; + } + + if (property.type === 'number' && typeof this.credentialData[property.name] !== 'number') { return false; } } diff --git a/packages/editor-ui/src/components/ParameterInputExpanded.vue b/packages/editor-ui/src/components/ParameterInputExpanded.vue index d12788abc4..9aa0e5ba43 100644 --- a/packages/editor-ui/src/components/ParameterInputExpanded.vue +++ b/packages/editor-ui/src/components/ParameterInputExpanded.vue @@ -53,7 +53,21 @@ export default Vue.extend({ }, computed: { showRequiredErrors(): boolean { - return this.$props.parameter.type !== 'boolean' && !this.value && this.$props.parameter.required && (this.blurred || this.showValidationWarnings); + if (!this.$props.parameter.required) { + return false; + } + + if (this.blurred || this.showValidationWarnings) { + if (this.$props.parameter.type === 'string') { + return !this.value; + } + + if (this.$props.parameter.type === 'number') { + return typeof this.value !== 'number'; + } + } + + return false; }, }, methods: {