Fix workflow detail (#3382)

* fix: loop node init

* fix: workflow detail

* fix: point table

* add null check
This commit is contained in:
Archer
2024-12-12 17:14:46 +08:00
committed by GitHub
parent 181b854342
commit ddddd998c8
34 changed files with 292 additions and 237 deletions

View File

@@ -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}>

View File

@@ -805,7 +805,7 @@ const ChatBox = ({
setQuestionGuide([]);
setValue('chatStarted', false);
abortRequest('leave');
}, [abortRequest, setValue]);
}, [chatId, appId, abortRequest, setValue]);
// Add listener
useEffect(() => {

View File

@@ -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);

View File

@@ -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}
/>
);
})();

View File

@@ -2,12 +2,15 @@ import { useSystemStore } from '@/web/common/system/useSystemStore';
import { StandardSubLevelEnum, SubModeEnum } from '@fastgpt/global/support/wallet/sub/constants';
import React, { useMemo } from 'react';
import { standardSubLevelMap } from '@fastgpt/global/support/wallet/sub/constants';
import { Box, Flex, Grid } from '@chakra-ui/react';
import { Box, Flex, Grid, useDisclosure } from '@chakra-ui/react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { getAiPointUsageCardRoute } from '@/web/support/wallet/sub/constants';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import dynamic from 'next/dynamic';
const AiPointsModal = dynamic(() =>
import('@/pages/price/components/Points').then((mod) => mod.AiPointsModal)
);
const StandardPlanContentList = ({
level,
@@ -18,7 +21,12 @@ const StandardPlanContentList = ({
}) => {
const { t } = useTranslation();
const { subPlans } = useSystemStore();
const router = useRouter();
const {
isOpen: isOpenAiPointsModal,
onClose: onCloseAiPointsModal,
onOpen: onOpenAiPointsModal
} = useDisclosure();
const planContent = useMemo(() => {
const plan = subPlans?.standard?.[level];
@@ -95,9 +103,7 @@ const StandardPlanContentList = ({
<QuestionTip
ml={1}
label={t('common:support.wallet.subscription.AI points click to read tip')}
onClick={() => {
router.push(getAiPointUsageCardRoute());
}}
onClick={onOpenAiPointsModal}
></QuestionTip>
</Flex>
</Flex>
@@ -121,6 +127,7 @@ const StandardPlanContentList = ({
<Box color={'myGray.600'}>{t('common:support.wallet.subscription.web_site_sync')}</Box>
</Flex>
)}
{isOpenAiPointsModal && <AiPointsModal onClose={onCloseAiPointsModal} />}
</Grid>
) : null;
};