From c3ddd39e037571113ec5e1b9c131455e3e258e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kre=C5=A1imir=20=C4=8Coko?= Date: Fri, 29 Nov 2024 17:04:56 +0100 Subject: [PATCH 1/2] 1516 - dont allow inserting additional datapills when property is not of type string --- .../workflow-editor/components/DataPill.tsx | 13 ++++++++++++- .../components/Properties/Property.tsx | 1 + .../PropertyMentionsInput/PropertyMentionsInput.tsx | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/client/src/pages/platform/workflow-editor/components/DataPill.tsx b/client/src/pages/platform/workflow-editor/components/DataPill.tsx index d98ecc5d93..0ca4303e30 100644 --- a/client/src/pages/platform/workflow-editor/components/DataPill.tsx +++ b/client/src/pages/platform/workflow-editor/components/DataPill.tsx @@ -2,6 +2,7 @@ import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/s import getNestedObject from '@/pages/platform/workflow-editor/utils/getNestedObject'; import {TYPE_ICONS} from '@/shared/typeIcons'; import {PropertyAllType} from '@/shared/types'; +import resolvePath from 'object-resolve-path'; import {MouseEvent} from 'react'; import {twMerge} from 'tailwind-merge'; @@ -24,7 +25,7 @@ const DataPill = ({ /* eslint-disable @typescript-eslint/no-explicit-any */ sampleOutput?: any; }) => { - const {focusedInput} = useWorkflowNodeDetailsPanelStore(); + const {currentComponent, focusedInput} = useWorkflowNodeDetailsPanelStore(); const mentionInput = focusedInput?.getEditor().getModule('mention'); @@ -52,6 +53,16 @@ const DataPill = ({ ? `${workflowNodeName}.${(path || dataPillName).replaceAll('/', '.').replaceAll('.[index]', '[index]')}` : workflowNodeName; + const parameters = currentComponent?.parameters || {}; + + if (Object.keys(parameters).length) { + const paramValue = resolvePath(parameters, mentionInput.options.path); + + if (mentionInput.options.singleMention && paramValue) { + return; + } + } + mentionInput.insertItem( { componentIcon, diff --git a/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx b/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx index c57adddbeb..9cf79c2513 100644 --- a/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx +++ b/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx @@ -915,6 +915,7 @@ const Property = ({ event.preventDefault(); } }} + path={path} placeholder={placeholder} ref={editorRef} required={required} diff --git a/client/src/pages/platform/workflow-editor/components/Properties/components/PropertyMentionsInput/PropertyMentionsInput.tsx b/client/src/pages/platform/workflow-editor/components/Properties/components/PropertyMentionsInput/PropertyMentionsInput.tsx index 0680ebbb51..26b9b24718 100644 --- a/client/src/pages/platform/workflow-editor/components/Properties/components/PropertyMentionsInput/PropertyMentionsInput.tsx +++ b/client/src/pages/platform/workflow-editor/components/Properties/components/PropertyMentionsInput/PropertyMentionsInput.tsx @@ -53,6 +53,7 @@ interface PropertyMentionsInputProps { onChange?: (value: string) => void; onKeyPress?: (event: KeyboardEvent) => void; overriddenDataPills?: Array; + path?: string; placeholder?: string; required?: boolean; singleMention?: boolean; @@ -74,6 +75,7 @@ const PropertyMentionsInput = forwardRef( onChange, onKeyPress, overriddenDataPills, + path, placeholder, required = false, showInputTypeSwitchButton = false, @@ -148,8 +150,10 @@ const PropertyMentionsInput = forwardRef( } ); }, + path, renderItem: (item: DataPillType) => MentionInputListItem(item), showDenotationChar: false, + singleMention, source: (searchTerm: string, renderList: (arg1: Array, arg2: string) => void) => { if (overriddenDataPills) { dataPills = overriddenDataPills; From fe24eb437a18de4dfe1098bf945e908246cd4cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kre=C5=A1imir=20=C4=8Coko?= Date: Fri, 29 Nov 2024 16:17:55 +0100 Subject: [PATCH 2/2] 1793 - handle FILE_ENTRY property the same as OBJECT_BUILDER --- .../workflow-editor/components/Properties/Property.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx b/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx index 9cf79c2513..7bffc4650b 100644 --- a/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx +++ b/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx @@ -989,7 +989,7 @@ const Property = ({ /> )} - {controlType === 'OBJECT_BUILDER' && ( + {(controlType === 'OBJECT_BUILDER' || type === 'FILE_ENTRY') && ( )} - {type === 'FILE_ENTRY' && } - {control && (isValidControlType || isNumericalInput) && path && ( <>