Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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('${', '');

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -958,6 +982,7 @@ const Property = ({
name={name}
onValueChange={(value) => {
onChange(value);

setSelectValue(value);
}}
options={options as Array<SelectOptionType>}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {PATH_SPACE_REPLACEMENT} from '@/shared/constants';
import {PATH_DIGIT_PREFIX, PATH_SPACE_REPLACEMENT} from '@/shared/constants';
import {
UpdateWorkflowNodeParameter200Response,
UpdateWorkflowNodeParameterOperationRequest,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions client/src/shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ export const EDGE_STYLES = {
};

export const PATH_SPACE_REPLACEMENT = '_SPACE_';
export const PATH_DIGIT_PREFIX = '_DIGIT_';
Loading