fix(web): workflow statement support variable
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 16:27:56
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-04-02 17:49:51
|
||||
* @Last Modified time: 2026-04-07 16:13:44
|
||||
*/
|
||||
/**
|
||||
* Copy Application Modal
|
||||
@@ -205,6 +205,7 @@ const FeaturesConfigModal = forwardRef<FeaturesConfigModalRef, FeaturesConfigMod
|
||||
/>
|
||||
<OpenStatementSettingModal
|
||||
ref={openStatementSettingModalRef}
|
||||
source={source}
|
||||
chatVariables={chatVariables}
|
||||
onSave={handleSaveStatement}
|
||||
/>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-03-05
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-04-07 14:22:40
|
||||
* @Last Modified time: 2026-04-07 16:58:10
|
||||
*/
|
||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||
import { Button, Form, Input, Flex, App } from 'antd';
|
||||
@@ -12,6 +12,8 @@ import RbModal from '@/components/RbModal';
|
||||
import type { FeaturesConfigForm } from '../../types'
|
||||
import type { Variable } from '../VariableList/types'
|
||||
import Tag from '@/components/Tag'
|
||||
import type { Application } from '@/views/ApplicationManagement/types';
|
||||
import Editor from '@/views/Workflow/components/Editor';
|
||||
|
||||
export interface OpenStatementSettingModalRef {
|
||||
handleOpen: (values?: FeaturesConfigForm['opening_statement']) => void;
|
||||
@@ -21,17 +23,21 @@ export interface OpenStatementSettingModalRef {
|
||||
interface OpenStatementSettingModalProps {
|
||||
onSave: (values: FeaturesConfigForm['opening_statement']) => void;
|
||||
chatVariables?: Variable[];
|
||||
source?: Application['type'];
|
||||
}
|
||||
|
||||
const OpenStatementSettingModal = forwardRef<OpenStatementSettingModalRef, OpenStatementSettingModalProps>(({
|
||||
onSave,
|
||||
chatVariables = []
|
||||
chatVariables = [],
|
||||
source
|
||||
}, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const { modal } = App.useApp()
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [form] = Form.useForm<FeaturesConfigForm['opening_statement']>();
|
||||
|
||||
console.log('chatVariables', chatVariables)
|
||||
|
||||
const handleClose = () => {
|
||||
setVisible(false);
|
||||
form.resetFields();
|
||||
@@ -49,6 +55,7 @@ const OpenStatementSettingModal = forwardRef<OpenStatementSettingModalRef, OpenS
|
||||
if (values?.enabled && values?.statement && values?.statement?.trim() !== '') {
|
||||
const usedVars = [...new Set([...values.statement?.matchAll(/\{\{(\w+)\}\}/g)].map(m => m[1]))]
|
||||
|
||||
console.log('usedVars', usedVars, chatVariables)
|
||||
const validNames = new Set(chatVariables.map(v => v.name))
|
||||
const invalid = usedVars.filter(v => !validNames.has(v))
|
||||
if (invalid.length > 0) {
|
||||
@@ -100,9 +107,12 @@ const OpenStatementSettingModal = forwardRef<OpenStatementSettingModalRef, OpenS
|
||||
label={t('application.opening_statement')}
|
||||
name="statement"
|
||||
>
|
||||
<Input.TextArea
|
||||
placeholder={t('common.pleaseEnter')}
|
||||
/>
|
||||
{source === 'workflow'
|
||||
? <Editor options={chatVariables as any} variant="outlined" />
|
||||
: <Input.TextArea
|
||||
placeholder={t('common.pleaseEnter')}
|
||||
/>
|
||||
}
|
||||
</Form.Item>
|
||||
|
||||
<Form.List name="suggested_questions">
|
||||
|
||||
Reference in New Issue
Block a user