fix(editor): Fix credential sharing issues handler when no matching id or name (#4879)

* fix: fix credential sharing issues handler when no matching id or name

* feat: Show erroring credential name as placeholder when available

* feat: Add (unavailable) descriptor for unavailable credentials
This commit is contained in:
Alex Grozav 2022-12-12 14:46:10 +02:00 committed by GitHub
parent 74b831b9b7
commit 1cce8eaf16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View file

@ -17,7 +17,7 @@
>
<div v-if="readonly || isReadOnly">
<n8n-input
:value="selected && selected[credentialTypeDescription.name] && selected[credentialTypeDescription.name].name"
:value="getSelectedName(credentialTypeDescription.name)"
disabled
size="small"
/>
@ -26,7 +26,12 @@
v-else
:class="issues.length ? $style.hasIssues : $style.input"
>
<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="getSelectPlaceholder(credentialTypeDescription.name, issues)"
size="small"
>
<n8n-option
v-for="(item) in getCredentialOptions(credentialTypeDescription.name)"
:key="item.id"
@ -180,6 +185,14 @@ export default mixins(
}
return undefined;
},
getSelectedName(type: string) {
return this.selected?.[type]?.name;
},
getSelectPlaceholder(type: string, issues: string[]) {
return issues.length && this.getSelectedName(type)
? this.$locale.baseText('nodeCredentials.selectedCredentialUnavailable', { interpolate: { name: this.getSelectedName(type) } })
: this.$locale.baseText('nodeCredentials.selectCredential');
},
credentialInputWrapperStyle (credentialType: string) {
let deductWidth = 0;
const styles = {

View file

@ -343,7 +343,8 @@ export const nodeHelpers = mixins(
}
if (nameMatches.length === 0) {
if (!this.settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.WorkflowSharing)) {
const isCredentialUsedInWorkflow = this.workflowsStore.usedCredentials?.[selectedCredentials.id as string];
if (!isCredentialUsedInWorkflow) {
foundIssues[credentialTypeDescription.name] = [this.$locale.baseText('nodeIssues.credentials.doNotExist', { interpolate: { name: selectedCredentials.name, type: credentialDisplayName } }), this.$locale.baseText('nodeIssues.credentials.doNotExist.hint')];
}
}

View file

@ -724,6 +724,7 @@
"nodeCredentials.credentialFor": "Credential for {credentialType}",
"nodeCredentials.issues": "Issues",
"nodeCredentials.selectCredential": "Select Credential",
"nodeCredentials.selectedCredentialUnavailable": "{name} (unavailable)",
"nodeCredentials.showMessage.message": "Nodes that used credential \"{oldCredentialName}\" have been updated to use \"{newCredentialName}\"",
"nodeCredentials.showMessage.title": "Node credential updated",
"nodeCredentials.updateCredential": "Update Credential",