Fix workflow detail (#3382)
* fix: loop node init * fix: workflow detail * fix: point table * add null check
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { Controller, UseFormReturn } from 'react-hook-form';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { Box, Button, Card, Textarea } from '@chakra-ui/react';
|
||||
@@ -121,21 +121,7 @@ const VariableInput = ({
|
||||
const variablesForm = useContextSelector(ChatItemContext, (v) => v.variablesForm);
|
||||
const variableList = useContextSelector(ChatBoxContext, (v) => v.variableList);
|
||||
|
||||
const { setValue, handleSubmit: handleSubmitChat } = variablesForm;
|
||||
|
||||
const defaultValues = useMemo(() => {
|
||||
return variableList.reduce((acc: Record<string, any>, item) => {
|
||||
acc[item.key] = item.defaultValue;
|
||||
return acc;
|
||||
}, {});
|
||||
}, [variableList]);
|
||||
|
||||
useEffect(() => {
|
||||
const values = variablesForm.getValues('variables');
|
||||
// If form is not empty, do not reset the variables
|
||||
if (Object.values(values).filter(Boolean).length > 0) return;
|
||||
setValue('variables', defaultValues);
|
||||
}, [defaultValues, setValue, variablesForm]);
|
||||
const { handleSubmit: handleSubmitChat } = variablesForm;
|
||||
|
||||
return (
|
||||
<Box py={3}>
|
||||
|
||||
@@ -805,7 +805,7 @@ const ChatBox = ({
|
||||
setQuestionGuide([]);
|
||||
setValue('chatStarted', false);
|
||||
abortRequest('leave');
|
||||
}, [abortRequest, setValue]);
|
||||
}, [chatId, appId, abortRequest, setValue]);
|
||||
|
||||
// Add listener
|
||||
useEffect(() => {
|
||||
|
||||
@@ -110,17 +110,15 @@ const RenderInput = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const defaultFormValues = formatPluginInputs.reduce(
|
||||
(acc, input) => {
|
||||
acc[input.key] = input.defaultValue;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, any>
|
||||
);
|
||||
|
||||
reset({
|
||||
files: [],
|
||||
variables: defaultFormValues
|
||||
variables: formatPluginInputs.reduce(
|
||||
(acc, input) => {
|
||||
acc[input.key] = input.defaultValue;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, any>
|
||||
)
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -164,7 +162,7 @@ const RenderInput = () => {
|
||||
files: historyFileList
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [histories]);
|
||||
}, [histories, formatPluginInputs]);
|
||||
|
||||
const [uploading, setUploading] = useState(false);
|
||||
|
||||
|
||||
@@ -172,7 +172,6 @@ const RenderPluginInput = ({
|
||||
return (
|
||||
<Textarea
|
||||
value={value}
|
||||
defaultValue={input.defaultValue}
|
||||
onChange={onChange}
|
||||
isDisabled={isDisabled}
|
||||
placeholder={t(input.placeholder as any)}
|
||||
@@ -192,7 +191,6 @@ const RenderPluginInput = ({
|
||||
isInvalid={isInvalid}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
defaultValue={input.defaultValue}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -203,7 +201,6 @@ const RenderPluginInput = ({
|
||||
onChange={onChange}
|
||||
isDisabled={isDisabled}
|
||||
isInvalid={isInvalid}
|
||||
defaultChecked={!!input.defaultValue}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -216,7 +213,6 @@ const RenderPluginInput = ({
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
isInvalid={isInvalid}
|
||||
defaultValue={input.defaultValue}
|
||||
/>
|
||||
);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user