From 2c240a0e4ecd9157dca612d98a8a7c68a65a9909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Thu, 27 Apr 2023 14:28:23 +0200 Subject: [PATCH] fix(editor): Show error in RLC if credentials are not set (#6108) --- .../ResourceLocator/ResourceLocator.vue | 39 +++++++++++++++++-- .../src/plugins/i18n/locales/en.json | 3 +- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue b/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue index 5d891fbede..b11d7a2eca 100644 --- a/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue +++ b/packages/editor-ui/src/components/ResourceLocator/ResourceLocator.vue @@ -22,10 +22,13 @@ {{ $locale.baseText('resourceLocator.mode.list.error.title') }} - + {{ $locale.baseText('resourceLocator.mode.list.error.description.part1') }} - {{ - $locale.baseText('resourceLocator.mode.list.error.description.part2') + {{ + $locale.baseText('resourceLocator.mode.list.error.description.part2.noCredentials') + }} + {{ + $locale.baseText('resourceLocator.mode.list.error.description.part2.hasCredentials') }} @@ -157,7 +160,12 @@ import { debounceHelper } from '@/mixins/debounce'; import stringify from 'fast-json-stable-stringify'; import { workflowHelpers } from '@/mixins/workflowHelpers'; import { nodeHelpers } from '@/mixins/nodeHelpers'; -import { getAppNameFromNodeName, isResourceLocatorValue, hasOnlyListMode } from '@/utils'; +import { + getAppNameFromNodeName, + isResourceLocatorValue, + hasOnlyListMode, + getMainAuthField, +} from '@/utils'; import { mapStores } from 'pinia'; import { useUIStore } from '@/stores/ui'; import { useWorkflowsStore } from '@/stores/workflows'; @@ -282,6 +290,17 @@ export default mixins(debounceHelper, workflowHelpers, nodeHelpers).extend({ } return !!(node && node.credentials && Object.keys(node.credentials).length === 1); }, + credentialsNotSet(): boolean { + const nodeType = this.nodeTypesStore.getNodeType(this.node?.type); + if (nodeType) { + const usesCredentials = + nodeType.credentials !== undefined && nodeType.credentials.length > 0; + if (usesCredentials && !this.node?.credentials) { + return true; + } + } + return false; + }, inputPlaceholder(): string { if (this.currentMode.placeholder) { return this.currentMode.placeholder; @@ -503,6 +522,18 @@ export default mixins(debounceHelper, workflowHelpers, nodeHelpers).extend({ const id = node.credentials[credentialKey].id; this.uiStore.openExistingCredential(id); }, + createNewCredential(): void { + const nodeType = this.nodeTypesStore.getNodeType(this.node?.type); + if (!nodeType) { + return; + } + const mainAuthType = getMainAuthField(nodeType); + const showAuthSelector = + mainAuthType !== null && + Array.isArray(mainAuthType.options) && + mainAuthType.options?.length > 0; + this.uiStore.openNewCredential('', showAuthSelector); + }, findModeByName(name: string): INodePropertyMode | null { if (this.parameter.modes) { return this.parameter.modes.find((mode: INodePropertyMode) => mode.name === name) || null; diff --git a/packages/editor-ui/src/plugins/i18n/locales/en.json b/packages/editor-ui/src/plugins/i18n/locales/en.json index ecf79a1733..44dd779f20 100644 --- a/packages/editor-ui/src/plugins/i18n/locales/en.json +++ b/packages/editor-ui/src/plugins/i18n/locales/en.json @@ -1038,7 +1038,8 @@ "resourceLocator.mode.list.disabled.title": "Change to Fixed mode to choose From List", "resourceLocator.mode.list.error.title": "Could not load list", "resourceLocator.mode.list.error.description.part1": "Please", - "resourceLocator.mode.list.error.description.part2": "check your credential", + "resourceLocator.mode.list.error.description.part2.hasCredentials": "check your credential", + "resourceLocator.mode.list.error.description.part2.noCredentials": "add your credential", "resourceLocator.mode.list.noResults": "No results", "resourceLocator.mode.list.openUrl": "Open URL", "resourceLocator.mode.list.placeholder": "Choose...",