diff --git a/client/src/pages/platform/workflow-editor/components/Properties/ObjectProperty.tsx b/client/src/pages/platform/workflow-editor/components/Properties/ObjectProperty.tsx index 65e77602ea6..4e26ea04c83 100644 --- a/client/src/pages/platform/workflow-editor/components/Properties/ObjectProperty.tsx +++ b/client/src/pages/platform/workflow-editor/components/Properties/ObjectProperty.tsx @@ -204,7 +204,6 @@ const ObjectProperty = ({arrayIndex, arrayName, onDeleteClick, operationName, pa key={`${property.name}_${subProperty.name}_${index}`} objectName={arrayName ? '' : name} operationName={operationName} - parameterValue={subProperty.defaultValue} path={`${path}.${subProperty.name}`} property={{ ...subProperty, 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 c79c38fcc26..92964862667 100644 --- a/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx +++ b/client/src/pages/platform/workflow-editor/components/Properties/Property.tsx @@ -18,7 +18,7 @@ import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/s import deleteProperty from '@/pages/platform/workflow-editor/utils/deleteProperty'; import getInputHTMLType from '@/pages/platform/workflow-editor/utils/getInputHTMLType'; import saveProperty from '@/pages/platform/workflow-editor/utils/saveProperty'; -import {PATH_SPACE_REPLACEMENT} from '@/shared/constants'; +import {PATH_DIGIT_PREFIX, PATH_SPACE_REPLACEMENT} from '@/shared/constants'; import {Option} from '@/shared/middleware/platform/configuration'; import {PropertyAllType} from '@/shared/types'; import {QuestionMarkCircledIcon} from '@radix-ui/react-icons'; @@ -182,6 +182,13 @@ const Property = ({ path = path.replace(/\s/g, PATH_SPACE_REPLACEMENT); } + if (path) { + path = path + .split('.') + .map((step) => (step.match(/^\d/) ? `${PATH_DIGIT_PREFIX}${step}` : step)) + .join('.'); + } + const getComponentIcon = (mentionValue: string) => { let componentName = mentionValue.split('_')[0].replace('${', ''); @@ -192,6 +199,24 @@ const Property = ({ return componentDefinitions.find((component) => component.name === componentName)?.icon || '📄'; }; + const formatKeysWithDigits = (obj: any) => { + const formattedObj = {...obj}; + + Object.keys(formattedObj).forEach((key) => { + if (key.match(/^\d/)) { + formattedObj[`${PATH_DIGIT_PREFIX}${key}`] = formattedObj[key]; + + delete formattedObj[key]; + } + + if (typeof formattedObj[key] === 'object' && formattedObj[key] !== null) { + formattedObj[key] = formatKeysWithDigits(formattedObj[key]); + } + }); + + return formattedObj; + }; + const saveInputValue = useDebouncedCallback(() => { if (!currentComponent || !workflow || !name || !path || !updateWorkflowNodeParameterMutation) { return; @@ -538,21 +563,23 @@ const Property = ({ const {parameters} = currentComponent; - if (!propertyParameterValue || propertyParameterValue === defaultValue) { + if (Object.keys(parameters).length && (!propertyParameterValue || propertyParameterValue === defaultValue)) { if (!path) { setPropertyParameterValue(parameters[name]); return; } - const formattedParamaters = replaceSpacesInKeys(parameters); + let formattedParameters = replaceSpacesInKeys(parameters); - const paramValue = resolvePath(formattedParamaters, path); + formattedParameters = formatKeysWithDigits(formattedParameters); + + const paramValue = resolvePath(formattedParameters, path); if (paramValue !== undefined || paramValue !== null) { setPropertyParameterValue(paramValue); } else { - setPropertyParameterValue(formattedParamaters[name]); + setPropertyParameterValue(formattedParameters[name]); } } // eslint-disable-next-line react-hooks/exhaustive-deps @@ -623,10 +650,7 @@ const Property = ({ setInputValue(propertyParameterValue); } - if ( - controlType === 'SELECT' && - (selectValue === '' || (selectValue === defaultValue && propertyParameterValue !== undefined)) - ) { + if (controlType === 'SELECT' && propertyParameterValue !== undefined) { if (propertyParameterValue === null) { setSelectValue('null'); } else if (propertyParameterValue !== undefined) { @@ -958,6 +982,7 @@ const Property = ({ name={name} onValueChange={(value) => { onChange(value); + setSelectValue(value); }} options={options as Array} diff --git a/client/src/pages/platform/workflow-editor/utils/saveProperty.ts b/client/src/pages/platform/workflow-editor/utils/saveProperty.ts index 6e930bb4774..cbd8acf3619 100644 --- a/client/src/pages/platform/workflow-editor/utils/saveProperty.ts +++ b/client/src/pages/platform/workflow-editor/utils/saveProperty.ts @@ -1,4 +1,4 @@ -import {PATH_SPACE_REPLACEMENT} from '@/shared/constants'; +import {PATH_DIGIT_PREFIX, PATH_SPACE_REPLACEMENT} from '@/shared/constants'; import { UpdateWorkflowNodeParameter200Response, UpdateWorkflowNodeParameterOperationRequest, @@ -41,6 +41,10 @@ export default function saveProperty({ path = path.replace(new RegExp(PATH_SPACE_REPLACEMENT, 'g'), ' '); } + if (path.includes(PATH_DIGIT_PREFIX)) { + path = path.replace(new RegExp(PATH_DIGIT_PREFIX, 'g'), ''); + } + updateWorkflowNodeParameterMutation.mutate( { id: workflowId, diff --git a/client/src/shared/constants.ts b/client/src/shared/constants.ts index 82487ea73ca..e045b4990d9 100644 --- a/client/src/shared/constants.ts +++ b/client/src/shared/constants.ts @@ -31,3 +31,4 @@ export const EDGE_STYLES = { }; export const PATH_SPACE_REPLACEMENT = '_SPACE_'; +export const PATH_DIGIT_PREFIX = '_DIGIT_';