Fix workflow detail (#3382)
* fix: loop node init * fix: workflow detail * fix: point table * add null check
This commit is contained in:
@@ -23,5 +23,7 @@ export const langMap = {
|
||||
|
||||
export const serviceSideProps = (content: any, ns: I18nNsType = []) => {
|
||||
const lang = content.req?.cookies?.NEXT_LOCALE || content.locale;
|
||||
return serverSideTranslations(lang, ['common', ...ns], null);
|
||||
|
||||
const extraLng = content.req?.cookies?.NEXT_LOCALE ? undefined : content.locales;
|
||||
return serverSideTranslations(lang, ['common', ...ns], null, extraLng);
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ComponentRef as ChatComponentRef } from '@/components/core/chat/ChatCon
|
||||
import { useForm, UseFormReturn } from 'react-hook-form';
|
||||
import { defaultChatData } from '@/global/core/chat/constants';
|
||||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { AppChatConfigType } from '@fastgpt/global/core/app/type';
|
||||
import { AppChatConfigType, VariableItemType } from '@fastgpt/global/core/app/type';
|
||||
import { FlowNodeInputItemType } from '@fastgpt/global/core/workflow/type/io';
|
||||
|
||||
type ChatBoxDataType = {
|
||||
@@ -29,7 +29,10 @@ type ChatItemContextType = {
|
||||
variablesForm: UseFormReturn<ChatBoxInputFormType, any>;
|
||||
pluginRunTab: PluginRunBoxTabEnum;
|
||||
setPluginRunTab: React.Dispatch<React.SetStateAction<PluginRunBoxTabEnum>>;
|
||||
resetVariables: (props?: { variables?: Record<string, any> }) => void;
|
||||
resetVariables: (props?: {
|
||||
variables?: Record<string, any>;
|
||||
variableList?: VariableItemType[];
|
||||
}) => void;
|
||||
clearChatRecords: () => void;
|
||||
chatBoxData: ChatBoxDataType;
|
||||
setChatBoxData: React.Dispatch<React.SetStateAction<ChatBoxDataType>>;
|
||||
@@ -44,7 +47,10 @@ export const ChatItemContext = createContext<ChatItemContextType>({
|
||||
setPluginRunTab: function (value: React.SetStateAction<PluginRunBoxTabEnum>): void {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
resetVariables: function (props?: { variables?: Record<string, any> }): void {
|
||||
resetVariables: function (props?: {
|
||||
variables?: Record<string, any>;
|
||||
variableList?: VariableItemType[];
|
||||
}): void {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
clearChatRecords: function (): void {
|
||||
@@ -69,27 +75,21 @@ const ChatItemContextProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [pluginRunTab, setPluginRunTab] = useState<PluginRunBoxTabEnum>(PluginRunBoxTabEnum.input);
|
||||
|
||||
const resetVariables = useCallback(
|
||||
(props?: { variables?: Record<string, any> }) => {
|
||||
const { variables = {} } = props || {};
|
||||
(props?: { variables?: Record<string, any>; variableList?: VariableItemType[] }) => {
|
||||
const { variables, variableList = [] } = props || {};
|
||||
|
||||
// Reset to empty input
|
||||
const data = variablesForm.getValues();
|
||||
|
||||
// Reset the old variables to empty
|
||||
const resetVariables: Record<string, any> = {};
|
||||
for (const key in data.variables) {
|
||||
resetVariables[key] = (() => {
|
||||
if (Array.isArray(data.variables[key])) {
|
||||
return [];
|
||||
}
|
||||
return '';
|
||||
})();
|
||||
let newVariableValue: Record<string, any> = {};
|
||||
if (variables) {
|
||||
variableList.forEach((item) => {
|
||||
newVariableValue[item.key] = variables[item.key];
|
||||
});
|
||||
} else {
|
||||
variableList.forEach((item) => {
|
||||
newVariableValue[item.key] = item.defaultValue;
|
||||
});
|
||||
}
|
||||
|
||||
variablesForm.setValue('variables', {
|
||||
...resetVariables,
|
||||
...variables
|
||||
});
|
||||
variablesForm.setValue('variables', newVariableValue);
|
||||
},
|
||||
[variablesForm]
|
||||
);
|
||||
|
||||
@@ -119,6 +119,7 @@ export const storeNode2FlowNode = ({
|
||||
|
||||
selectedTypeIndex: storeInput.selectedTypeIndex ?? templateInput.selectedTypeIndex,
|
||||
value: storeInput.value ?? templateInput.value,
|
||||
valueType: storeInput.valueType ?? templateInput.valueType,
|
||||
label: storeInput.label ?? templateInput.label
|
||||
};
|
||||
})
|
||||
@@ -148,7 +149,8 @@ export const storeNode2FlowNode = ({
|
||||
|
||||
id: storeOutput.id ?? templateOutput.id,
|
||||
label: storeOutput.label ?? templateOutput.label,
|
||||
value: storeOutput.value ?? templateOutput.value
|
||||
value: storeOutput.value ?? templateOutput.value,
|
||||
valueType: storeOutput.valueType ?? templateOutput.valueType
|
||||
};
|
||||
})
|
||||
.concat(
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { getDocPath } from '@/web/common/system/doc';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
|
||||
export const AI_POINT_USAGE_CARD_ROUTE = '/price#point-card';
|
||||
export const getAiPointUsageCardRoute = () => {
|
||||
const subPlans = useSystemStore.getState().subPlans;
|
||||
return subPlans?.planDescriptionUrl
|
||||
? getDocPath(subPlans.planDescriptionUrl)
|
||||
: AI_POINT_USAGE_CARD_ROUTE;
|
||||
};
|
||||
|
||||
export const EXTRA_PLAN_CARD_ROUTE = '/price#extra-plan';
|
||||
export const getExtraPlanCardRoute = () => {
|
||||
const subPlans = useSystemStore.getState().subPlans;
|
||||
|
||||
Reference in New Issue
Block a user