mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-15 23:55:36 +00:00
compatible with old enums (#5219)
* compatible with old enums\ * add id
This commit is contained in:
@@ -341,7 +341,13 @@ export const toolSetData2FlowNodeIO = ({
|
||||
};
|
||||
|
||||
export const formatEditorVariablePickerIcon = (
|
||||
variables: { key: string; label: string; type?: `${VariableInputEnum}`; required?: boolean }[]
|
||||
variables: {
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
type?: `${VariableInputEnum}`;
|
||||
required?: boolean;
|
||||
}[]
|
||||
): EditorVariablePickerType[] => {
|
||||
return variables.map((item) => ({
|
||||
...item,
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import type { WorkflowIOValueTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
|
||||
export type EditorVariablePickerType = {
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
required?: boolean;
|
||||
|
@@ -385,7 +385,7 @@ const TableItem = ({
|
||||
onClick={() => {
|
||||
const formattedItem = {
|
||||
...item,
|
||||
list: item.enums || []
|
||||
list: item.enums?.map((item) => ({ label: item.value, value: item.value })) || []
|
||||
};
|
||||
reset(formattedItem);
|
||||
}}
|
||||
|
@@ -100,11 +100,14 @@ const InputRender = (props: InputRenderProps) => {
|
||||
}
|
||||
|
||||
if (inputType === InputTypeEnum.select) {
|
||||
return <MySelect {...commonProps} list={props.list || []} h={10} />;
|
||||
const list =
|
||||
props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || [];
|
||||
return <MySelect {...commonProps} list={list} h={10} />;
|
||||
}
|
||||
|
||||
if (inputType === InputTypeEnum.multipleSelect) {
|
||||
const { list = [] } = props;
|
||||
const list =
|
||||
props.list || props.enums?.map((item) => ({ label: item.value, value: item.value })) || [];
|
||||
return (
|
||||
<MultipleSelect<string>
|
||||
{...commonProps}
|
||||
|
@@ -40,6 +40,9 @@ type SpecificProps =
|
||||
// select & multipleSelect
|
||||
inputType: InputTypeEnum.select | InputTypeEnum.multipleSelect;
|
||||
list?: { label: string; value: string }[];
|
||||
|
||||
// old version
|
||||
enums?: { value: string }[];
|
||||
}
|
||||
| {
|
||||
// JSONEditor
|
||||
|
@@ -174,6 +174,7 @@ const RenderHttpMethodAndUrl = React.memo(function RenderHttpMethodAndUrl({
|
||||
return (
|
||||
feConfigs?.externalProviderWorkflowVariables?.map((item) => ({
|
||||
key: item.key,
|
||||
id: item.key,
|
||||
label: item.name
|
||||
})) || []
|
||||
);
|
||||
@@ -294,6 +295,7 @@ export function RenderHttpProps({
|
||||
return (
|
||||
feConfigs?.externalProviderWorkflowVariables?.map((item) => ({
|
||||
key: item.key,
|
||||
id: item.key,
|
||||
label: item.name
|
||||
})) || []
|
||||
);
|
||||
@@ -498,6 +500,7 @@ const RenderForm = ({
|
||||
input: FlowNodeInputItemType;
|
||||
variables: EditorVariableLabelPickerType[];
|
||||
externalProviderWorkflowVariables: {
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
}[];
|
||||
@@ -684,6 +687,7 @@ const RenderBody = ({
|
||||
typeInput: FlowNodeInputItemType | undefined;
|
||||
variables: EditorVariableLabelPickerType[];
|
||||
externalProviderWorkflowVariables: {
|
||||
id: string;
|
||||
key: string;
|
||||
label: string;
|
||||
}[];
|
||||
|
@@ -67,6 +67,7 @@ const NodeVariableUpdate = ({ data, selected }: NodeProps<FlowNodeItemType>) =>
|
||||
const externalProviderWorkflowVariables = useMemo(() => {
|
||||
return (
|
||||
feConfigs?.externalProviderWorkflowVariables?.map((item) => ({
|
||||
id: item.key,
|
||||
key: item.key,
|
||||
label: item.name
|
||||
})) || []
|
||||
|
@@ -51,6 +51,7 @@ const CommonInputForm = ({ item, nodeId }: RenderInputProps) => {
|
||||
const externalVariables = useMemo(() => {
|
||||
return (
|
||||
feConfigs?.externalProviderWorkflowVariables?.map((item) => ({
|
||||
id: item.key,
|
||||
key: item.key,
|
||||
label: item.name
|
||||
})) || []
|
||||
|
@@ -247,7 +247,10 @@ const EditModal = ({ onClose, ...props }: RenderInputProps & { onClose: () => vo
|
||||
</Flex>
|
||||
|
||||
<PromptEditor
|
||||
variables={quoteTemplateVariables}
|
||||
variables={quoteTemplateVariables.map((item) => ({
|
||||
...item,
|
||||
id: item.key
|
||||
}))}
|
||||
minH={160}
|
||||
title={t('common:core.app.Quote templates')}
|
||||
placeholder={t('workflow:quote_content_placeholder')}
|
||||
@@ -268,7 +271,10 @@ const EditModal = ({ onClose, ...props }: RenderInputProps & { onClose: () => vo
|
||||
/>
|
||||
</Flex>
|
||||
<PromptEditor
|
||||
variables={quotePromptVariables}
|
||||
variables={quotePromptVariables.map((item) => ({
|
||||
...item,
|
||||
id: item.key
|
||||
}))}
|
||||
title={t('common:core.app.Quote prompt')}
|
||||
minH={300}
|
||||
placeholder={t('workflow:quote_prompt_tip', {
|
||||
|
@@ -107,6 +107,7 @@ export const getEditorVariables = ({
|
||||
const nodeVariables = currentNode.inputs
|
||||
.filter((input) => input.canEdit)
|
||||
.map((item) => ({
|
||||
id: item.key,
|
||||
key: item.key,
|
||||
label: item.label,
|
||||
parent: {
|
||||
@@ -137,6 +138,7 @@ export const getEditorVariables = ({
|
||||
)
|
||||
.map((output) => {
|
||||
return {
|
||||
id: output.id,
|
||||
label: t((output.label as any) || ''),
|
||||
key: output.id,
|
||||
parent: {
|
||||
|
@@ -582,30 +582,35 @@ export function filterSensitiveFormData(appForm: AppSimpleEditFormType) {
|
||||
|
||||
export const workflowSystemVariables: EditorVariablePickerType[] = [
|
||||
{
|
||||
id: 'userId',
|
||||
key: 'userId',
|
||||
label: i18nT('workflow:use_user_id'),
|
||||
required: true,
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
id: 'appId',
|
||||
key: 'appId',
|
||||
label: i18nT('common:core.module.http.AppId'),
|
||||
required: true,
|
||||
valueType: WorkflowIOValueTypeEnum.string
|
||||
},
|
||||
{
|
||||
id: 'chatId',
|
||||
key: 'chatId',
|
||||
label: i18nT('common:core.module.http.ChatId'),
|
||||
valueType: WorkflowIOValueTypeEnum.string,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
id: 'responseChatItemId',
|
||||
key: 'responseChatItemId',
|
||||
label: i18nT('common:core.module.http.ResponseChatItemId'),
|
||||
valueType: WorkflowIOValueTypeEnum.string,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
id: 'histories',
|
||||
key: 'histories',
|
||||
label: i18nT('common:core.module.http.Histories'),
|
||||
required: true,
|
||||
@@ -613,6 +618,7 @@ export const workflowSystemVariables: EditorVariablePickerType[] = [
|
||||
valueDesc: chatHistoryValueDesc
|
||||
},
|
||||
{
|
||||
id: 'cTime',
|
||||
key: 'cTime',
|
||||
label: i18nT('common:core.module.http.Current time'),
|
||||
required: true,
|
||||
|
@@ -54,7 +54,7 @@ export const getGlobalVariableNode = ({
|
||||
nodeId: VARIABLE_NODE_ID,
|
||||
...template,
|
||||
outputs: globalVariables.map((item) => ({
|
||||
id: item.key,
|
||||
id: item.id,
|
||||
type: FlowNodeOutputTypeEnum.static,
|
||||
label: item.label,
|
||||
key: item.key,
|
||||
|
Reference in New Issue
Block a user